Skip to content

Commit 0837107

Browse files
committed
test: fix subtest nodejs#1, nodejs#2 of test-node-run
Subtest nodejs#1, nodejs#2 of test-node-run.js originally matched the error message "Can't read package.json" on non-existent file. However, the subtests failed on Ubuntu20.04. we found that attempting to run a non-existent script like `node --run foo` using the latest version of node results in an error message like `Can't find “scripts” field in package.json` (on Ubuntu20.04, regardless of whether package.json is present in the subpath or not). So we modified the subtest so that if we match either of the two messages, the test passes.
1 parent 5210cd8 commit 0837107

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/parallel/test-node-run.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('node --run [command]', () => {
1515
{ cwd: __dirname },
1616
);
1717
assert.match(child.stderr, /ExperimentalWarning: Task runner is an experimental feature and might change at any time/);
18-
assert.match(child.stderr, /Can't read package\.json/);
18+
assert.match(child.stderr, /Can't read package\.json|Can't find "scripts" field in package\.json/);
1919
assert.strictEqual(child.stdout, '');
2020
assert.strictEqual(child.code, 1);
2121
});
@@ -26,7 +26,7 @@ describe('node --run [command]', () => {
2626
[ '--no-warnings', '--run', 'test'],
2727
{ cwd: __dirname },
2828
);
29-
assert.match(child.stderr, /Can't read package\.json/);
29+
assert.match(child.stderr, /Can't read package\.json|Can't find "scripts" field in package\.json/);
3030
assert.strictEqual(child.stdout, '');
3131
assert.strictEqual(child.code, 1);
3232
});

0 commit comments

Comments
 (0)