Skip to content

Commit 6bcbfcd

Browse files
sungpakstargos
authored andcommitted
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: #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>
1 parent a5a320c commit 6bcbfcd

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"types" : ""
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "non-parsable package.json"

‎test/parallel/test-node-run.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,26 @@ describe('node --run [command]', () => {
113113
assert.strictEqual(child.stderr,'');
114114
assert.strictEqual(child.code,0);
115115
});
116+
117+
it('returns error on unparsable file',async()=>{
118+
constchild=awaitcommon.spawnPromisified(
119+
process.execPath,
120+
['--no-warnings','--run','test'],
121+
{cwd: fixtures.path('run-script/cannot-parse')},
122+
);
123+
assert.match(child.stderr,/Can'tparsepackage\.json/);
124+
assert.strictEqual(child.stdout,'');
125+
assert.strictEqual(child.code,1);
126+
});
127+
128+
it('returns error when there is no "scripts" field file',async()=>{
129+
constchild=awaitcommon.spawnPromisified(
130+
process.execPath,
131+
['--no-warnings','--run','test'],
132+
{cwd: fixtures.path('run-script/cannot-find-script')},
133+
);
134+
assert.match(child.stderr,/Can'tfind"scripts"fieldinpackage\.json/);
135+
assert.strictEqual(child.stdout,'');
136+
assert.strictEqual(child.code,1);
137+
});
116138
});

0 commit comments

Comments
 (0)