test: refactor test_runner tests to change default reporter
This commit updates the test runner tests in order to switch the default reporter from tap to spec. This commit can be backported, while changing the default reporter cannot. Refs: https://github.com/nodejs/node/issues/54540 PR-URL: https://github.com/nodejs/node/pull/54547 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
This commit is contained in:
parent
3a71ccf6c4
commit
3d5357a2f4
@ -77,7 +77,11 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
|
|||||||
test({ skip: 'Skipping pseudo-tty tests, as pseudo terminals are not available on Windows.' });
|
test({ skip: 'Skipping pseudo-tty tests, as pseudo terminals are not available on Windows.' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const flags = common.parseTestFlags(filename);
|
let flags = common.parseTestFlags(filename);
|
||||||
|
if (options.flags) {
|
||||||
|
flags = [...options.flags, ...flags];
|
||||||
|
}
|
||||||
|
|
||||||
const executable = tty ? (process.env.PYTHON || 'python3') : process.execPath;
|
const executable = tty ? (process.env.PYTHON || 'python3') : process.execPath;
|
||||||
const args =
|
const args =
|
||||||
tty ?
|
tty ?
|
||||||
|
@ -26,7 +26,8 @@ for (const isolation of ['none', 'process']) {
|
|||||||
{
|
{
|
||||||
// Default behavior. node_modules is ignored. Files that don't match the
|
// Default behavior. node_modules is ignored. Files that don't match the
|
||||||
// pattern are ignored except in test/ directories.
|
// pattern are ignored except in test/ directories.
|
||||||
const args = ['--test', `--experimental-test-isolation=${isolation}`];
|
const args = ['--test', '--test-reporter=tap',
|
||||||
|
`--experimental-test-isolation=${isolation}`];
|
||||||
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') });
|
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') });
|
||||||
|
|
||||||
assert.strictEqual(child.status, 1);
|
assert.strictEqual(child.status, 1);
|
||||||
@ -47,6 +48,7 @@ for (const isolation of ['none', 'process']) {
|
|||||||
const args = [
|
const args = [
|
||||||
'--require', join(testFixtures, 'protoMutation.js'),
|
'--require', join(testFixtures, 'protoMutation.js'),
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=tap',
|
||||||
`--experimental-test-isolation=${isolation}`,
|
`--experimental-test-isolation=${isolation}`,
|
||||||
];
|
];
|
||||||
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') });
|
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') });
|
||||||
@ -67,6 +69,7 @@ for (const isolation of ['none', 'process']) {
|
|||||||
// User specified files that don't match the pattern are still run.
|
// User specified files that don't match the pattern are still run.
|
||||||
const args = [
|
const args = [
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=tap',
|
||||||
`--experimental-test-isolation=${isolation}`,
|
`--experimental-test-isolation=${isolation}`,
|
||||||
join(testFixtures, 'index.js'),
|
join(testFixtures, 'index.js'),
|
||||||
];
|
];
|
||||||
@ -83,6 +86,7 @@ for (const isolation of ['none', 'process']) {
|
|||||||
// Searches node_modules if specified.
|
// Searches node_modules if specified.
|
||||||
const args = [
|
const args = [
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=tap',
|
||||||
`--experimental-test-isolation=${isolation}`,
|
`--experimental-test-isolation=${isolation}`,
|
||||||
join(testFixtures, 'default-behavior/node_modules/*.js'),
|
join(testFixtures, 'default-behavior/node_modules/*.js'),
|
||||||
];
|
];
|
||||||
@ -105,18 +109,19 @@ for (const isolation of ['none', 'process']) {
|
|||||||
assert.strictEqual(child.signal, null);
|
assert.strictEqual(child.signal, null);
|
||||||
assert.strictEqual(child.stderr.toString(), '');
|
assert.strictEqual(child.stderr.toString(), '');
|
||||||
const stdout = child.stdout.toString();
|
const stdout = child.stdout.toString();
|
||||||
assert.match(stdout, /ok 1 - this should pass/);
|
assert.match(stdout, /this should pass/);
|
||||||
assert.match(stdout, /not ok 2 - this should fail/);
|
assert.match(stdout, /this should fail/);
|
||||||
assert.match(stdout, /ok 3 - subdir.+subdir_test\.js/);
|
assert.match(stdout, /subdir.+subdir_test\.js/);
|
||||||
assert.match(stdout, /ok 4 - this should pass/);
|
assert.match(stdout, /this should pass/);
|
||||||
assert.match(stdout, /ok 5 - this should be skipped/);
|
assert.match(stdout, /this should be skipped/);
|
||||||
assert.match(stdout, /ok 6 - this should be executed/);
|
assert.match(stdout, /this should be executed/);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Test combined stream outputs
|
// Test combined stream outputs
|
||||||
const args = [
|
const args = [
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=tap',
|
||||||
`--experimental-test-isolation=${isolation}`,
|
`--experimental-test-isolation=${isolation}`,
|
||||||
'test/fixtures/test-runner/default-behavior/index.test.js',
|
'test/fixtures/test-runner/default-behavior/index.test.js',
|
||||||
'test/fixtures/test-runner/nested.js',
|
'test/fixtures/test-runner/nested.js',
|
||||||
@ -189,6 +194,7 @@ for (const isolation of ['none', 'process']) {
|
|||||||
// Test user logging in tests.
|
// Test user logging in tests.
|
||||||
const args = [
|
const args = [
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=tap',
|
||||||
'test/fixtures/test-runner/user-logs.js',
|
'test/fixtures/test-runner/user-logs.js',
|
||||||
];
|
];
|
||||||
const child = spawnSync(process.execPath, args);
|
const child = spawnSync(process.execPath, args);
|
||||||
@ -223,7 +229,7 @@ for (const isolation of ['none', 'process']) {
|
|||||||
assert.strictEqual(child.status, 0);
|
assert.strictEqual(child.status, 0);
|
||||||
assert.strictEqual(child.signal, null);
|
assert.strictEqual(child.signal, null);
|
||||||
const stdout = child.stdout.toString();
|
const stdout = child.stdout.toString();
|
||||||
assert.match(stdout, /ok 1 - this should pass/);
|
assert.match(stdout, /this should pass/);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -290,6 +296,7 @@ for (const isolation of ['none', 'process']) {
|
|||||||
// --test-shard option, first shard
|
// --test-shard option, first shard
|
||||||
const args = [
|
const args = [
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=tap',
|
||||||
'--test-shard=1/2',
|
'--test-shard=1/2',
|
||||||
join(testFixtures, 'shards/*.cjs'),
|
join(testFixtures, 'shards/*.cjs'),
|
||||||
];
|
];
|
||||||
@ -324,6 +331,7 @@ for (const isolation of ['none', 'process']) {
|
|||||||
// --test-shard option, last shard
|
// --test-shard option, last shard
|
||||||
const args = [
|
const args = [
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=tap',
|
||||||
'--test-shard=2/2',
|
'--test-shard=2/2',
|
||||||
join(testFixtures, 'shards/*.cjs'),
|
join(testFixtures, 'shards/*.cjs'),
|
||||||
];
|
];
|
||||||
|
@ -12,7 +12,7 @@ async function runAndKill(file) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let stdout = '';
|
let stdout = '';
|
||||||
const child = spawn(process.execPath, ['--test', file]);
|
const child = spawn(process.execPath, ['--test', '--test-reporter=tap', file]);
|
||||||
child.stdout.setEncoding('utf8');
|
child.stdout.setEncoding('utf8');
|
||||||
child.stdout.on('data', (chunk) => {
|
child.stdout.on('data', (chunk) => {
|
||||||
if (!stdout.length) child.kill('SIGINT');
|
if (!stdout.length) child.kill('SIGINT');
|
||||||
@ -58,10 +58,10 @@ if (process.argv[2] === 'child') {
|
|||||||
assert.strictEqual(child.status, 0);
|
assert.strictEqual(child.status, 0);
|
||||||
assert.strictEqual(child.signal, null);
|
assert.strictEqual(child.signal, null);
|
||||||
const stdout = child.stdout.toString();
|
const stdout = child.stdout.toString();
|
||||||
assert.match(stdout, /# tests 3/);
|
assert.match(stdout, /tests 3/);
|
||||||
assert.match(stdout, /# pass 0/);
|
assert.match(stdout, /pass 0/);
|
||||||
assert.match(stdout, /# fail 0/);
|
assert.match(stdout, /fail 0/);
|
||||||
assert.match(stdout, /# todo 3/);
|
assert.match(stdout, /todo 3/);
|
||||||
|
|
||||||
child = spawnSync(process.execPath, [__filename, 'child', 'fail']);
|
child = spawnSync(process.execPath, [__filename, 'child', 'fail']);
|
||||||
assert.strictEqual(child.status, 1);
|
assert.strictEqual(child.status, 1);
|
||||||
|
@ -10,10 +10,10 @@ const { spawnSync } = require('child_process');
|
|||||||
fixtures.path('test-runner', 'extraneous_set_immediate_async.mjs'),
|
fixtures.path('test-runner', 'extraneous_set_immediate_async.mjs'),
|
||||||
]);
|
]);
|
||||||
const stdout = child.stdout.toString();
|
const stdout = child.stdout.toString();
|
||||||
assert.match(stdout, /^# Error: Test "extraneous async activity test" at .+extraneous_set_immediate_async\.mjs:3:1 generated asynchronous activity after the test ended/m);
|
assert.match(stdout, /Error: Test "extraneous async activity test" at .+extraneous_set_immediate_async\.mjs:3:1 generated asynchronous activity after the test ended/m);
|
||||||
assert.match(stdout, /^# pass 1/m);
|
assert.match(stdout, /pass 1/m);
|
||||||
assert.match(stdout, /^# fail 1$/m);
|
assert.match(stdout, /fail 1$/m);
|
||||||
assert.match(stdout, /^# cancelled 0$/m);
|
assert.match(stdout, /cancelled 0$/m);
|
||||||
assert.strictEqual(child.status, 1);
|
assert.strictEqual(child.status, 1);
|
||||||
assert.strictEqual(child.signal, null);
|
assert.strictEqual(child.signal, null);
|
||||||
}
|
}
|
||||||
@ -24,10 +24,10 @@ const { spawnSync } = require('child_process');
|
|||||||
fixtures.path('test-runner', 'extraneous_set_timeout_async.mjs'),
|
fixtures.path('test-runner', 'extraneous_set_timeout_async.mjs'),
|
||||||
]);
|
]);
|
||||||
const stdout = child.stdout.toString();
|
const stdout = child.stdout.toString();
|
||||||
assert.match(stdout, /^# Error: Test "extraneous async activity test" at .+extraneous_set_timeout_async\.mjs:3:1 generated asynchronous activity after the test ended/m);
|
assert.match(stdout, /Error: Test "extraneous async activity test" at .+extraneous_set_timeout_async\.mjs:3:1 generated asynchronous activity after the test ended/m);
|
||||||
assert.match(stdout, /^# pass 1$/m);
|
assert.match(stdout, /pass 1$/m);
|
||||||
assert.match(stdout, /^# fail 1$/m);
|
assert.match(stdout, /fail 1$/m);
|
||||||
assert.match(stdout, /^# cancelled 0$/m);
|
assert.match(stdout, /cancelled 0$/m);
|
||||||
assert.strictEqual(child.status, 1);
|
assert.strictEqual(child.status, 1);
|
||||||
assert.strictEqual(child.signal, null);
|
assert.strictEqual(child.signal, null);
|
||||||
}
|
}
|
||||||
@ -38,13 +38,13 @@ const { spawnSync } = require('child_process');
|
|||||||
fixtures.path('test-runner', 'async-error-in-test-hook.mjs'),
|
fixtures.path('test-runner', 'async-error-in-test-hook.mjs'),
|
||||||
]);
|
]);
|
||||||
const stdout = child.stdout.toString();
|
const stdout = child.stdout.toString();
|
||||||
assert.match(stdout, /^# Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m);
|
assert.match(stdout, /Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m);
|
||||||
assert.match(stdout, /^# Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m);
|
assert.match(stdout, /Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m);
|
||||||
assert.match(stdout, /^# Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m);
|
assert.match(stdout, /Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m);
|
||||||
assert.match(stdout, /^# Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m);
|
assert.match(stdout, /Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m);
|
||||||
assert.match(stdout, /^# pass 1$/m);
|
assert.match(stdout, /pass 1$/m);
|
||||||
assert.match(stdout, /^# fail 1$/m);
|
assert.match(stdout, /fail 1$/m);
|
||||||
assert.match(stdout, /^# cancelled 0$/m);
|
assert.match(stdout, /cancelled 0$/m);
|
||||||
assert.strictEqual(child.status, 1);
|
assert.strictEqual(child.status, 1);
|
||||||
assert.strictEqual(child.signal, null);
|
assert.strictEqual(child.signal, null);
|
||||||
}
|
}
|
||||||
@ -56,13 +56,13 @@ const { spawnSync } = require('child_process');
|
|||||||
fixtures.path('test-runner', 'async-error-in-test-hook.mjs'),
|
fixtures.path('test-runner', 'async-error-in-test-hook.mjs'),
|
||||||
]);
|
]);
|
||||||
const stdout = child.stdout.toString();
|
const stdout = child.stdout.toString();
|
||||||
assert.match(stdout, /^# Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m);
|
assert.match(stdout, /Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m);
|
||||||
assert.match(stdout, /^# Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m);
|
assert.match(stdout, /Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m);
|
||||||
assert.match(stdout, /^# Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m);
|
assert.match(stdout, /Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m);
|
||||||
assert.match(stdout, /^# Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m);
|
assert.match(stdout, /Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m);
|
||||||
assert.match(stdout, /^# pass 1$/m);
|
assert.match(stdout, /pass 1$/m);
|
||||||
assert.match(stdout, /^# fail 0$/m);
|
assert.match(stdout, /fail 0$/m);
|
||||||
assert.match(stdout, /^# cancelled 0$/m);
|
assert.match(stdout, /cancelled 0$/m);
|
||||||
assert.strictEqual(child.status, 1);
|
assert.strictEqual(child.status, 1);
|
||||||
assert.strictEqual(child.signal, null);
|
assert.strictEqual(child.signal, null);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ const fixture = fixtures.path('test-runner/throws_sync_and_async.js');
|
|||||||
for (const isolation of ['none', 'process']) {
|
for (const isolation of ['none', 'process']) {
|
||||||
const args = [
|
const args = [
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=spec',
|
||||||
'--test-force-exit',
|
'--test-force-exit',
|
||||||
`--experimental-test-isolation=${isolation}`,
|
`--experimental-test-isolation=${isolation}`,
|
||||||
fixture,
|
fixture,
|
||||||
@ -19,6 +20,6 @@ for (const isolation of ['none', 'process']) {
|
|||||||
strictEqual(r.stderr.toString(), '');
|
strictEqual(r.stderr.toString(), '');
|
||||||
|
|
||||||
const stdout = r.stdout.toString();
|
const stdout = r.stdout.toString();
|
||||||
match(stdout, /error: 'fails'/);
|
match(stdout, /Error: fails/);
|
||||||
doesNotMatch(stdout, /this should not have a chance to be thrown/);
|
doesNotMatch(stdout, /this should not have a chance to be thrown/);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ tmpdir.refresh();
|
|||||||
|
|
||||||
{
|
{
|
||||||
const child = new NodeInstance(
|
const child = new NodeInstance(
|
||||||
['--test', '--inspect-brk=0'],
|
['--test', '--test-reporter=tap', '--inspect-brk=0'],
|
||||||
undefined,
|
undefined,
|
||||||
fixtures.path('test-runner/default-behavior/index.test.js')
|
fixtures.path('test-runner/default-behavior/index.test.js')
|
||||||
);
|
);
|
||||||
@ -38,7 +38,10 @@ tmpdir.refresh();
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const args = ['--test', '--inspect=0', fixtures.path('test-runner/index.js')];
|
const args = [
|
||||||
|
'--test', '--test-reporter=tap', '--inspect=0',
|
||||||
|
fixtures.path('test-runner/index.js'),
|
||||||
|
];
|
||||||
const { stderr, stdout, code, signal } = await common.spawnPromisified(process.execPath, args);
|
const { stderr, stdout, code, signal } = await common.spawnPromisified(process.execPath, args);
|
||||||
|
|
||||||
assert.match(stderr,
|
assert.match(stderr,
|
||||||
|
@ -33,9 +33,9 @@ if (process.argv[2] === 'child') {
|
|||||||
} else {
|
} else {
|
||||||
const child = spawnSync(process.execPath, [__filename, 'child', 'abortSignal']);
|
const child = spawnSync(process.execPath, [__filename, 'child', 'abortSignal']);
|
||||||
const stdout = child.stdout.toString();
|
const stdout = child.stdout.toString();
|
||||||
assert.match(stdout, /^# pass 2$/m);
|
assert.match(stdout, /pass 2$/m);
|
||||||
assert.match(stdout, /^# fail 0$/m);
|
assert.match(stdout, /fail 0$/m);
|
||||||
assert.match(stdout, /^# cancelled 1$/m);
|
assert.match(stdout, /cancelled 1$/m);
|
||||||
assert.strictEqual(child.status, 1);
|
assert.strictEqual(child.status, 1);
|
||||||
assert.strictEqual(child.signal, null);
|
assert.strictEqual(child.signal, null);
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ test('node_modules can be used by both module systems', async (t) => {
|
|||||||
|
|
||||||
assert.strictEqual(code, 0);
|
assert.strictEqual(code, 0);
|
||||||
assert.strictEqual(signal, null);
|
assert.strictEqual(signal, null);
|
||||||
assert.match(stdout, /# pass 1/);
|
assert.match(stdout, /pass 1/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('file:// imports are supported in ESM only', async (t) => {
|
test('file:// imports are supported in ESM only', async (t) => {
|
||||||
|
@ -11,6 +11,7 @@ const fixture2 = fixtures.path('test-runner', 'no-isolation', 'two.test.js');
|
|||||||
test('works with --test-only', () => {
|
test('works with --test-only', () => {
|
||||||
const args = [
|
const args = [
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=tap',
|
||||||
'--experimental-test-isolation=none',
|
'--experimental-test-isolation=none',
|
||||||
'--test-only',
|
'--test-only',
|
||||||
fixture1,
|
fixture1,
|
||||||
@ -33,6 +34,7 @@ test('works with --test-only', () => {
|
|||||||
test('works with --test-name-pattern', () => {
|
test('works with --test-name-pattern', () => {
|
||||||
const args = [
|
const args = [
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=tap',
|
||||||
'--experimental-test-isolation=none',
|
'--experimental-test-isolation=none',
|
||||||
'--test-name-pattern=/test one/',
|
'--test-name-pattern=/test one/',
|
||||||
fixture1,
|
fixture1,
|
||||||
@ -52,6 +54,7 @@ test('works with --test-name-pattern', () => {
|
|||||||
test('works with --test-skip-pattern', () => {
|
test('works with --test-skip-pattern', () => {
|
||||||
const args = [
|
const args = [
|
||||||
'--test',
|
'--test',
|
||||||
|
'--test-reporter=tap',
|
||||||
'--experimental-test-isolation=none',
|
'--experimental-test-isolation=none',
|
||||||
'--test-skip-pattern=/one/',
|
'--test-skip-pattern=/one/',
|
||||||
fixture1,
|
fixture1,
|
||||||
|
@ -92,50 +92,116 @@ const lcovTransform = snapshot.transform(
|
|||||||
|
|
||||||
|
|
||||||
const tests = [
|
const tests = [
|
||||||
{ name: 'test-runner/output/abort.js' },
|
{ name: 'test-runner/output/abort.js', flags: ['--test-reporter=tap'] },
|
||||||
{ name: 'test-runner/output/abort-runs-after-hook.js' },
|
{
|
||||||
{ name: 'test-runner/output/abort_suite.js' },
|
name: 'test-runner/output/abort-runs-after-hook.js',
|
||||||
{ name: 'test-runner/output/abort_hooks.js' },
|
flags: ['--test-reporter=tap'],
|
||||||
{ name: 'test-runner/output/describe_it.js' },
|
},
|
||||||
{ name: 'test-runner/output/describe_nested.js' },
|
{ name: 'test-runner/output/abort_suite.js', flags: ['--test-reporter=tap'] },
|
||||||
|
{ name: 'test-runner/output/abort_hooks.js', flags: ['--test-reporter=tap'] },
|
||||||
|
{ name: 'test-runner/output/describe_it.js', flags: ['--test-reporter=tap'] },
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/describe_nested.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
{ name: 'test-runner/output/eval_dot.js', transform: specTransform },
|
{ name: 'test-runner/output/eval_dot.js', transform: specTransform },
|
||||||
{ name: 'test-runner/output/eval_spec.js', transform: specTransform },
|
{ name: 'test-runner/output/eval_spec.js', transform: specTransform },
|
||||||
{ name: 'test-runner/output/eval_tap.js' },
|
{ name: 'test-runner/output/eval_tap.js' },
|
||||||
{ name: 'test-runner/output/filtered-suite-delayed-build.js' },
|
{
|
||||||
{ name: 'test-runner/output/filtered-suite-order.mjs' },
|
name: 'test-runner/output/filtered-suite-delayed-build.js',
|
||||||
{ name: 'test-runner/output/filtered-suite-throws.js' },
|
flags: ['--test-reporter=tap'],
|
||||||
{ name: 'test-runner/output/hooks.js' },
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/filtered-suite-order.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/filtered-suite-throws.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{ name: 'test-runner/output/hooks.js', flags: ['--test-reporter=tap'] },
|
||||||
{ name: 'test-runner/output/hooks_spec_reporter.js', transform: specTransform },
|
{ name: 'test-runner/output/hooks_spec_reporter.js', transform: specTransform },
|
||||||
{ name: 'test-runner/output/skip-each-hooks.js', transform: specTransform },
|
{ name: 'test-runner/output/skip-each-hooks.js', transform: specTransform },
|
||||||
{ name: 'test-runner/output/suite-skip-hooks.js', transform: specTransform },
|
{ name: 'test-runner/output/suite-skip-hooks.js', transform: specTransform },
|
||||||
{ name: 'test-runner/output/timeout_in_before_each_should_not_affect_further_tests.js' },
|
{
|
||||||
{ name: 'test-runner/output/hooks-with-no-global-test.js' },
|
name: 'test-runner/output/timeout_in_before_each_should_not_affect_further_tests.js',
|
||||||
{ name: 'test-runner/output/global-hooks-with-no-tests.js' },
|
flags: ['--test-reporter=tap'],
|
||||||
{ name: 'test-runner/output/before-and-after-each-too-many-listeners.js' },
|
},
|
||||||
{ name: 'test-runner/output/before-and-after-each-with-timeout-too-many-listeners.js' },
|
{
|
||||||
|
name: 'test-runner/output/hooks-with-no-global-test.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/global-hooks-with-no-tests.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/before-and-after-each-too-many-listeners.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/before-and-after-each-with-timeout-too-many-listeners.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
{ name: 'test-runner/output/force_exit.js', transform: specTransform },
|
{ name: 'test-runner/output/force_exit.js', transform: specTransform },
|
||||||
{ name: 'test-runner/output/global_after_should_fail_the_test.js' },
|
{
|
||||||
{ name: 'test-runner/output/no_refs.js' },
|
name: 'test-runner/output/global_after_should_fail_the_test.js',
|
||||||
{ name: 'test-runner/output/no_tests.js' },
|
flags: ['--test-reporter=tap'],
|
||||||
{ name: 'test-runner/output/only_tests.js' },
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/no_refs.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/no_tests.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{ name: 'test-runner/output/only_tests.js', flags: ['--test-reporter=tap'] },
|
||||||
{ name: 'test-runner/output/dot_reporter.js', transform: specTransform },
|
{ name: 'test-runner/output/dot_reporter.js', transform: specTransform },
|
||||||
{ name: 'test-runner/output/junit_reporter.js', transform: junitTransform },
|
{ name: 'test-runner/output/junit_reporter.js', transform: junitTransform },
|
||||||
{ name: 'test-runner/output/spec_reporter_successful.js', transform: specTransform },
|
{ name: 'test-runner/output/spec_reporter_successful.js', transform: specTransform },
|
||||||
{ name: 'test-runner/output/spec_reporter.js', transform: specTransform },
|
{ name: 'test-runner/output/spec_reporter.js', transform: specTransform },
|
||||||
{ name: 'test-runner/output/spec_reporter_cli.js', transform: specTransform },
|
{ name: 'test-runner/output/spec_reporter_cli.js', transform: specTransform },
|
||||||
{ name: 'test-runner/output/source_mapped_locations.mjs' },
|
{
|
||||||
|
name: 'test-runner/output/source_mapped_locations.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
process.features.inspector ? { name: 'test-runner/output/lcov_reporter.js', transform: lcovTransform } : false,
|
process.features.inspector ? { name: 'test-runner/output/lcov_reporter.js', transform: lcovTransform } : false,
|
||||||
{ name: 'test-runner/output/output.js' },
|
{ name: 'test-runner/output/output.js', flags: ['--test-reporter=tap'] },
|
||||||
{ name: 'test-runner/output/output_cli.js' },
|
{ name: 'test-runner/output/output_cli.js' },
|
||||||
{ name: 'test-runner/output/name_and_skip_patterns.js' },
|
{
|
||||||
{ name: 'test-runner/output/name_pattern.js' },
|
name: 'test-runner/output/name_and_skip_patterns.js',
|
||||||
{ name: 'test-runner/output/name_pattern_with_only.js' },
|
flags: ['--test-reporter=tap'],
|
||||||
{ name: 'test-runner/output/skip_pattern.js' },
|
},
|
||||||
{ name: 'test-runner/output/unfinished-suite-async-error.js' },
|
{
|
||||||
{ name: 'test-runner/output/unresolved_promise.js' },
|
name: 'test-runner/output/name_pattern.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/name_pattern_with_only.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/skip_pattern.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/unfinished-suite-async-error.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/unresolved_promise.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
{ name: 'test-runner/output/default_output.js', transform: specTransform, tty: true },
|
{ name: 'test-runner/output/default_output.js', transform: specTransform, tty: true },
|
||||||
{ name: 'test-runner/output/arbitrary-output.js' },
|
{
|
||||||
{ name: 'test-runner/output/async-test-scheduling.mjs' },
|
name: 'test-runner/output/arbitrary-output.js',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test-runner/output/async-test-scheduling.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
!skipForceColors ? {
|
!skipForceColors ? {
|
||||||
name: 'test-runner/output/arbitrary-output-colored.js',
|
name: 'test-runner/output/arbitrary-output-colored.js',
|
||||||
transform: snapshot.transform(specTransform, replaceTestDuration), tty: true
|
transform: snapshot.transform(specTransform, replaceTestDuration), tty: true
|
||||||
@ -147,24 +213,58 @@ const tests = [
|
|||||||
snapshot.replaceWindowsLineEndings,
|
snapshot.replaceWindowsLineEndings,
|
||||||
replaceTestDuration,
|
replaceTestDuration,
|
||||||
),
|
),
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
},
|
},
|
||||||
{ name: 'test-runner/output/test-runner-plan.js' },
|
{
|
||||||
process.features.inspector ? { name: 'test-runner/output/coverage_failure.js' } : false,
|
name: 'test-runner/output/test-runner-plan.js',
|
||||||
{ name: 'test-runner/output/test-diagnostic-warning-without-test-only-flag.js' },
|
flags: ['--test-reporter=tap'],
|
||||||
process.features.inspector ? { name: 'test-runner/output/coverage-width-80.mjs' } : false,
|
},
|
||||||
process.features.inspector ? { name: 'test-runner/output/coverage-width-100.mjs' } : false,
|
process.features.inspector ? {
|
||||||
process.features.inspector ? { name: 'test-runner/output/coverage-width-150.mjs' } : false,
|
name: 'test-runner/output/coverage_failure.js',
|
||||||
process.features.inspector ? { name: 'test-runner/output/coverage-width-infinity.mjs' } : false,
|
flags: ['--test-reporter=tap'],
|
||||||
process.features.inspector ? { name: 'test-runner/output/coverage-width-80-uncovered-lines.mjs' } : false,
|
} : false,
|
||||||
process.features.inspector ? { name: 'test-runner/output/coverage-width-100-uncovered-lines.mjs' } : false,
|
{
|
||||||
process.features.inspector ? { name: 'test-runner/output/coverage-width-150-uncovered-lines.mjs' } : false,
|
name: 'test-runner/output/test-diagnostic-warning-without-test-only-flag.js',
|
||||||
process.features.inspector ? { name: 'test-runner/output/coverage-width-infinity-uncovered-lines.mjs' } : false,
|
flags: ['--test-reporter=tap'],
|
||||||
|
},
|
||||||
|
process.features.inspector ? {
|
||||||
|
name: 'test-runner/output/coverage-width-80.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
} : false,
|
||||||
|
process.features.inspector ? {
|
||||||
|
name: 'test-runner/output/coverage-width-100.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
} : false,
|
||||||
|
process.features.inspector ? {
|
||||||
|
name: 'test-runner/output/coverage-width-150.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
} : false,
|
||||||
|
process.features.inspector ? {
|
||||||
|
name: 'test-runner/output/coverage-width-infinity.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
} : false,
|
||||||
|
process.features.inspector ? {
|
||||||
|
name: 'test-runner/output/coverage-width-80-uncovered-lines.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
} : false,
|
||||||
|
process.features.inspector ? {
|
||||||
|
name: 'test-runner/output/coverage-width-100-uncovered-lines.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
} : false,
|
||||||
|
process.features.inspector ? {
|
||||||
|
name: 'test-runner/output/coverage-width-150-uncovered-lines.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
} : false,
|
||||||
|
process.features.inspector ? {
|
||||||
|
name: 'test-runner/output/coverage-width-infinity-uncovered-lines.mjs',
|
||||||
|
flags: ['--test-reporter=tap'],
|
||||||
|
} : false,
|
||||||
]
|
]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.map(({ name, tty, transform }) => ({
|
.map(({ flags, name, tty, transform }) => ({
|
||||||
name,
|
name,
|
||||||
fn: common.mustCall(async () => {
|
fn: common.mustCall(async () => {
|
||||||
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty });
|
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags });
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ test('root duration is longer than test duration', async () => {
|
|||||||
stderr,
|
stderr,
|
||||||
stdout,
|
stdout,
|
||||||
} = await spawnPromisified(process.execPath, [
|
} = await spawnPromisified(process.execPath, [
|
||||||
|
'--test-reporter=tap',
|
||||||
fixtures.path('test-runner/root-duration.mjs'),
|
fixtures.path('test-runner/root-duration.mjs'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -305,9 +305,9 @@ test('t.assert.snapshot()', async (t) => {
|
|||||||
|
|
||||||
t.assert.strictEqual(child.code, 1);
|
t.assert.strictEqual(child.code, 1);
|
||||||
t.assert.strictEqual(child.signal, null);
|
t.assert.strictEqual(child.signal, null);
|
||||||
t.assert.match(child.stdout, /# tests 5/);
|
t.assert.match(child.stdout, /tests 5/);
|
||||||
t.assert.match(child.stdout, /# pass 0/);
|
t.assert.match(child.stdout, /pass 0/);
|
||||||
t.assert.match(child.stdout, /# fail 5/);
|
t.assert.match(child.stdout, /fail 5/);
|
||||||
t.assert.match(child.stdout, /Missing snapshots/);
|
t.assert.match(child.stdout, /Missing snapshots/);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -362,9 +362,9 @@ test('snapshots from multiple files (isolation=none)', async (t) => {
|
|||||||
|
|
||||||
t.assert.strictEqual(child.code, 1);
|
t.assert.strictEqual(child.code, 1);
|
||||||
t.assert.strictEqual(child.signal, null);
|
t.assert.strictEqual(child.signal, null);
|
||||||
t.assert.match(child.stdout, /# tests 6/);
|
t.assert.match(child.stdout, /tests 6/);
|
||||||
t.assert.match(child.stdout, /# pass 0/);
|
t.assert.match(child.stdout, /pass 0/);
|
||||||
t.assert.match(child.stdout, /# fail 6/);
|
t.assert.match(child.stdout, /fail 6/);
|
||||||
t.assert.match(child.stdout, /Missing snapshots/);
|
t.assert.match(child.stdout, /Missing snapshots/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ describe('test runner watch mode with more complex setup', () => {
|
|||||||
child.stdout.on('data', (data) => {
|
child.stdout.on('data', (data) => {
|
||||||
stdout += data.toString();
|
stdout += data.toString();
|
||||||
currentRun += data.toString();
|
currentRun += data.toString();
|
||||||
const testRuns = stdout.match(/# duration_ms\s\d+/g);
|
const testRuns = stdout.match(/duration_ms\s\d+/g);
|
||||||
|
|
||||||
if (testRuns?.length >= 2) {
|
if (testRuns?.length >= 2) {
|
||||||
ran2.resolve();
|
ran2.resolve();
|
||||||
@ -91,14 +91,14 @@ describe('test runner watch mode with more complex setup', () => {
|
|||||||
|
|
||||||
const [firstRun, secondRun] = runs;
|
const [firstRun, secondRun] = runs;
|
||||||
|
|
||||||
assert.match(firstRun, /# tests 3/);
|
assert.match(firstRun, /tests 3/);
|
||||||
assert.match(firstRun, /# pass 3/);
|
assert.match(firstRun, /pass 3/);
|
||||||
assert.match(firstRun, /# fail 0/);
|
assert.match(firstRun, /fail 0/);
|
||||||
assert.match(firstRun, /# cancelled 0/);
|
assert.match(firstRun, /cancelled 0/);
|
||||||
|
|
||||||
assert.match(secondRun, /# tests 2/);
|
assert.match(secondRun, /tests 2/);
|
||||||
assert.match(secondRun, /# pass 2/);
|
assert.match(secondRun, /pass 2/);
|
||||||
assert.match(secondRun, /# fail 0/);
|
assert.match(secondRun, /fail 0/);
|
||||||
assert.match(secondRun, /# cancelled 0/);
|
assert.match(secondRun, /cancelled 0/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user