Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 3 additions & 0 deletions test/fixtures/run-script/cannot-find-script/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"types" : ""
}
Comment thread
sungpaks marked this conversation as resolved.
Outdated
1 change: 1 addition & 0 deletions test/fixtures/run-script/cannot-parse/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "non-parsable package.json"
Comment thread
sungpaks marked this conversation as resolved.
Outdated
22 changes: 22 additions & 0 deletions test/parallel/test-node-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});