Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix npm scripts on windows #5219

Merged
merged 8 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"karma-mocha-reporter",
"karma-mocha",
"karma-sauce-launcher",
"non-existent-package"
"non-existent-package",
"prettier"
],
"mocha": {
"entry": ["test/**/*.{js,ts,mjs,cjs}"]
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
"docs:api": "jsdoc -c jsdoc.conf.json",
"docs:site": "eleventy",
"docs": "run-s docs-clean docs:*",
"format:eslint": "eslint --fix . 'bin/*'",
"format:prettier": "prettier --write '!(package*).json' '.*.json' 'lib/**/*.json' '*.yml'",
"format:eslint": "eslint --fix . \"bin/*\"",
"format:prettier": "prettier --write \"!(package*).json\" \".*.json\" \"lib/**/*.json\" \"*.yml\"",
"format": "run-s format:*",
"lint:knip": "knip --cache",
"lint:code": "eslint . 'bin/*' --max-warnings 0",
"lint:markdown": "markdownlint '*.md' 'docs/**/*.md' '.github/*.md' 'lib/**/*.md' 'test/**/*.md' 'example/**/*.md' -i CHANGELOG.md",
"lint:code": "eslint . \"bin/*\" --max-warnings 0",
"lint:markdown": "markdownlint \"*.md\" \"docs/**/*.md\" \".github/*.md\" \"lib/**/*.md\" \"test/**/*.md\" \"example/**/*.md\" -i CHANGELOG.md",
"lint": "run-p lint:*",
"prepublishOnly": "run-s clean build",
"test-browser-run": "cross-env NODE_PATH=. karma start ./karma.conf.js --single-run",
Expand All @@ -70,7 +70,7 @@
"test-coverage-generate": "nyc report --reporter=lcov --reporter=text",
"test-node-run-only": "nyc --no-clean --reporter=json node bin/mocha.js",
"test-node-run": "nyc --no-clean --reporter=json node bin/mocha.js --forbid-only",
"test-node:integration": "run-s clean build && npm run -s test-node-run -- --parallel --timeout 10000 --slow 3750 'test/integration/**/*.spec.js'",
"test-node:integration": "run-s clean build && npm run -s test-node-run -- --parallel --timeout 10000 --slow 3750 \"test/integration/**/*.spec.js\"",
"test-node:interfaces:bdd": "npm run -s test-node-run -- --ui bdd test/interfaces/bdd.spec",
"test-node:interfaces:exports": "npm run -s test-node-run -- --ui exports test/interfaces/exports.spec",
"test-node:interfaces:qunit": "npm run -s test-node-run -- --ui qunit test/interfaces/qunit.spec",
Expand All @@ -82,9 +82,9 @@
"test-node:only:globalQunit": "npm run -s test-node-run-only -- --ui qunit test/only/global/qunit.spec --no-parallel",
"test-node:only:globalTdd": "npm run -s test-node-run-only -- --ui tdd test/only/global/tdd.spec --no-parallel",
"test-node:only": "run-p test-node:only:*",
"test-node:reporters": "npm run -s test-node-run -- 'test/reporters/*.spec.js'",
"test-node:reporters": "npm run -s test-node-run -- \"test/reporters/*.spec.js\"",
"test-node:requires": "npm run -s test-node-run -- --require coffeescript/register --require test/require/a.js --require test/require/b.coffee --require test/require/c.js --require test/require/d.coffee test/require/require.spec.js",
"test-node:unit": "npm run -s test-node-run -- 'test/unit/*.spec.js' 'test/node-unit/**/*.spec.js'",
"test-node:unit": "npm run -s test-node-run -- \"test/unit/*.spec.js\" \"test/node-unit/**/*.spec.js\"",
"test-node": "run-s test-coverage-clean test-node:* test-coverage-generate",
"test-smoke": "node ./bin/mocha --no-config test/smoke/smoke.spec.js",
"test": "run-s lint test-node test-browser",
Expand Down
56 changes: 40 additions & 16 deletions test/integration/plugins/root-hooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,46 @@ describe('root hooks', function () {
});

describe('support ESM via .js extension w/o type=module', function () {
it('should fail due to ambiguous file type', function () {
return expect(
invokeMochaAsync(
[
'--require=' +
require.resolve(
// as object
'../fixtures/plugins/root-hooks/root-hook-defs-esm-broken.fixture.js'
)
],
'pipe'
)[1],
'when fulfilled',
'to contain output',
/SyntaxError: Unexpected token/
);
describe('should fail due to ambiguous file type', function () {
const filename =
'../fixtures/plugins/root-hooks/root-hook-defs-esm-broken.fixture.js';
const noDetectModuleRegex = /SyntaxError: Unexpected token/;
const detectModuleRegex = /Cannot require\(\) ES Module/;

it('with --no-experimental-detect-module', function () {
return expect(
invokeMochaAsync(
[
'--require=' + require.resolve(filename), // as object
'--no-experimental-detect-module'
],
'pipe'
)[1],
'when fulfilled',
'to contain output',
noDetectModuleRegex
);
});

it('with --experimental-detect-module', function () {
// --experimental-detect-module was introduced in Node 21.1.0
const expectedRegex =
process.version >= 'v21.1.0'
? detectModuleRegex
: noDetectModuleRegex;
return expect(
invokeMochaAsync(
[
'--require=' + require.resolve(filename), // as object
'--experimental-detect-module'
],
'pipe'
)[1],
'when fulfilled',
'to contain output',
expectedRegex
);
});
});
});
});
Expand Down
Loading