From 052c84b948b6d35194822fd5acbd13f20f70bcc0 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 13:47:56 -0700 Subject: [PATCH 01/21] create runner-specific test folders --- .../babelGeneratedDoubleDefault.js | 19 +++ .../babelGeneratedDoubleDefault/package.json | 4 + tests/local/mainUtil.js | 9 +- tests/package.json | 37 ++++-- tests/package.json.esmock.export.js | 35 ++++++ tests/tests-ava/package.json | 19 +++ .../{ => spec}/esmock.ava.only.spec.js | 6 +- tests/tests-ava/{ => spec}/esmock.ava.spec.js | 116 +++++++++--------- tests/tests-node/package.json | 18 +++ .../esmock.node-ts.test.ts | 2 +- tests/tests-nodets/package.json | 19 +++ tests/{ => tests-nodets}/tsconfig.json | 0 tests/tests-uvu/esmock.uvu.spec.js | 11 +- tests/tests-uvu/package.json | 19 +++ 14 files changed, 237 insertions(+), 77 deletions(-) create mode 100644 tests/local/babelGeneratedDoubleDefault/babelGeneratedDoubleDefault.js create mode 100644 tests/local/babelGeneratedDoubleDefault/package.json create mode 100644 tests/package.json.esmock.export.js create mode 100644 tests/tests-ava/package.json rename tests/tests-ava/{ => spec}/esmock.ava.only.spec.js (63%) rename tests/tests-ava/{ => spec}/esmock.ava.spec.js (71%) create mode 100644 tests/tests-node/package.json rename tests/{tests-tsnode => tests-nodets}/esmock.node-ts.test.ts (88%) create mode 100644 tests/tests-nodets/package.json rename tests/{ => tests-nodets}/tsconfig.json (100%) create mode 100644 tests/tests-uvu/package.json diff --git a/tests/local/babelGeneratedDoubleDefault/babelGeneratedDoubleDefault.js b/tests/local/babelGeneratedDoubleDefault/babelGeneratedDoubleDefault.js new file mode 100644 index 00000000..0be92c9e --- /dev/null +++ b/tests/local/babelGeneratedDoubleDefault/babelGeneratedDoubleDefault.js @@ -0,0 +1,19 @@ +// this undesirable output was commonly generated by babel w browser-breaking +// defineProperty and default.default definitions + +/* eslint-disable */ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = void 0; + +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _default = function _default() { + return 'unmocked default.default'; +}; + +exports["default"] = _default; +/* eslint-enable */ diff --git a/tests/local/babelGeneratedDoubleDefault/package.json b/tests/local/babelGeneratedDoubleDefault/package.json new file mode 100644 index 00000000..7da14565 --- /dev/null +++ b/tests/local/babelGeneratedDoubleDefault/package.json @@ -0,0 +1,4 @@ +{ + "description": "problematic cjs file type generated by babel", + "main": "./babelGeneratedDoubleDefault.js" +} diff --git a/tests/local/mainUtil.js b/tests/local/mainUtil.js index 6cfc43bc..dce8e5d0 100644 --- a/tests/local/mainUtil.js +++ b/tests/local/mainUtil.js @@ -1,4 +1,5 @@ import formurlencoded from 'form-urlencoded'; +import babelGeneratedDoubleDefault from 'babelGeneratedDoubleDefault'; import { mainUtilNamedExportOne, mainUtilNamedExportTwo @@ -6,12 +7,15 @@ import { const mainUtil = () => 'mainUtil'; -const createString = () => formurlencoded.default({ +const createString = () => formurlencoded({ mainUtil : 'a string', mainUtilNamedExportOneValue : mainUtilNamedExportOne(), mainUtilNamedExportTwoValue : mainUtilNamedExportTwo() }); +const callBabelGeneratedDoubleDefault = o => ( + babelGeneratedDoubleDefault.default(o) ); + const causeRuntimeError = () => mainUtil()(); export default mainUtil; @@ -19,5 +23,6 @@ export default mainUtil; export { mainUtil, createString, - causeRuntimeError + causeRuntimeError, + callBabelGeneratedDoubleDefault }; diff --git a/tests/package.json b/tests/package.json index 2ff0f87a..260ceb88 100644 --- a/tests/package.json +++ b/tests/package.json @@ -1,5 +1,4 @@ { - "name": "esmock-tests", "type": "module", "license": "ISC", "description": "various esmock unit tests", @@ -7,18 +6,40 @@ "type": "git", "url": "https://github.com/iambumblehead/esmock.git" }, + "main": "package.json.esmock.export.js", "dependencies": { - "esmock": "file:..", - "ts-node": "^10.9.1", - "uvu": "0.5.3", - "ava": "^4.0.1", "eslint": "^8.12.0", - "ts-node": "^10.9.1", - "form-urlencoded": "4.2.1", + "sinon": "^12.0.1", + "form-urlencoded": "^6.0.7", "run-script-os": "^1.1.6", - "sinon": "^12.0.1" + "check-node-version": "^4.2.1", + "npm-run-all": "^4.1.5", + "babelGeneratedDoubleDefault": "file:./local/babelGeneratedDoubleDefault" }, "scripts": { + "note": "windows18 test should be improved for finding node version", + "install:esmock": "cd .. && npm install", + "install:test-ava": "cd tests-ava && npm install", + "install:test-uvu": "cd tests-uvu && npm install", + "install:test-node": "cd tests-node && npm install", + "install:test-nodets": "cd tests-nodets && npm install", + "install:all": "npm-run-all install:test*", + + "test:test-ava": "cd tests-ava && npm test", + "test:test-uvu": "cd tests-uvu && npm test", + "test:test-node": "check-node-version --node '>= 18.0.0' && cd tests-node && npm test", + "test:test-nodets": "check-node-version --node '>= 18.0.0' && cd tests-nodets && npm test", + "test:all": "npm-run-all test:test*", + "test:all-ci": "cd .. && npm run mini && cd tests && npm run test:all", + + "mini": "cd .. && npm run" + "mini:default": "npx esbuild ./src/*js --minify --allow-overwrite --outdir=src", + "mini:win32": "cd src && forfiles /m \"*.js\" /c \"cmd /c npx esbuild @file --minify --allow-overwrite --outfile=@file\"", + "mini": "run-script-os", + "test-ci": "npm run mini && npm run test", + + "nopostinstall": "npm ru", + "test-node-esbuildts": "node --loader=@esbuild-kit/esm-loader --loader=esmock --test ./tests-nodets/*ts", "test-ava": "npx ava --node-arguments=\"--loader=esmock\" ./tests-ava/*.spec.js", "test-uvu": "node --loader=esmock ./node_modules/uvu/bin.js ./tests-uvu/", diff --git a/tests/package.json.esmock.export.js b/tests/package.json.esmock.export.js new file mode 100644 index 00000000..24f5b8e0 --- /dev/null +++ b/tests/package.json.esmock.export.js @@ -0,0 +1,35 @@ +export {default, load, resolve, getSource} from '../src/esmockLoader.js'; + +// this file is used in tandem with two other things, +// +// 1. a "main" definition in ./package.json, +// ``` +// { +// "main": "tests.esmock.export.js" +// } +// ``` +// +// 2. an "esmock" definition in child ./tests-ava/package.json +// ``` +// { +// "dependencies": { +// "esmock": "file:.." +// } +// } +// ``` +// +// together, these allow child folder tests to, +// * import "esmock" rather than "../../src/esmock.js" +// * use "--loader=esmock" rather than "../../src/esmockLoader.js" +// +// Previously, there existed only one test folder and package.json, +// and during that time the package.json only needed to define +// the esmock dependency as a local file eg "esmock": "file:.." +// +// When subdirectories were introduced, "esmock": "file:../.." did not +// work with "--loader=esmock". The loader ignored the longer path and +// threw an error message, creating need for this file. +// +// Error [ERR_MODULE_NOT_FOUND]: Cannot find package \ +// '/root/esmock/tests/tests-ava/node_modules/esmock/' \ +// imported from /root/esmock/tests/tests-ava/ diff --git a/tests/tests-ava/package.json b/tests/tests-ava/package.json new file mode 100644 index 00000000..33cd885e --- /dev/null +++ b/tests/tests-ava/package.json @@ -0,0 +1,19 @@ +{ + "type": "module", + "description": "esmock unit tests, ava", + "repository": { + "type": "git", + "url": "https://github.com/iambumblehead/esmock.git" + }, + "dependencies": { + "ava": "^4.3.1", + "esmock": "file:..", + "sinon": "file:../node_modules/sinon", + "eslint": "file:../node_modules/eslint", + "form-urlencoded": "file:../node_modules/form-urlencoded", + "babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault" + }, + "scripts": { + "test": "ava --node-arguments=\"--loader=esmock\"" + } +} diff --git a/tests/tests-ava/esmock.ava.only.spec.js b/tests/tests-ava/spec/esmock.ava.only.spec.js similarity index 63% rename from tests/tests-ava/esmock.ava.only.spec.js rename to tests/tests-ava/spec/esmock.ava.only.spec.js index 8f599e85..e1b91149 100644 --- a/tests/tests-ava/esmock.ava.only.spec.js +++ b/tests/tests-ava/spec/esmock.ava.only.spec.js @@ -1,10 +1,12 @@ import test from 'ava'; -import esmock from '../../src/esmock.js'; +// import esmock from '../../../src/esmock.js'; +import esmock from 'esmock'; // this error can occur when sources do not define 'esmockloader' // on 'global' but use a process linked variable instead test.only('should not error when esmock used with ava.only', async t => { - await esmock('../local/mainUtil.js', { +// console.log( 'is?', global.esmockloader ); + await esmock('../../local/mainUtil.js', { 'form-urlencoded' : () => 'mock encode' }); diff --git a/tests/tests-ava/esmock.ava.spec.js b/tests/tests-ava/spec/esmock.ava.spec.js similarity index 71% rename from tests/tests-ava/esmock.ava.spec.js rename to tests/tests-ava/spec/esmock.ava.spec.js index 20c4318d..776a2630 100644 --- a/tests/tests-ava/esmock.ava.spec.js +++ b/tests/tests-ava/spec/esmock.ava.spec.js @@ -1,9 +1,9 @@ import test from 'ava'; -import esmock from '../../src/esmock.js'; +import esmock from 'esmock'; import sinon from 'sinon'; test('should return un-mocked file', async t => { - const main = await esmock('../local/main.js'); + const main = await esmock('../../local/main.js'); const mainqs = [ 'a+string', 'mainUtilNamedExportOneValue=namedExportOne', @@ -14,8 +14,8 @@ test('should return un-mocked file', async t => { }); test('should mock a local file', async t => { - const main = await esmock.px('../local/main.js', { - '../local/mainUtil.js' : { + const main = await esmock.px('../../local/main.js', { + '../../local/mainUtil.js' : { createString : () => 'test string' } }); @@ -33,27 +33,35 @@ test.serial('should throw error if !esmockloader', async t => { }); test('should throw error if local file not found', async t => { - await t.throwsAsync(() => esmock('../local/not/found.js', { - '../local/mainUtil.js' : { + const err = await t.throwsAsync(() => esmock('../../local/not/found.js', { + '../../local/mainUtil.js' : { createString : () => 'test string' } }), { - message : 'modulePath not found: "../local/not/found.js"' + instanceOf : Error, + name : 'Error' }); + + t.true( err.message.startsWith( + 'modulePath not found: "../../local/not/found.js"' ) ); }); test('should throw error if local definition file not found', async t => { - await t.throwsAsync(() => esmock('../local/not/found.js', { - '../local/not/found.js' : { + const err = await t.throwsAsync(() => esmock('../../local/not/found.js', { + '../../local/not/found.js' : { createString : () => 'test string' } }), { - message : /not a valid path: \"..\/local\/not\/found.js\" \(used by/ + instanceOf : Error, + name : 'Error' }); + + t.true( err.message.startsWith( + 'not a valid path: "../../local/not/found.js"' ) ); }); test('should mock a module', async t => { - const main = await esmock('../local/mainUtil.js', { + const main = await esmock('../../local/mainUtil.js', { 'form-urlencoded' : () => 'mock encode' }); @@ -62,8 +70,8 @@ test('should mock a module', async t => { }); test('should mock a module, globally', async t => { - const main = await esmock('../local/main.js', { - '../local/mainUtilNamedExports.js' : { + const main = await esmock('../../local/main.js', { + '../../local/mainUtilNamedExports.js' : { mainUtilNamedExportOne : 'mocked' } }, { @@ -85,8 +93,8 @@ test('should mock a module, globally', async t => { }); test('should purge local and global mocks', async t => { - await esmock('../local/main.js', { - '../local/mainUtilNamedExports.js' : { + await esmock('../../local/main.js', { + '../../local/mainUtilNamedExports.js' : { mainUtilNamedExportOne : 'mocked' } }, { @@ -110,13 +118,13 @@ test('should purge local and global mocks', async t => { }); test('should mock a module, many times differently', async t => { - const mainfoo = await esmock('../local/mainUtil.js', { + const mainfoo = await esmock('../../local/mainUtil.js', { 'form-urlencoded' : () => 'mock encode foo' }); - const mainbar = await esmock('../local/mainUtil.js', { + const mainbar = await esmock('../../local/mainUtil.js', { 'form-urlencoded' : () => 'mock encode bar' }); - const mainbaz = await esmock('../local/mainUtil.js', { + const mainbaz = await esmock('../../local/mainUtil.js', { 'form-urlencoded' : () => 'mock encode baz' }); t.is(typeof mainfoo, 'function'); @@ -126,7 +134,7 @@ test('should mock a module, many times differently', async t => { }); test('should return un-mocked file (again)', async t => { - const main = await esmock('../local/main.js'); + const main = await esmock('../../local/main.js'); const mainqs = [ 'a+string', 'mainUtilNamedExportOneValue=namedExportOne', @@ -137,8 +145,8 @@ test('should return un-mocked file (again)', async t => { }); test('should mock local file', async t => { - const mainUtil = await esmock.px('../local/mainUtil.js', { - '../local/mainUtilNamedExports.js' : { + const mainUtil = await esmock.px('../../local/mainUtil.js', { + '../../local/mainUtilNamedExports.js' : { mainUtilNamedExportOne : () => 'foobar' } }); @@ -153,9 +161,9 @@ test('should mock local file', async t => { }); test('should mock module and local file at the same time', async t => { - const mainUtil = await esmock.px('../local/mainUtil.js', { + const mainUtil = await esmock.px('../../local/mainUtil.js', { 'form-urlencoded' : o => JSON.stringify(o), - '../local/mainUtilNamedExports.js' : { + '../../local/mainUtilNamedExports.js' : { mainUtilNamedExportOne : () => 'foobar' } }); @@ -168,24 +176,20 @@ test('should mock module and local file at the same time', async t => { }); test('__esModule definition, inconsequential', async t => { - const mainUtil = await esmock.px('../local/mainUtil.js', { - 'form-urlencoded' : o => JSON.stringify(o), - '../local/mainUtilNamedExports.js' : { + const mainUtil = await esmock.px('../../local/mainUtil.js', { + 'babelGeneratedDoubleDefault' : o => o, + '../../local/mainUtilNamedExports.js' : { mainUtilNamedExportOne : () => 'foobar', __esModule : true } }); - t.is(mainUtil.createString(), JSON.stringify({ - mainUtil : 'a string', - mainUtilNamedExportOneValue : 'foobar', - mainUtilNamedExportTwoValue : 'namedExportTwo' - })); + t.is(mainUtil.callBabelGeneratedDoubleDefault('mocked'), 'mocked'); }); test('should work well with sinon', async t => { - const mainUtil = await esmock.px('../local/mainUtil.js', { - '../local/mainUtilNamedExports.js' : { + const mainUtil = await esmock.px('../../local/mainUtil.js', { + '../../local/mainUtilNamedExports.js' : { mainUtilNamedExportOne : sinon.stub().returns('foobar') } }); @@ -198,24 +202,24 @@ test('should work well with sinon', async t => { }); test('should mock an mjs file', async t => { - const main = await esmock('../local/usesmjsModule.js', { - '../local/exampleMJS.mjs' : () => 'first mocked' + const main = await esmock('../../local/usesmjsModule.js', { + '../../local/exampleMJS.mjs' : () => 'first mocked' }); t.is(main.verifyImportedMock(), 'first mocked'); }); test('should mock an mjs file, again', async t => { - const main = await esmock('../local/usesmjsModule.js', { - '../local/exampleMJS.mjs' : () => 'second mocked' + const main = await esmock('../../local/usesmjsModule.js', { + '../../local/exampleMJS.mjs' : () => 'second mocked' }); t.is(main.verifyImportedMock(), 'second mocked'); }); test('should mock an exported constant values', async t => { - const main = await esmock('../local/usesmjsModule.js', { - '../local/env.js' : { + const main = await esmock('../../local/usesmjsModule.js', { + '../../local/env.js' : { TESTCONSTANT : 'hello world' } }); @@ -224,7 +228,7 @@ test('should mock an exported constant values', async t => { }); test('should mock core module', async t => { - const usesCoreModule = await esmock('../local/usesCoreModule.js', { + const usesCoreModule = await esmock('../../local/usesCoreModule.js', { fs : { existsSync : () => true, readFileSync : filepath => filepath === 'checkfilepath.js' @@ -237,8 +241,8 @@ test('should mock core module', async t => { }); test('should apply third parameter "global" definitions', async t => { - const main = await esmock.px('../local/main.js', { - '../local/mainUtil.js' : { + const main = await esmock.px('../../local/main.js', { + '../../local/mainUtil.js' : { exportedFunction : () => 'foobar' } }, { @@ -254,7 +258,7 @@ test('should apply third parameter "global" definitions', async t => { }); test('returns spread-imported [object Module] default export', async t => { - const main = await esmock('../local/usesObjectModule.js', { + const main = await esmock('../../local/usesObjectModule.js', { fs : { exportedFunction : () => 'foobar' } @@ -264,7 +268,7 @@ test('returns spread-imported [object Module] default export', async t => { }); test('mocks inline `async import("name")`', async t => { - const writeJSConfigFile = await esmock.p('../local/usesInlineImport.mjs', { + const writeJSConfigFile = await esmock.p('../../local/usesInlineImport.mjs', { eslint : { ESLint : function (...o) { this.stringify = () => JSON.stringify(...o); @@ -295,7 +299,7 @@ test('mocks inline `async import("name")`', async t => { }); test('should have small querystring in stacktrace filename', async t => { - const { causeRuntimeError } = await esmock('../local/mainUtil.js'); + const { causeRuntimeError } = await esmock('../../local/mainUtil.js'); try { causeRuntimeError(); @@ -309,8 +313,8 @@ test('should have small querystring in stacktrace filename', async t => { test('should have small querystring in stacktrace filename, deep', async t => { const { causeRuntimeErrorFromImportedFile - } = await esmock.px('../local/main.js', {}, { - '../local/mainUtil.js' : { + } = await esmock.px('../../local/main.js', {}, { + '../../local/mainUtil.js' : { causeRuntimeError : () => { t.nonexistantmethod(); } @@ -330,8 +334,8 @@ test('should have small querystring in stacktrace filename, deep', async t => { test('should have small querystring in stacktrace filename, deep2', async t => { const causeDeepErrorParent = - await esmock.px('../local/causeDeepErrorParent.js', {}, { - '../local/causeDeepErrorGrandChild.js' : { + await esmock.px('../../local/causeDeepErrorParent.js', {}, { + '../../local/causeDeepErrorGrandChild.js' : { what : 'now' } }); @@ -352,23 +356,23 @@ test('should have small querystring in stacktrace filename, deep2', async t => { }); test('should merge "default" value, when safe', async t => { - const main = await esmock('../local/main.js'); + const main = await esmock('../../local/main.js'); t.is(main(), main.default()); - const mockMainA = await esmock('../local/exportsMain.js', { - '../local/main.js' : () => 'mocked main' + const mockMainA = await esmock('../../local/exportsMain.js', { + '../../local/main.js' : () => 'mocked main' }); - const mockMainB = await esmock('../local/exportsMain.js', { - '../local/main.js' : { default : () => 'mocked main' } + const mockMainB = await esmock('../../local/exportsMain.js', { + '../../local/main.js' : { default : () => 'mocked main' } }); t.is(mockMainA(), mockMainB()); }); test('should not error when mocked file has space in path', async t => { - const main = await esmock('../local/main.js', { - '../local/space in path/wild-file.js' : { + const main = await esmock('../../local/main.js', { + '../../local/space in path/wild-file.js' : { default : 'tamed' } }); diff --git a/tests/tests-node/package.json b/tests/tests-node/package.json new file mode 100644 index 00000000..0abfe517 --- /dev/null +++ b/tests/tests-node/package.json @@ -0,0 +1,18 @@ +{ + "type": "module", + "description": "esmock unit tests, node native runner", + "repository": { + "type": "git", + "url": "https://github.com/iambumblehead/esmock.git" + }, + "dependencies": { + "esmock": "file:..", + "sinon": "file:../node_modules/sinon", + "eslint": "file:../node_modules/eslint", + "form-urlencoded": "file:../node_modules/form-urlencoded", + "babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault" + }, + "scripts": { + "test": "node --loader=esmock --test" + } +} diff --git a/tests/tests-tsnode/esmock.node-ts.test.ts b/tests/tests-nodets/esmock.node-ts.test.ts similarity index 88% rename from tests/tests-tsnode/esmock.node-ts.test.ts rename to tests/tests-nodets/esmock.node-ts.test.ts index 8adb1ff4..4c938782 100644 --- a/tests/tests-tsnode/esmock.node-ts.test.ts +++ b/tests/tests-nodets/esmock.node-ts.test.ts @@ -1,6 +1,6 @@ import test from 'node:test'; import assert from 'assert'; -import esmock from '../../src/esmock.js'; +import esmock from 'esmock'; test('should mock ts when using node-ts', { only : true }, async () => { const main = await esmock('../local/main.ts', { diff --git a/tests/tests-nodets/package.json b/tests/tests-nodets/package.json new file mode 100644 index 00000000..948e3b04 --- /dev/null +++ b/tests/tests-nodets/package.json @@ -0,0 +1,19 @@ +{ + "type": "module", + "description": "esmock unit tests, ts-node/esm with node native runner", + "repository": { + "type": "git", + "url": "https://github.com/iambumblehead/esmock.git" + }, + "dependencies": { + "ts-node": "^10.9.1", + "esmock": "file:..", + "sinon": "file:../node_modules/sinon", + "eslint": "file:../node_modules/eslint", + "form-urlencoded": "file:../node_modules/form-urlencoded", + "babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault" + }, + "scripts": { + "test": "node --loader=ts-node/esm --loader=esmock --test *test.ts" + } +} diff --git a/tests/tsconfig.json b/tests/tests-nodets/tsconfig.json similarity index 100% rename from tests/tsconfig.json rename to tests/tests-nodets/tsconfig.json diff --git a/tests/tests-uvu/esmock.uvu.spec.js b/tests/tests-uvu/esmock.uvu.spec.js index d48c34dd..77e3c8e1 100644 --- a/tests/tests-uvu/esmock.uvu.spec.js +++ b/tests/tests-uvu/esmock.uvu.spec.js @@ -1,8 +1,7 @@ import { test } from 'uvu'; import * as assert from 'uvu/assert'; import sinon from 'sinon'; - -import esmock from '../../src/esmock.js'; +import esmock from 'esmock'; test('should return un-mocked file', async () => { const main = await esmock('../local/main.js'); @@ -179,18 +178,14 @@ test('should mock module and local file at the same time', async () => { test('__esModule definition, inconsequential', async () => { const mainUtil = await esmock.px('../local/mainUtil.js', { - 'form-urlencoded' : o => JSON.stringify(o), + 'babelGeneratedDoubleDefault' : o => o, '../local/mainUtilNamedExports.js' : { mainUtilNamedExportOne : () => 'foobar', __esModule : true } }); - assert.is(mainUtil.createString(), JSON.stringify({ - mainUtil : 'a string', - mainUtilNamedExportOneValue : 'foobar', - mainUtilNamedExportTwoValue : 'namedExportTwo' - })); + assert.is(mainUtil.callBabelGeneratedDoubleDefault('mocked'), 'mocked'); }); test('should work well with sinon', async () => { diff --git a/tests/tests-uvu/package.json b/tests/tests-uvu/package.json new file mode 100644 index 00000000..025fdc77 --- /dev/null +++ b/tests/tests-uvu/package.json @@ -0,0 +1,19 @@ +{ + "type": "module", + "description": "esmock unit tests, uvu", + "repository": { + "type": "git", + "url": "https://github.com/iambumblehead/esmock.git" + }, + "dependencies": { + "uvu": "^0.5.6", + "esmock": "file:..", + "sinon": "file:../node_modules/sinon", + "eslint": "file:../node_modules/eslint", + "form-urlencoded": "file:../node_modules/form-urlencoded", + "babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault" + }, + "scripts": { + "test": "node --loader=esmock ./node_modules/uvu/bin.js" + } +} From cf5539d67a9dced3a3d995be8b9c3f53c69da6cd Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 13:55:02 -0700 Subject: [PATCH 02/21] update package.json, use tests folder for mini --- package.json | 12 +++--------- tests/package.json | 26 +++++--------------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 201204e4..37522fdb 100644 --- a/package.json +++ b/package.json @@ -54,16 +54,10 @@ "dependencies": { "resolvewithplus": "^0.8.4" }, - "devDependencies": { - "run-script-os": "^1.1.6" - }, "scripts": { - "mini:default": "npx esbuild ./src/*js --minify --allow-overwrite --outdir=src", - "mini:win32": "cd src && forfiles /m \"*.js\" /c \"cmd /c npx esbuild @file --minify --allow-overwrite --outfile=@file\"", - "mini": "run-script-os", - "test-ci": "npm run mini && npm run test", + "test": "cd tests && npm run test:all", + "test-ci": "cd tests && npm run test:all-ci", "prepublishOnly": "npm run test-ci; npm pkg delete scripts devDependencies", - "lint": "npx eslint . --ext .js,.mjs", - "test": "cd tests && npm install && npm test" + "lint": "npx eslint . --ext .js,.mjs" } } diff --git a/tests/package.json b/tests/package.json index 260ceb88..599979ae 100644 --- a/tests/package.json +++ b/tests/package.json @@ -17,7 +17,10 @@ "babelGeneratedDoubleDefault": "file:./local/babelGeneratedDoubleDefault" }, "scripts": { - "note": "windows18 test should be improved for finding node version", + "mini:default": "cd .. && npx esbuild ./src/*js --minify --allow-overwrite --outdir=src", + "mini:win32": "cd .. && cd src && forfiles /m \"*.js\" /c \"cmd /c npx esbuild @file --minify --allow-overwrite --outfile=@file\"", + "mini": "run-script-os", + "install:esmock": "cd .. && npm install", "install:test-ava": "cd tests-ava && npm install", "install:test-uvu": "cd tests-uvu && npm install", @@ -30,25 +33,6 @@ "test:test-node": "check-node-version --node '>= 18.0.0' && cd tests-node && npm test", "test:test-nodets": "check-node-version --node '>= 18.0.0' && cd tests-nodets && npm test", "test:all": "npm-run-all test:test*", - "test:all-ci": "cd .. && npm run mini && cd tests && npm run test:all", - - "mini": "cd .. && npm run" - "mini:default": "npx esbuild ./src/*js --minify --allow-overwrite --outdir=src", - "mini:win32": "cd src && forfiles /m \"*.js\" /c \"cmd /c npx esbuild @file --minify --allow-overwrite --outfile=@file\"", - "mini": "run-script-os", - "test-ci": "npm run mini && npm run test", - - "nopostinstall": "npm ru", - - "test-node-esbuildts": "node --loader=@esbuild-kit/esm-loader --loader=esmock --test ./tests-nodets/*ts", - "test-ava": "npx ava --node-arguments=\"--loader=esmock\" ./tests-ava/*.spec.js", - "test-uvu": "node --loader=esmock ./node_modules/uvu/bin.js ./tests-uvu/", - "test-node": "node --no-warnings --loader=esmock --test ./tests-node/", - "test-node-ts": "node --loader=ts-node/esm --loader=esmock --test ./tests-tsnode/*ts", - "test-node18": "npm run test-node && npm run test-node-ts", - "test-nodeis18": "if (node -v | grep v18); then npm run test-node18; fi;", - "test:default": "npm run test-nodeis18 && npm run test-ava && npm run test-uvu", - "test:windows": "npm run test-ava && npm run test-uvu", - "test": "npm install && run-script-os" + "test:all-ci": "npm run mini && npm run test:all" } } From 24f6e7e1644ac8ed4e7a07dce14282ce23918d0a Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 13:57:57 -0700 Subject: [PATCH 03/21] use dedicated script for reducing package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 37522fdb..dab0dd34 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "scripts": { "test": "cd tests && npm run test:all", "test-ci": "cd tests && npm run test:all-ci", - "prepublishOnly": "npm run test-ci; npm pkg delete scripts devDependencies", + "mini:json": "npm pkg delete scripts devDependencies", + "prepublishOnly": "npm run lint && npm run test-ci && npm run mini:json", "lint": "npx eslint . --ext .js,.mjs" } } From d51154e8923cbe43c4d4e37984ae1273dae4afbb Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 13:58:14 -0700 Subject: [PATCH 04/21] use dedicated script for reducing package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index dab0dd34..77d507ca 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,8 @@ "scripts": { "test": "cd tests && npm run test:all", "test-ci": "cd tests && npm run test:all-ci", - "mini:json": "npm pkg delete scripts devDependencies", - "prepublishOnly": "npm run lint && npm run test-ci && npm run mini:json", + "mini:pkg": "npm pkg delete scripts devDependencies", + "prepublishOnly": "npm run lint && npm run test-ci && npm run mini:pkg", "lint": "npx eslint . --ext .js,.mjs" } } From da18c38e2e647d7b8dc2f35b6adde5d81e311950 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 13:58:37 -0700 Subject: [PATCH 05/21] change position of scripts --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 77d507ca..b43ac550 100644 --- a/package.json +++ b/package.json @@ -56,9 +56,9 @@ }, "scripts": { "test": "cd tests && npm run test:all", + "lint": "npx eslint . --ext .js,.mjs", "test-ci": "cd tests && npm run test:all-ci", "mini:pkg": "npm pkg delete scripts devDependencies", - "prepublishOnly": "npm run lint && npm run test-ci && npm run mini:pkg", - "lint": "npx eslint . --ext .js,.mjs" + "prepublishOnly": "npm run lint && npm run test-ci && npm run mini:pkg" } } From f0dedc41044103604037b5891b9a9b2619ae0a1f Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 14:00:08 -0700 Subject: [PATCH 06/21] fix lint related formatting --- tests/local/mainUtil.js | 2 +- tests/tests-ava/spec/esmock.ava.spec.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/local/mainUtil.js b/tests/local/mainUtil.js index dce8e5d0..7631fe6e 100644 --- a/tests/local/mainUtil.js +++ b/tests/local/mainUtil.js @@ -14,7 +14,7 @@ const createString = () => formurlencoded({ }); const callBabelGeneratedDoubleDefault = o => ( - babelGeneratedDoubleDefault.default(o) ); + babelGeneratedDoubleDefault.default(o)); const causeRuntimeError = () => mainUtil()(); diff --git a/tests/tests-ava/spec/esmock.ava.spec.js b/tests/tests-ava/spec/esmock.ava.spec.js index 776a2630..912a98d4 100644 --- a/tests/tests-ava/spec/esmock.ava.spec.js +++ b/tests/tests-ava/spec/esmock.ava.spec.js @@ -42,8 +42,8 @@ test('should throw error if local file not found', async t => { name : 'Error' }); - t.true( err.message.startsWith( - 'modulePath not found: "../../local/not/found.js"' ) ); + t.true(err.message.startsWith( + 'modulePath not found: "../../local/not/found.js"')); }); test('should throw error if local definition file not found', async t => { @@ -56,8 +56,8 @@ test('should throw error if local definition file not found', async t => { name : 'Error' }); - t.true( err.message.startsWith( - 'not a valid path: "../../local/not/found.js"' ) ); + t.true(err.message.startsWith( + 'not a valid path: "../../local/not/found.js"')); }); test('should mock a module', async t => { From db5db9db76d09357c12ad1c255f6c8071b4fb99b Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 14:31:31 -0700 Subject: [PATCH 07/21] run npm install before running tests --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b43ac550..6000a5e3 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "scripts": { "test": "cd tests && npm run test:all", "lint": "npx eslint . --ext .js,.mjs", - "test-ci": "cd tests && npm run test:all-ci", + "test-ci": "cd tests && npm install && npm run test:all-ci", "mini:pkg": "npm pkg delete scripts devDependencies", "prepublishOnly": "npm run lint && npm run test-ci && npm run mini:pkg" } From 6072f024fbe86756b3879cec0d01a908c4f10e09 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 14:33:21 -0700 Subject: [PATCH 08/21] run npm install:all before running tests --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6000a5e3..515f4a39 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "scripts": { "test": "cd tests && npm run test:all", "lint": "npx eslint . --ext .js,.mjs", - "test-ci": "cd tests && npm install && npm run test:all-ci", + "test-ci": "cd tests && npm install:all && npm run test:all-ci", "mini:pkg": "npm pkg delete scripts devDependencies", "prepublishOnly": "npm run lint && npm run test-ci && npm run mini:pkg" } From 9723a122ca662794052e574fb590c250f1556776 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 14:34:57 -0700 Subject: [PATCH 09/21] run npm run install:all before running tests --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 515f4a39..f82a4641 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "scripts": { "test": "cd tests && npm run test:all", "lint": "npx eslint . --ext .js,.mjs", - "test-ci": "cd tests && npm install:all && npm run test:all-ci", + "test-ci": "cd tests && npm run install:all && npm run test:all-ci", "mini:pkg": "npm pkg delete scripts devDependencies", "prepublishOnly": "npm run lint && npm run test-ci && npm run mini:pkg" } From 258b4268cee82e1905bf781978f7489354425484 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 14:37:36 -0700 Subject: [PATCH 10/21] run npm install before running tests --- package.json | 2 +- tests/package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f82a4641..6000a5e3 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "scripts": { "test": "cd tests && npm run test:all", "lint": "npx eslint . --ext .js,.mjs", - "test-ci": "cd tests && npm run install:all && npm run test:all-ci", + "test-ci": "cd tests && npm install && npm run test:all-ci", "mini:pkg": "npm pkg delete scripts devDependencies", "prepublishOnly": "npm run lint && npm run test-ci && npm run mini:pkg" } diff --git a/tests/package.json b/tests/package.json index 599979ae..fa6bbce1 100644 --- a/tests/package.json +++ b/tests/package.json @@ -27,6 +27,7 @@ "install:test-node": "cd tests-node && npm install", "install:test-nodets": "cd tests-nodets && npm install", "install:all": "npm-run-all install:test*", + "postinstall": "npm run install:all", "test:test-ava": "cd tests-ava && npm test", "test:test-uvu": "cd tests-uvu && npm test", From 12146b5f3baae151b1db8fd0430fa9cbea6d1969 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 14:42:03 -0700 Subject: [PATCH 11/21] use npx npm-run-all for tests install --- tests/package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/package.json b/tests/package.json index fa6bbce1..45217ea7 100644 --- a/tests/package.json +++ b/tests/package.json @@ -13,7 +13,6 @@ "form-urlencoded": "^6.0.7", "run-script-os": "^1.1.6", "check-node-version": "^4.2.1", - "npm-run-all": "^4.1.5", "babelGeneratedDoubleDefault": "file:./local/babelGeneratedDoubleDefault" }, "scripts": { @@ -26,8 +25,7 @@ "install:test-uvu": "cd tests-uvu && npm install", "install:test-node": "cd tests-node && npm install", "install:test-nodets": "cd tests-nodets && npm install", - "install:all": "npm-run-all install:test*", - "postinstall": "npm run install:all", + "postinstall": "npx npm-run-all install:test*", "test:test-ava": "cd tests-ava && npm test", "test:test-uvu": "cd tests-uvu && npm test", From 1668d7efb6bae2088091c7c56a43c80ac8b821ac Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 15:04:37 -0700 Subject: [PATCH 12/21] revert minified files --- package.json | 2 +- tests/package.json | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6000a5e3..f82a4641 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "scripts": { "test": "cd tests && npm run test:all", "lint": "npx eslint . --ext .js,.mjs", - "test-ci": "cd tests && npm install && npm run test:all-ci", + "test-ci": "cd tests && npm run install:all && npm run test:all-ci", "mini:pkg": "npm pkg delete scripts devDependencies", "prepublishOnly": "npm run lint && npm run test-ci && npm run mini:pkg" } diff --git a/tests/package.json b/tests/package.json index 45217ea7..c018af63 100644 --- a/tests/package.json +++ b/tests/package.json @@ -19,14 +19,12 @@ "mini:default": "cd .. && npx esbuild ./src/*js --minify --allow-overwrite --outdir=src", "mini:win32": "cd .. && cd src && forfiles /m \"*.js\" /c \"cmd /c npx esbuild @file --minify --allow-overwrite --outfile=@file\"", "mini": "run-script-os", - "install:esmock": "cd .. && npm install", "install:test-ava": "cd tests-ava && npm install", "install:test-uvu": "cd tests-uvu && npm install", "install:test-node": "cd tests-node && npm install", "install:test-nodets": "cd tests-nodets && npm install", - "postinstall": "npx npm-run-all install:test*", - + "install:all": "npm install && npm-run-all install:test*", "test:test-ava": "cd tests-ava && npm test", "test:test-uvu": "cd tests-uvu && npm test", "test:test-node": "check-node-version --node '>= 18.0.0' && cd tests-node && npm test", From a256213d9d36776bad5ef3b83cb094e340b176a5 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 15:07:28 -0700 Subject: [PATCH 13/21] restore npm-run-all dependencies --- tests/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/package.json b/tests/package.json index c018af63..2372faf7 100644 --- a/tests/package.json +++ b/tests/package.json @@ -13,6 +13,7 @@ "form-urlencoded": "^6.0.7", "run-script-os": "^1.1.6", "check-node-version": "^4.2.1", + "npm-run-all": "^4.1.5", "babelGeneratedDoubleDefault": "file:./local/babelGeneratedDoubleDefault" }, "scripts": { From 351bab4c050a0cfbce497fcadb2ae1e46903dd79 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 15:15:14 -0700 Subject: [PATCH 14/21] update node18 condition --- tests/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/package.json b/tests/package.json index 2372faf7..17e756e9 100644 --- a/tests/package.json +++ b/tests/package.json @@ -20,6 +20,7 @@ "mini:default": "cd .. && npx esbuild ./src/*js --minify --allow-overwrite --outdir=src", "mini:win32": "cd .. && cd src && forfiles /m \"*.js\" /c \"cmd /c npx esbuild @file --minify --allow-overwrite --outfile=@file\"", "mini": "run-script-os", + "isnode18": "check-node-version --node '>= 18.0.0'", "install:esmock": "cd .. && npm install", "install:test-ava": "cd tests-ava && npm install", "install:test-uvu": "cd tests-uvu && npm install", @@ -28,8 +29,8 @@ "install:all": "npm install && npm-run-all install:test*", "test:test-ava": "cd tests-ava && npm test", "test:test-uvu": "cd tests-uvu && npm test", - "test:test-node": "check-node-version --node '>= 18.0.0' && cd tests-node && npm test", - "test:test-nodets": "check-node-version --node '>= 18.0.0' && cd tests-nodets && npm test", + "test:test-node": "npm run isnode18 && cd tests-node && npm test || true", + "test:test-nodets": "npm run isnode18 && cd tests-nodets && npm test || true", "test:all": "npm-run-all test:test*", "test:all-ci": "npm run mini && npm run test:all" } From 83d0a4028e4fa272b3c68d6b017ea97a47d9c76b Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 15:22:38 -0700 Subject: [PATCH 15/21] update node18 condition --- tests/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/package.json b/tests/package.json index 17e756e9..32cc9cd0 100644 --- a/tests/package.json +++ b/tests/package.json @@ -20,7 +20,7 @@ "mini:default": "cd .. && npx esbuild ./src/*js --minify --allow-overwrite --outdir=src", "mini:win32": "cd .. && cd src && forfiles /m \"*.js\" /c \"cmd /c npx esbuild @file --minify --allow-overwrite --outfile=@file\"", "mini": "run-script-os", - "isnode18": "check-node-version --node '>= 18.0.0'", + "isnode18": "check-node-version --node 18", "install:esmock": "cd .. && npm install", "install:test-ava": "cd tests-ava && npm install", "install:test-uvu": "cd tests-uvu && npm install", From 81357386147cd117feaa53150b43230610803b47 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 15:29:42 -0700 Subject: [PATCH 16/21] remove un-needed Error() use Error --- src/esmock.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/esmock.js b/src/esmock.js index 2ee77735..68fe328d 100644 --- a/src/esmock.js +++ b/src/esmock.js @@ -9,7 +9,7 @@ import { } from './esmockCache.js'; const esmock = async (modulePath, mockDefs, globalDefs, opt = {}, err) => { - const calleePath = (err || new Error()).stack.split('\n')[2] + const calleePath = (err || new Error).stack.split('\n')[2] .replace(/^.*file:\/\//, '') // rm every before filepath .replace(/:[\d]*:[\d]*.*$/, '') // rm line and row number .replace(/^.*:/, '') // rm windows-style drive location @@ -30,10 +30,10 @@ const esmock = async (modulePath, mockDefs, globalDefs, opt = {}, err) => { }; esmock.px = async (modulePath, mockDefs, globalDefs) => ( - esmock(modulePath, mockDefs, globalDefs, { partial : true }, new Error())); + esmock(modulePath, mockDefs, globalDefs, { partial : true }, new Error)); esmock.p = async (modulePath, mockDefs, globalDefs) => ( - esmock(modulePath, mockDefs, globalDefs, { purge : false }, new Error())); + esmock(modulePath, mockDefs, globalDefs, { purge : false }, new Error)); esmock.purge = mockModule => { if (mockModule && /object|function/.test(typeof mockModule) From d1ca1f23212dc677f62740ad12b0bc998b71ad51 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 15:33:23 -0700 Subject: [PATCH 17/21] increase min version of node to 14 --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 3a5060d6..9ffbd476 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - node-version: [12.x, 16.x, 18.x] + node-version: [14.x, 16.x, 18.x] os: [ubuntu-latest, windows-latest] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ From db616e02cf516570ddb837cc20a6fc88e81d5610 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 15:37:00 -0700 Subject: [PATCH 18/21] resotre node 12, added timeout to ci file spec --- .github/workflows/node.js.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 9ffbd476..83cf097e 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -12,9 +12,10 @@ on: jobs: build: runs-on: ${{ matrix.os }} + timeout-minutes: 5 strategy: matrix: - node-version: [14.x, 16.x, 18.x] + node-version: [12.x, 16.x, 18.x] os: [ubuntu-latest, windows-latest] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ From 1aeb5ec3467a06fbd57b0c0e8819497ccfd89075 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 15:40:59 -0700 Subject: [PATCH 19/21] try updating npm at ci --- .github/workflows/node.js.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 83cf097e..6dc9610d 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -25,6 +25,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} + - sudo npm install -g npm@latest - run: npm install - run: npm run build --if-present - run: npm run test-ci From 443fd962fd1c12690ead3df1dc7f34cda407bbc4 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 15:43:14 -0700 Subject: [PATCH 20/21] try updating npm at ci --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 6dc9610d..78e68f8d 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -25,7 +25,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - - sudo npm install -g npm@latest + - run: sudo npm install -g npm@latest - run: npm install - run: npm run build --if-present - run: npm run test-ci From a554762810f0d0da65a217ce5df8b81697786e5f Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Jul 2022 15:45:48 -0700 Subject: [PATCH 21/21] remove sudo from npm install command --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 78e68f8d..61fc9dfa 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -25,7 +25,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - - run: sudo npm install -g npm@latest + - run: npm install -g npm@latest - run: npm install - run: npm run build --if-present - run: npm run test-ci