Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify test messages to template literals #15931

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
34 changes: 17 additions & 17 deletions test/parallel/test-cli-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const notFoundRE = /^Error: Cannot find module/m;
const cmd = [node, ..._args].join(' ');
exec(cmd, common.mustCall((err, stdout, stderr) => {
assert.ifError(err);
assert.strictEqual(stdout, '', 'stdout produced');
assert.strictEqual(stderr, '', 'stderr produced');
assert.strictEqual(stdout, '');
assert.strictEqual(stderr, '');
}));
});
});
Expand All @@ -54,16 +54,16 @@ const notFoundRE = /^Error: Cannot find module/m;
const cmd = [node, ..._args].join(' ');
exec(cmd, common.mustCall((err, stdout, stderr) => {
assert.strictEqual(err instanceof Error, true);
assert.strictEqual(err.code, 1, `code === ${err.code}`);
assert.strictEqual(err.code, 1);

// no stdout should be produced
assert.strictEqual(stdout, '', 'stdout produced');
assert.strictEqual(stdout, '');

// stderr should have a syntax error message
assert(syntaxErrorRE.test(stderr), 'stderr incorrect');
assert(syntaxErrorRE.test(stderr), `${syntaxErrorRE} === ${stderr}`);

// stderr should include the filename
assert(stderr.startsWith(file), "stderr doesn't start with the filename");
assert(stderr.startsWith(file), `${stderr} starts with ${file}`);
}));
});
});
Expand All @@ -81,12 +81,12 @@ const notFoundRE = /^Error: Cannot find module/m;
const cmd = [node, ..._args].join(' ');
exec(cmd, common.mustCall((err, stdout, stderr) => {
// no stdout should be produced
assert.strictEqual(stdout, '', 'stdout produced');
assert.strictEqual(stdout, '');

// stderr should have a module not found error message
assert(notFoundRE.test(stderr), 'stderr incorrect');
assert(notFoundRE.test(stderr), `${notFoundRE} === ${stderr}`);

assert.strictEqual(err.code, 1, `code === ${err.code}`);
assert.strictEqual(err.code, 1);
}));
});
});
Expand All @@ -98,10 +98,10 @@ syntaxArgs.forEach(function(args) {
const c = spawnSync(node, args, { encoding: 'utf8', input: stdin });

// no stdout or stderr should be produced
assert.strictEqual(c.stdout, '', 'stdout produced');
assert.strictEqual(c.stderr, '', 'stderr produced');
assert.strictEqual(c.stdout, '');
assert.strictEqual(c.stderr, '');

assert.strictEqual(c.status, 0, `code === ${c.status}`);
assert.strictEqual(c.status, 0);
});

// should throw if code piped from stdin with --check has bad syntax
Expand All @@ -111,15 +111,15 @@ syntaxArgs.forEach(function(args) {
const c = spawnSync(node, args, { encoding: 'utf8', input: stdin });

// stderr should include '[stdin]' as the filename
assert(c.stderr.startsWith('[stdin]'), "stderr doesn't start with [stdin]");
assert(c.stderr.startsWith('[stdin]'), `${c.stderr} starts with ${stdin}`);

// no stdout or stderr should be produced
assert.strictEqual(c.stdout, '', 'stdout produced');
assert.strictEqual(c.stdout, '');

// stderr should have a syntax error message
assert(syntaxErrorRE.test(c.stderr), 'stderr incorrect');
assert(syntaxErrorRE.test(c.stderr), `${syntaxErrorRE} === ${c.stderr}`);

assert.strictEqual(c.status, 1, `code === ${c.status}`);
assert.strictEqual(c.status, 1);
});

// should throw if -c and -e flags are both passed
Expand All @@ -129,7 +129,7 @@ syntaxArgs.forEach(function(args) {
const cmd = [node, ...args].join(' ');
exec(cmd, common.mustCall((err, stdout, stderr) => {
assert.strictEqual(err instanceof Error, true);
assert.strictEqual(err.code, 9, `code === ${err.code}`);
assert.strictEqual(err.code, 9);
assert(
stderr.startsWith(
`${node}: either --check or --eval can be used, not both`
Expand Down