test: add subtests to test-node-run
Added two subtests to test-node-run. First one is about unparsable package.json file, and the second one is about there is no "script" fields in package.json PR-URL: https://github.com/nodejs/node/pull/54204 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
e1e7a417da
commit
359b4284bc
3
test/fixtures/run-script/cannot-find-script/package.json
vendored
Normal file
3
test/fixtures/run-script/cannot-find-script/package.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"types" : ""
|
||||
}
|
1
test/fixtures/run-script/cannot-parse/package.json
vendored
Normal file
1
test/fixtures/run-script/cannot-parse/package.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{ "non-parsable package.json"
|
@ -113,4 +113,26 @@ describe('node --run [command]', () => {
|
||||
assert.strictEqual(child.stderr, '');
|
||||
assert.strictEqual(child.code, 0);
|
||||
});
|
||||
|
||||
it('returns error on unparsable file', async () => {
|
||||
const child = await common.spawnPromisified(
|
||||
process.execPath,
|
||||
[ '--no-warnings', '--run', 'test'],
|
||||
{ cwd: fixtures.path('run-script/cannot-parse') },
|
||||
);
|
||||
assert.match(child.stderr, /Can't parse package\.json/);
|
||||
assert.strictEqual(child.stdout, '');
|
||||
assert.strictEqual(child.code, 1);
|
||||
});
|
||||
|
||||
it('returns error when there is no "scripts" field file', async () => {
|
||||
const child = await common.spawnPromisified(
|
||||
process.execPath,
|
||||
[ '--no-warnings', '--run', 'test'],
|
||||
{ cwd: fixtures.path('run-script/cannot-find-script') },
|
||||
);
|
||||
assert.match(child.stderr, /Can't find "scripts" field in package\.json/);
|
||||
assert.strictEqual(child.stdout, '');
|
||||
assert.strictEqual(child.code, 1);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user