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:
sungpaks authored and Michaël Zasso committed 2024-08-14 08:14:59 +02:00
1 parent a5a320cd5b
commit 6bcbfcd7bc
3 files changed
+26

No files matched your search

@@ -0,0 +1,3 @@
{
"types" : ""
}
+1
View File
@@ -0,0 +1 @@
{ "non-parsable package.json"
+22
View File
@@ -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);
});
});