Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,14 @@
'use strict';
const { test } = require('node:test');
test('test that aborts', (t, done) => {
t.after(() => {
// This should still run.
console.log('AFTER');
});
setImmediate(() => {
// This creates an uncaughtException, which aborts the test.
throw new Error('boom');
});
});

View File

@ -0,0 +1,24 @@
TAP version 13
AFTER
# Subtest: test that aborts
not ok 1 - test that aborts
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort-runs-after-hook.js:(LINE):1'
failureType: 'uncaughtException'
error: 'boom'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
...
1..1
# tests 1
# suites 0
# pass 0
# fail 1
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,46 @@
'use strict';
require('../../../common');
const test = require('node:test');
test('promise timeout signal', { signal: AbortSignal.timeout(1) }, async (t) => {
await Promise.all([
t.test('ok 1', async () => {}),
t.test('ok 2', () => {}),
t.test('ok 3', { signal: t.signal }, async () => {}),
t.test('ok 4', { signal: t.signal }, () => {}),
t.test('not ok 1', () => new Promise(() => {})),
t.test('not ok 2', (t, done) => {}),
t.test('not ok 3', { signal: t.signal }, () => new Promise(() => {})),
t.test('not ok 4', { signal: t.signal }, (t, done) => {}),
t.test('not ok 5', { signal: t.signal }, (t, done) => {
t.signal.addEventListener('abort', done);
}),
]);
});
test('promise abort signal', { signal: AbortSignal.abort() }, async (t) => {
await t.test('should not appear', () => {});
});
test('callback timeout signal', { signal: AbortSignal.timeout(1) }, (t, done) => {
t.test('ok 1', async () => {});
t.test('ok 2', () => {});
t.test('ok 3', { signal: t.signal }, async () => {});
t.test('ok 4', { signal: t.signal }, () => {});
t.test('not ok 1', () => new Promise(() => {}));
t.test('not ok 2', (t, done) => {});
t.test('not ok 3', { signal: t.signal }, () => new Promise(() => {}));
t.test('not ok 4', { signal: t.signal }, (t, done) => {});
t.test('not ok 5', { signal: t.signal }, (t, done) => {
t.signal.addEventListener('abort', done);
});
});
test('callback abort signal', { signal: AbortSignal.abort() }, (t, done) => {
t.test('should not appear', done);
});
// AbortSignal.timeout(1) doesn't prevent process from closing
// thus we have to keep the process open to prevent cancelation
// of the entire test tree
setTimeout(() => {}, 1000);

View File

@ -0,0 +1,308 @@
TAP version 13
# Subtest: promise timeout signal
# Subtest: ok 1
ok 1 - ok 1
---
duration_ms: *
type: 'test'
...
# Subtest: ok 2
ok 2 - ok 2
---
duration_ms: *
type: 'test'
...
# Subtest: ok 3
ok 3 - ok 3
---
duration_ms: *
type: 'test'
...
# Subtest: ok 4
ok 4 - ok 4
---
duration_ms: *
type: 'test'
...
# Subtest: not ok 1
not ok 5 - not ok 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
# Subtest: not ok 2
not ok 6 - not ok 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
# Subtest: not ok 3
not ok 7 - not ok 3
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: not ok 4
not ok 8 - not ok 4
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: not ok 5
not ok 9 - not ok 5
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
1..9
not ok 1 - promise timeout signal
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):1'
failureType: 'testAborted'
error: 'The operation was aborted due to timeout'
code: 23
name: 'TimeoutError'
stack: |-
*
*
*
*
...
# Subtest: promise abort signal
not ok 2 - promise abort signal
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):1'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: callback timeout signal
# Subtest: ok 1
ok 1 - ok 1
---
duration_ms: *
type: 'test'
...
# Subtest: ok 2
ok 2 - ok 2
---
duration_ms: *
type: 'test'
...
# Subtest: ok 3
ok 3 - ok 3
---
duration_ms: *
type: 'test'
...
# Subtest: ok 4
ok 4 - ok 4
---
duration_ms: *
type: 'test'
...
# Subtest: not ok 1
not ok 5 - not ok 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
# Subtest: not ok 2
not ok 6 - not ok 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
# Subtest: not ok 3
not ok 7 - not ok 3
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: not ok 4
not ok 8 - not ok 4
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: not ok 5
not ok 9 - not ok 5
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
1..9
not ok 3 - callback timeout signal
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):1'
failureType: 'testAborted'
error: 'The operation was aborted due to timeout'
code: 23
name: 'TimeoutError'
stack: |-
*
*
*
*
...
# Subtest: callback abort signal
not ok 4 - callback abort signal
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort.js:(LINE):1'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
1..4
# tests 22
# suites 0
# pass 8
# fail 0
# cancelled 14
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,62 @@
'use strict';
const { before, beforeEach, describe, it, after, afterEach } = require('node:test');
describe('1 before describe', () => {
const ac = new AbortController();
before(() => {
console.log('before');
ac.abort();
}, { signal: ac.signal });
it('test 1', () => {
console.log('1.1');
});
it('test 2', () => {
console.log('1.2');
});
});
describe('2 after describe', () => {
const ac = new AbortController();
after(() => {
console.log('after');
ac.abort();
}, { signal: ac.signal });
it('test 1', () => {
console.log('2.1');
});
it('test 2', () => {
console.log('2.2');
});
});
describe('3 beforeEach describe', () => {
const ac = new AbortController();
beforeEach(() => {
console.log('beforeEach');
ac.abort();
}, { signal: ac.signal });
it('test 1', () => {
console.log('3.1');
});
it('test 2', () => {
console.log('3.2');
});
});
describe('4 afterEach describe', () => {
const ac = new AbortController();
afterEach(() => {
console.log('afterEach');
ac.abort();
}, { signal: ac.signal });
it('test 1', () => {
console.log('4.1');
});
it('test 2', () => {
console.log('4.2');
});
});

View File

@ -0,0 +1,206 @@
before
2.1
2.2
after
beforeEach
4.1
afterEach
4.2
TAP version 13
# Subtest: 1 before describe
# Subtest: test 1
not ok 1 - test 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
# Subtest: test 2
not ok 2 - test 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
1..2
not ok 1 - 1 before describe
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):1'
failureType: 'hookFailed'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: 2 after describe
# Subtest: test 1
ok 1 - test 1
---
duration_ms: *
type: 'test'
...
# Subtest: test 2
ok 2 - test 2
---
duration_ms: *
type: 'test'
...
1..2
not ok 2 - 2 after describe
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):1'
failureType: 'hookFailed'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: 3 beforeEach describe
# Subtest: test 1
not ok 1 - test 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):3'
failureType: 'hookFailed'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: test 2
not ok 2 - test 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):3'
failureType: 'hookFailed'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
1..2
not ok 3 - 3 beforeEach describe
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: 4 afterEach describe
# Subtest: test 1
not ok 1 - test 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):3'
failureType: 'hookFailed'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: test 2
not ok 2 - test 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):3'
failureType: 'hookFailed'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
1..2
not ok 4 - 4 afterEach describe
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
1..4
# tests 8
# suites 4
# pass 2
# fail 4
# cancelled 2
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,26 @@
'use strict';
require('../../../common');
const { describe, it } = require('node:test');
describe('describe timeout signal', { signal: AbortSignal.timeout(1) }, (t) => {
it('ok 1', async () => {});
it('ok 2', () => {});
it('ok 3', { signal: t.signal }, async () => {});
it('ok 4', { signal: t.signal }, () => {});
it('not ok 1', () => new Promise(() => {}));
it('not ok 2', (done) => {});
it('not ok 3', { signal: t.signal }, () => new Promise(() => {}));
it('not ok 4', { signal: t.signal }, (done) => {});
it('not ok 5', { signal: t.signal }, function(done) {
this.signal.addEventListener('abort', done);
});
});
describe('describe abort signal', { signal: AbortSignal.abort() }, () => {
it('should not appear', () => {});
});
// AbortSignal.timeout(1) doesn't prevent process from closing
// thus we have to keep the process open to prevent cancelation
// of the entire test tree
setTimeout(() => {}, 1000);

View File

@ -0,0 +1,159 @@
TAP version 13
# Subtest: describe timeout signal
# Subtest: ok 1
ok 1 - ok 1
---
duration_ms: *
type: 'test'
...
# Subtest: ok 2
ok 2 - ok 2
---
duration_ms: *
type: 'test'
...
# Subtest: ok 3
ok 3 - ok 3
---
duration_ms: *
type: 'test'
...
# Subtest: ok 4
ok 4 - ok 4
---
duration_ms: *
type: 'test'
...
# Subtest: not ok 1
not ok 5 - not ok 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
# Subtest: not ok 2
not ok 6 - not ok 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
# Subtest: not ok 3
not ok 7 - not ok 3
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: not ok 4
not ok 8 - not ok 4
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: not ok 5
not ok 9 - not ok 5
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
1..9
not ok 1 - describe timeout signal
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):1'
failureType: 'testAborted'
error: 'The operation was aborted due to timeout'
code: 23
name: 'TimeoutError'
stack: |-
*
*
*
*
...
# Subtest: describe abort signal
not ok 2 - describe abort signal
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):1'
failureType: 'testAborted'
error: 'This operation was aborted'
code: 20
name: 'AbortError'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
1..2
# tests 9
# suites 2
# pass 4
# fail 0
# cancelled 5
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,7 @@
'use strict';
const test = require('node:test');
console.log({ foo: 'bar' });
test('passing test', () => {
console.log(1);
});

View File

@ -0,0 +1,15 @@
'use strict';
const common = require('../../../common');
const { once } = require('node:events');
const { spawn } = require('node:child_process');
const fixtures = require('../../../common/fixtures');
(async function run() {
const test = fixtures.path('test-runner/output/arbitrary-output-colored-1.js');
const reset = fixtures.path('test-runner/output/reset-color-depth.js');
await once(spawn(process.execPath, ['-r', reset, '--test', test], { stdio: 'inherit' }), 'exit');
await once(
spawn(process.execPath, ['-r', reset, '--test', '--test-reporter', 'tap', test], { stdio: 'inherit' }),
'exit',
);
})().then(common.mustCall());

View File

@ -0,0 +1,29 @@
{ foo: [32m'bar'[39m }
[33m1[39m
[32m✔ passing test [90m(*ms)[39m[39m
[34mℹ tests 1[39m
[34mℹ suites 0[39m
[34mℹ pass 1[39m
[34mℹ fail 0[39m
[34mℹ cancelled 0[39m
[34mℹ skipped 0[39m
[34mℹ todo 0[39m
[34mℹ duration_ms *[39m
TAP version 13
# { foo: [32m'bar'[39m }
# [33m1[39m
# Subtest: passing test
ok 1 - passing test
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,23 @@
// Flags: --test --expose-internals
'use strict';
const v8_reporter = require('internal/test_runner/reporter/v8-serializer');
const { Buffer } = require('buffer');
// eslint-disable-next-line node-core/async-iife-no-unused-result
(async function() {
const reported = v8_reporter([
{
type: 'test:pass',
data: { name: 'test', nesting: 0, file: __filename, testNumber: 1, details: { duration_ms: 0 } },
},
]);
for await (const chunk of reported) {
process.stdout.write(chunk);
process.stdout.write(Buffer.concat([Buffer.from('arbitrary - pre'), chunk]));
process.stdout.write(Buffer.from('arbitrary - mid'));
process.stdout.write(Buffer.concat([chunk, Buffer.from('arbitrary - post')]));
}
})();

View File

@ -0,0 +1,25 @@
TAP version 13
ok 1 - test
---
duration_ms: *
...
# arbitrary - pre
ok 2 - test
---
duration_ms: *
...
# arbitrary - mid
ok 3 - test
---
duration_ms: *
...
# arbitrary - post
1..3
# tests 3
# suites 0
# pass 3
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,6 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
test('failing assertion', () => {
assert.strictEqual('!Hello World', 'Hello World!');
});

View File

@ -0,0 +1,25 @@
[31m✖ failing assertion [90m(*ms)[39m[39m
[34mℹ tests 1[39m
[34mℹ suites 0[39m
[34mℹ pass 0[39m
[34mℹ fail 1[39m
[34mℹ cancelled 0[39m
[34mℹ skipped 0[39m
[34mℹ todo 0[39m
[34mℹ duration_ms *[39m
[31m✖ failing tests:[39m
*
[31m✖ failing assertion [90m(*ms)[39m[39m
[AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
[32mactual[39m [31mexpected[39m
[39m'[39m[32m![39m[39mH[39m[39me[39m[39ml[39m[39ml[39m[39mo[39m[39m [39m[39mW[39m[39mo[39m[39mr[39m[39ml[39m[39md[39m[31m![39m[39m'[39m
] {
generatedMessage: [33mtrue[39m,
code: [32m'ERR_ASSERTION'[39m,
actual: [32m'!Hello World'[39m,
expected: [32m'Hello World!'[39m,
operator: [32m'strictEqual'[39m
}

View File

@ -0,0 +1,13 @@
import * as common from '../../../common/index.mjs';
import { describe, test } from 'node:test';
import { setTimeout } from 'node:timers/promises';
test('test', common.mustCall());
describe('suite', common.mustCall(async () => {
test('test', common.mustCall());
await setTimeout(10);
test('scheduled async', common.mustCall());
}));
await setTimeout(10);
test('scheduled async', common.mustCall());

View File

@ -0,0 +1,41 @@
TAP version 13
# Subtest: test
ok 1 - test
---
duration_ms: *
type: 'test'
...
# Subtest: suite
# Subtest: test
ok 1 - test
---
duration_ms: *
type: 'test'
...
# Subtest: scheduled async
ok 2 - scheduled async
---
duration_ms: *
type: 'test'
...
1..2
ok 2 - suite
---
duration_ms: *
type: 'suite'
...
# Subtest: scheduled async
ok 3 - scheduled async
---
duration_ms: *
type: 'test'
...
1..3
# tests 4
# suites 1
# pass 4
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,8 @@
'use strict';
const { beforeEach, afterEach, test } = require('node:test');
beforeEach(() => {});
afterEach(() => {});
for (let i = 1; i <= 11; ++i) {
test(`${i}`, () => {});
}

View File

@ -0,0 +1,76 @@
TAP version 13
# Subtest: 1
ok 1 - 1
---
duration_ms: *
type: 'test'
...
# Subtest: 2
ok 2 - 2
---
duration_ms: *
type: 'test'
...
# Subtest: 3
ok 3 - 3
---
duration_ms: *
type: 'test'
...
# Subtest: 4
ok 4 - 4
---
duration_ms: *
type: 'test'
...
# Subtest: 5
ok 5 - 5
---
duration_ms: *
type: 'test'
...
# Subtest: 6
ok 6 - 6
---
duration_ms: *
type: 'test'
...
# Subtest: 7
ok 7 - 7
---
duration_ms: *
type: 'test'
...
# Subtest: 8
ok 8 - 8
---
duration_ms: *
type: 'test'
...
# Subtest: 9
ok 9 - 9
---
duration_ms: *
type: 'test'
...
# Subtest: 10
ok 10 - 10
---
duration_ms: *
type: 'test'
...
# Subtest: 11
ok 11 - 11
---
duration_ms: *
type: 'test'
...
1..11
# tests 11
# suites 0
# pass 11
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,8 @@
'use strict';
const { beforeEach, afterEach, test } = require('node:test');
beforeEach(() => {}, { timeout: 10000 });
afterEach(() => {}, { timeout: 10000 });
for (let i = 1; i <= 11; ++i) {
test(`${i}`, () => {});
}

View File

@ -0,0 +1,76 @@
TAP version 13
# Subtest: 1
ok 1 - 1
---
duration_ms: *
type: 'test'
...
# Subtest: 2
ok 2 - 2
---
duration_ms: *
type: 'test'
...
# Subtest: 3
ok 3 - 3
---
duration_ms: *
type: 'test'
...
# Subtest: 4
ok 4 - 4
---
duration_ms: *
type: 'test'
...
# Subtest: 5
ok 5 - 5
---
duration_ms: *
type: 'test'
...
# Subtest: 6
ok 6 - 6
---
duration_ms: *
type: 'test'
...
# Subtest: 7
ok 7 - 7
---
duration_ms: *
type: 'test'
...
# Subtest: 8
ok 8 - 8
---
duration_ms: *
type: 'test'
...
# Subtest: 9
ok 9 - 9
---
duration_ms: *
type: 'test'
...
# Subtest: 10
ok 10 - 10
---
duration_ms: *
type: 'test'
...
# Subtest: 11
ok 11 - 11
---
duration_ms: *
type: 'test'
...
1..11
# tests 11
# suites 0
# pass 11
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,9 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/a.js';
import { test } from 'node:test';
test(`Coverage Print Short Filename`);

View File

@ -0,0 +1,25 @@
TAP version 13
# Subtest: Coverage Print Short Filename
ok 1 - Coverage Print Short Filename
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# ---------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# ---------------------------------------------------------------------------------------
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
# ---------------------------------------------------------------------------------------
# all files | 55.77 | 100.00 | 0.00 |
# ---------------------------------------------------------------------------------------
# end of coverage report

View File

@ -0,0 +1,15 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
// eslint-disable-next-line no-unused-vars
import * as c from '../coverage-snap/many-uncovered-lines.js';
import { test } from 'node:test';
process.stdout.columns = 100;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,33 @@
TAP version 13
# Subtest: Coverage Print Fixed Width 100
ok 1 - Coverage Print Fixed Width 100
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# --------------------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# --------------------------------------------------------------------------------------------------
# test | | | |
# fixtures | | | |
# test-runner | | | |
# coverage-snap | | | |
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 …
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 17-19 …
# output | | | |
# coverage-width-100-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
# --------------------------------------------------------------------------------------------------
# all files | 53.13 | 60.00 | 1.61 |
# --------------------------------------------------------------------------------------------------
# end of coverage report

View File

@ -0,0 +1,13 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
import { test } from 'node:test';
process.stdout.columns = 100;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,32 @@
TAP version 13
# Subtest: Coverage Print Fixed Width 100
ok 1 - Coverage Print Fixed Width 100
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# --------------------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# --------------------------------------------------------------------------------------------------
# test | | | |
# fixtures | | | |
# test-runner | | | |
# coverage-snap | | | |
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-4…
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
# output | | | |
# coverage-width-100.mjs | 100.00 | 100.00 | 100.00 |
# --------------------------------------------------------------------------------------------------
# all files | 61.84 | 100.00 | 0.00 |
# --------------------------------------------------------------------------------------------------
# end of coverage report

View File

@ -0,0 +1,15 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
// eslint-disable-next-line no-unused-vars
import * as c from '../coverage-snap/many-uncovered-lines.js';
import { test } from 'node:test';
process.stdout.columns = 150;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,33 @@
TAP version 13
# Subtest: Coverage Print Fixed Width 150
ok 1 - Coverage Print Fixed Width 150
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# ----------------------------------------------------------------------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# ----------------------------------------------------------------------------------------------------------------------------------------------------
# test | | | |
# fixtures | | | |
# test-runner | | | |
# coverage-snap | | | |
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 55-57 59-61 63-65 67-69 91…
# output | | | |
# coverage-width-150-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
# ----------------------------------------------------------------------------------------------------------------------------------------------------
# all files | 53.13 | 60.00 | 1.61 |
# ----------------------------------------------------------------------------------------------------------------------------------------------------
# end of coverage report

View File

@ -0,0 +1,13 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
import { test } from 'node:test';
process.stdout.columns = 150;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,32 @@
TAP version 13
# Subtest: Coverage Print Fixed Width 150
ok 1 - Coverage Print Fixed Width 150
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# --------------------------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# --------------------------------------------------------------------------------------------------------
# test | | | |
# fixtures | | | |
# test-runner | | | |
# coverage-snap | | | |
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
# output | | | |
# coverage-width-150.mjs | 100.00 | 100.00 | 100.00 |
# --------------------------------------------------------------------------------------------------------
# all files | 61.84 | 100.00 | 0.00 |
# --------------------------------------------------------------------------------------------------------
# end of coverage report

View File

@ -0,0 +1,15 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
// eslint-disable-next-line no-unused-vars
import * as c from '../coverage-snap/a-very-long-long-long-sub-dir/c.js';
import { test } from 'node:test';
process.stdout.columns = 40;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,34 @@
TAP version 13
# Subtest: Coverage Print Fixed Width 40
ok 1 - Coverage Print Fixed Width 40
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# --------------------------------------
# file | line % | branch % | funcs % | …
# --------------------------------------
# test | | | |
# fixtures | | | |
# test-runner | | | |
# coverage-snap | | | |
# …g-long-sub-dir | | | |
# c.js | 55.77 | 100.00 | 0.00 | …
# a.js | 55.77 | 100.00 | 0.00 | …
# b.js | 45.45 | 100.00 | 0.00 | …
# output | | | |
# …e-width-40.mjs | 100.00 | 100.00 | 100.00 |
# --------------------------------------
# all files | 60.00 | 100.00 | 0.00 |
# --------------------------------------
# end of coverage report

View File

@ -0,0 +1,14 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
import { test } from 'node:test';
process.env.FORCE_COLOR = '3';
process.stdout.columns = 80;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,26 @@
[32m✔ Coverage Print Fixed Width 80 [90m(*ms)[39m[39m
[34mℹ tests 1[39m
[34mℹ suites 0[39m
[34mℹ pass 1[39m
[34mℹ fail 0[39m
[34mℹ cancelled 0[39m
[34mℹ skipped 0[39m
[34mℹ todo 0[39m
[34mℹ duration_ms *[39m
[34mℹ start of coverage report
ℹ ------------------------------------------------------------------------------
ℹ file | [31mline %[34m | [31mbranch %[34m | [31mfuncs %[34m | uncovered …
ℹ ------------------------------------------------------------------------------
ℹ test | [31m [34m | [31m [34m | [31m [34m |
ℹ fixtures | [31m [34m | [31m [34m | [31m [34m |
ℹ test-runner | [31m [34m | [31m [34m | [31m [34m |
ℹ coverage-snap | [31m [34m | [31m [34m | [31m [34m |
ℹ [33ma.js [34m | [33m 55.77[34m | [32m 100.00[34m | [31m 0.00[34m | 5-7 9-11 1…
ℹ [31mb.js [34m | [31m 45.45[34m | [32m 100.00[34m | [31m 0.00[34m | 5-7 9-11
ℹ output | [31m [34m | [31m [34m | [31m [34m |
ℹ [32mcoverage-width-80-color.mjs [34m | [32m100.00[34m | [32m 100.00[34m | [32m 100.00[34m |
ℹ ------------------------------------------------------------------------------
ℹ all files | [33m 62.34[34m | [32m 100.00[34m | [31m 0.00[34m |
ℹ ------------------------------------------------------------------------------
ℹ end of coverage report
[39m

View File

@ -0,0 +1,16 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
// eslint-disable-next-line no-unused-vars
import * as c from '../coverage-snap/many-uncovered-lines.js';
import { test } from 'node:test';
process.env.FORCE_COLOR = '3';
process.stdout.columns = 100;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,27 @@
[32m✔ Coverage Print Fixed Width 100 [90m(*ms)[39m[39m
[34mℹ tests 1[39m
[34mℹ suites 0[39m
[34mℹ pass 1[39m
[34mℹ fail 0[39m
[34mℹ cancelled 0[39m
[34mℹ skipped 0[39m
[34mℹ todo 0[39m
[34mℹ duration_ms *[39m
[34mℹ start of coverage report
ℹ --------------------------------------------------------------------------------------------------
ℹ file | [31mline %[34m | [31mbranch %[34m | [31mfuncs %[34m | uncovered lines
ℹ --------------------------------------------------------------------------------------------------
ℹ test | [31m [34m | [31m [34m | [31m [34m |
ℹ fixtures | [31m [34m | [31m [34m | [31m [34m |
ℹ test-runner | [31m [34m | [31m [34m | [31m [34m |
ℹ coverage-snap | [31m [34m | [31m [34m | [31m [34m |
ℹ [33ma.js [34m | [33m 55.77[34m | [32m 100.00[34m | [31m 0.00[34m | 5-7 9-11 13-15…
ℹ [31mb.js [34m | [31m 45.45[34m | [32m 100.00[34m | [31m 0.00[34m | 5-7 9-11
ℹ [31mmany-uncovered-lines.js [34m | [33m 50.99[34m | [31m 42.86[34m | [31m 1.92[34m | 5-7 9-11 13-15…
ℹ output | [31m [34m | [31m [34m | [31m [34m |
ℹ [32mcoverage-width-80-uncovered-lines-color.mjs [34m | [32m100.00[34m | [32m 100.00[34m | [32m 100.00[34m |
ℹ --------------------------------------------------------------------------------------------------
ℹ all files | [33m 53.24[34m | [33m 60.00[34m | [31m 1.61[34m |
ℹ --------------------------------------------------------------------------------------------------
ℹ end of coverage report
[39m

View File

@ -0,0 +1,15 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
// eslint-disable-next-line no-unused-vars
import * as c from '../coverage-snap/many-uncovered-lines.js';
import { test } from 'node:test';
process.stdout.columns = 100;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,33 @@
TAP version 13
# Subtest: Coverage Print Fixed Width 100
ok 1 - Coverage Print Fixed Width 100
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# --------------------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# --------------------------------------------------------------------------------------------------
# test | | | |
# fixtures | | | |
# test-runner | | | |
# coverage-snap | | | |
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 2…
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 17-19 2…
# output | | | |
# coverage-width-80-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
# --------------------------------------------------------------------------------------------------
# all files | 53.13 | 60.00 | 1.61 |
# --------------------------------------------------------------------------------------------------
# end of coverage report

View File

@ -0,0 +1,13 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
import { test } from 'node:test';
process.stdout.columns = 80;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,32 @@
TAP version 13
# Subtest: Coverage Print Fixed Width 80
ok 1 - Coverage Print Fixed Width 80
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# ------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# ------------------------------------------------------------------------------
# test | | | |
# fixtures | | | |
# test-runner | | | |
# coverage-snap | | | |
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-…
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
# output | | | |
# coverage-width-80.mjs | 100.00 | 100.00 | 100.00 |
# ------------------------------------------------------------------------------
# all files | 61.84 | 100.00 | 0.00 |
# ------------------------------------------------------------------------------
# end of coverage report

View File

@ -0,0 +1,15 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
// eslint-disable-next-line no-unused-vars
import * as c from '../coverage-snap/many-uncovered-lines.js';
import { test } from 'node:test';
process.stdout.columns = Infinity;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,33 @@
TAP version 13
# Subtest: Coverage Print Fixed Width Infinity
ok 1 - Coverage Print Fixed Width Infinity
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# test | | | |
# fixtures | | | |
# test-runner | | | |
# coverage-snap | | | |
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 55-57 59-61 63-65 67-69 91-93 96-98 100-102 104-106 111-112 118-119 122-123 127-129 132-136 144-146 150 166-167 173 180 188-189 196-200 207-213 216-218 221-223 226-228 232 236-238 241-243 246-248 251-257 260-262 265-268 271-273 276-280 283-285 288-290 293-295 298-301 304-306 309-312 315-318 321-324 327-329 332-340 343-348 351-353
# output | | | |
# coverage-width-infinity-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# all files | 53.13 | 60.00 | 1.61 |
# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# end of coverage report

View File

@ -0,0 +1,13 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/b.js';
// eslint-disable-next-line no-unused-vars
import * as b from '../coverage-snap/a.js';
import { test } from 'node:test';
process.stdout.columns = Infinity;
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

View File

@ -0,0 +1,32 @@
TAP version 13
# Subtest: Coverage Print Fixed Width Infinity
ok 1 - Coverage Print Fixed Width Infinity
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# -------------------------------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# -------------------------------------------------------------------------------------------------------------
# test | | | |
# fixtures | | | |
# test-runner | | | |
# coverage-snap | | | |
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
# output | | | |
# coverage-width-infinity.mjs | 100.00 | 100.00 | 100.00 |
# -------------------------------------------------------------------------------------------------------------
# all files | 61.84 | 100.00 | 0.00 |
# -------------------------------------------------------------------------------------------------------------
# end of coverage report

View File

@ -0,0 +1,12 @@
// Flags: --expose-internals --experimental-test-coverage
'use strict';
require('../../../common');
const { TestCoverage } = require('internal/test_runner/coverage');
const { test, mock } = require('node:test');
mock.method(TestCoverage.prototype, 'summary', () => {
throw new Error('Failed to collect coverage');
});
test('ok');

View File

@ -0,0 +1,17 @@
TAP version 13
# Subtest: ok
ok 1 - ok
---
duration_ms: *
type: 'test'
...
1..1
# Warning: Could not report code coverage. Error: Failed to collect coverage
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,17 @@
'use strict';
process.env.FORCE_COLOR = '1';
delete process.env.NODE_DISABLE_COLORS;
delete process.env.NO_COLOR;
require('../../../common');
const test = require('node:test');
test('should pass', () => {});
test('should fail', () => { throw new Error('fail'); });
test('should skip', { skip: true }, () => {});
test('parent', (t) => {
t.test('should fail', () => { throw new Error('fail'); });
t.test('should pass but parent fail', (t, done) => {
setImmediate(done);
});
});

View File

@ -0,0 +1,42 @@
[32m✔ should pass [90m(*ms)[39m[39m
[31m✖ should fail [90m(*ms)[39m[39m
[90m﹣ should skip [90m(*ms)[39m # SKIP[39m
▶ parent
[31m✖ should fail [90m(*ms)[39m[39m
[32m✔ should pass but parent fail [90m(*ms)[39m[39m
[31m✖ parent [90m(*ms)[39m[39m
[34mℹ tests 6[39m
[34mℹ suites 0[39m
[34mℹ pass 2[39m
[34mℹ fail 3[39m
[34mℹ cancelled 0[39m
[34mℹ skipped 1[39m
[34mℹ todo 0[39m
[34mℹ duration_ms *[39m
[31m✖ failing tests:[39m
*
[31m✖ should fail [90m(*ms)[39m[39m
Error: fail
*[39m
*[39m
*[39m
*[39m
*[39m
*[39m
*[39m
*
[31m✖ should fail [90m(*ms)[39m[39m
Error: fail
*[39m
*[39m
*[39m
*[39m
*[39m
*[39m
*[39m
*[39m
*[39m
*[39m

View File

@ -0,0 +1,392 @@
'use strict';
require('../../../common');
const assert = require('node:assert');
const { describe, it, test } = require('node:test');
const util = require('util');
it.todo('sync pass todo', () => {
});
it('sync pass todo with message', { todo: 'this is a passing todo' }, () => {
});
it.todo('sync todo', () => {
throw new Error('should not count as a failure');
});
it('sync todo with message', { todo: 'this is a failing todo' }, () => {
throw new Error('should not count as a failure');
});
it.skip('sync skip pass', () => {
});
it('sync skip pass with message', { skip: 'this is skipped' }, () => {
});
it('sync pass', () => {
});
it('sync throw fail', () => {
throw new Error('thrown from sync throw fail');
});
it.skip('async skip pass', async () => {
});
it('async pass', async () => {
});
test('mixing describe/it and test should work', () => {});
it('async throw fail', async () => {
throw new Error('thrown from async throw fail');
});
it('async skip fail', async (t, done) => {
t.skip();
throw new Error('thrown from async throw fail');
});
it('async assertion fail', async () => {
// Make sure the assert module is handled.
assert.strictEqual(true, false);
});
it('resolve pass', () => {
return Promise.resolve();
});
it('reject fail', () => {
return Promise.reject(new Error('rejected from reject fail'));
});
it('unhandled rejection - passes but warns', () => {
Promise.reject(new Error('rejected from unhandled rejection fail'));
});
it('async unhandled rejection - passes but warns', async () => {
Promise.reject(new Error('rejected from async unhandled rejection fail'));
});
it('immediate throw - passes but warns', () => {
setImmediate(() => {
throw new Error('thrown from immediate throw fail');
});
});
it('immediate reject - passes but warns', () => {
setImmediate(() => {
Promise.reject(new Error('rejected from immediate reject fail'));
});
});
it('immediate resolve pass', () => {
return new Promise((resolve) => {
setImmediate(() => {
resolve();
});
});
});
describe('subtest sync throw fail', () => {
it('+sync throw fail', () => {
throw new Error('thrown from subtest sync throw fail');
});
test('mixing describe/it and test should work', () => {});
});
it('sync throw non-error fail', async () => {
throw Symbol('thrown symbol from sync throw non-error fail');
});
describe('level 0a', { concurrency: 4 }, () => {
it('level 1a', async () => {
const p1a = new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 100);
});
return p1a;
});
it('level 1b', async () => {
const p1b = new Promise((resolve) => {
resolve();
});
return p1b;
});
it('level 1c', async () => {
const p1c = new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 200);
});
return p1c;
});
it('level 1d', async () => {
const p1c = new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 150);
});
return p1c;
});
const p0a = new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 300);
});
return p0a;
});
describe('invalid subtest - pass but subtest fails', () => {
setImmediate(() => {
it('invalid subtest fail', () => {
throw new Error('this should not be thrown');
});
});
});
it.skip('sync skip option', () => {
throw new Error('this should not be executed');
});
it('sync skip option with message', { skip: 'this is skipped' }, () => {
throw new Error('this should not be executed');
});
it('sync skip option is false fail', { skip: false }, () => {
throw new Error('this should be executed');
});
// A test with no arguments provided.
it();
// A test with only a named function provided.
it(function functionOnly() {});
// A test with only an anonymous function provided.
it(() => {});
// A test with only a name provided.
it('test with only a name provided');
// A test with an empty string name.
it('');
// A test with only options provided.
it({ skip: true });
// A test with only a name and options provided.
it('test with a name and options provided', { skip: true });
// A test with only options and a function provided.
it({ skip: true }, function functionAndOptions() {});
it('callback pass', (t, done) => {
setImmediate(done);
});
it('callback fail', (t, done) => {
setImmediate(() => {
done(new Error('callback failure'));
});
});
it('sync t is this in test', function(t) {
assert.strictEqual(this, t);
});
it('async t is this in test', async function(t) {
assert.strictEqual(this, t);
});
it('callback t is this in test', function(t, done) {
assert.strictEqual(this, t);
done();
});
it('callback also returns a Promise', async (t, done) => {
throw new Error('thrown from callback also returns a Promise');
});
it('callback throw', (t, done) => {
throw new Error('thrown from callback throw');
});
it('callback called twice', (t, done) => {
done();
done();
});
it('callback called twice in different ticks', (t, done) => {
setImmediate(done);
done();
});
it('callback called twice in future tick', (t, done) => {
setImmediate(() => {
done();
done();
});
});
it('callback async throw', (t, done) => {
setImmediate(() => {
throw new Error('thrown from callback async throw');
});
});
it('callback async throw after done', (t, done) => {
setImmediate(() => {
throw new Error('thrown from callback async throw after done');
});
done();
});
it('custom inspect symbol fail', () => {
const obj = {
[util.inspect.custom]() {
return 'customized';
},
foo: 1,
};
throw obj;
});
it('custom inspect symbol that throws fail', () => {
const obj = {
[util.inspect.custom]() {
throw new Error('bad-inspect');
},
foo: 1,
};
throw obj;
});
describe('subtest sync throw fails', () => {
it('sync throw fails at first', () => {
throw new Error('thrown from subtest sync throw fails at first');
});
it('sync throw fails at second', () => {
throw new Error('thrown from subtest sync throw fails at second');
});
});
describe('describe sync throw fails', () => {
it('should not run', () => {});
throw new Error('thrown from describe');
});
describe('describe async throw fails', async () => {
it('should not run', () => {});
throw new Error('thrown from describe');
});
describe('timeouts', () => {
it('timed out async test', { timeout: 5 }, async () => {
return new Promise((resolve) => {
setTimeout(() => {
// Empty timer so the process doesn't exit before the timeout triggers.
}, 5);
setTimeout(resolve, 30_000_000).unref();
});
});
it('timed out callback test', { timeout: 5 }, (t, done) => {
setTimeout(() => {
// Empty timer so the process doesn't exit before the timeout triggers.
}, 5);
setTimeout(done, 30_000_000).unref();
});
it('large timeout async test is ok', { timeout: 30_000_000 }, async () => {
return new Promise((resolve) => {
setTimeout(resolve, 10);
});
});
it('large timeout callback test is ok', { timeout: 30_000_000 }, (t, done) => {
setTimeout(done, 10);
});
});
describe('successful thenable', () => {
it('successful thenable', () => {
let thenCalled = false;
return {
get then() {
if (thenCalled) throw new Error();
thenCalled = true;
return (successHandler) => successHandler();
},
};
});
it('rejected thenable', () => {
let thenCalled = false;
return {
get then() {
if (thenCalled) throw new Error();
thenCalled = true;
return (_, errorHandler) => errorHandler(new Error('custom error'));
},
};
});
let thenCalled = false;
return {
get then() {
if (thenCalled) throw new Error();
thenCalled = true;
return (successHandler) => successHandler();
},
};
});
describe('rejected thenable', () => {
let thenCalled = false;
return {
get then() {
if (thenCalled) throw new Error();
thenCalled = true;
return (_, errorHandler) => errorHandler(new Error('custom error'));
},
};
});
describe('async describe function', async () => {
await null;
await it('it inside describe 1', async () => {
await null;
});
await it('it inside describe 2', async () => {
await null;
});
describe('inner describe', async () => {
await null;
it('it inside inner describe', async () => {
await null;
});
});
});

View File

@ -0,0 +1,774 @@
TAP version 13
# Subtest: sync pass todo
ok 1 - sync pass todo # TODO
---
duration_ms: *
type: 'test'
...
# Subtest: sync pass todo with message
ok 2 - sync pass todo with message # TODO this is a passing todo
---
duration_ms: *
type: 'test'
...
# Subtest: sync todo
not ok 3 - sync todo # TODO
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):4'
failureType: 'testCodeFailure'
error: 'should not count as a failure'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
...
# Subtest: sync todo with message
not ok 4 - sync todo with message # TODO this is a failing todo
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'should not count as a failure'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
...
# Subtest: sync skip pass
ok 5 - sync skip pass # SKIP
---
duration_ms: *
type: 'test'
...
# Subtest: sync skip pass with message
ok 6 - sync skip pass with message # SKIP this is skipped
---
duration_ms: *
type: 'test'
...
# Subtest: sync pass
ok 7 - sync pass
---
duration_ms: *
type: 'test'
...
# Subtest: sync throw fail
not ok 8 - sync throw fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'thrown from sync throw fail'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
...
# Subtest: async skip pass
ok 9 - async skip pass # SKIP
---
duration_ms: *
type: 'test'
...
# Subtest: async pass
ok 10 - async pass
---
duration_ms: *
type: 'test'
...
# Subtest: mixing describe/it and test should work
ok 11 - mixing describe/it and test should work
---
duration_ms: *
type: 'test'
...
# Subtest: async throw fail
not ok 12 - async throw fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'thrown from async throw fail'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
...
# Subtest: async skip fail
not ok 13 - async skip fail # SKIP
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'callbackAndPromisePresent'
error: 'passed a callback but also returned a Promise'
code: 'ERR_TEST_FAILURE'
...
# Subtest: async assertion fail
not ok 14 - async assertion fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: |-
Expected values to be strictly equal:
true !== false
code: 'ERR_ASSERTION'
name: 'AssertionError'
expected: false
actual: true
operator: 'strictEqual'
stack: |-
*
*
*
*
*
*
*
...
# Subtest: resolve pass
ok 15 - resolve pass
---
duration_ms: *
type: 'test'
...
# Subtest: reject fail
not ok 16 - reject fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'rejected from reject fail'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
...
# Subtest: unhandled rejection - passes but warns
ok 17 - unhandled rejection - passes but warns
---
duration_ms: *
type: 'test'
...
# Subtest: async unhandled rejection - passes but warns
ok 18 - async unhandled rejection - passes but warns
---
duration_ms: *
type: 'test'
...
# Subtest: immediate throw - passes but warns
ok 19 - immediate throw - passes but warns
---
duration_ms: *
type: 'test'
...
# Subtest: immediate reject - passes but warns
ok 20 - immediate reject - passes but warns
---
duration_ms: *
type: 'test'
...
# Subtest: immediate resolve pass
ok 21 - immediate resolve pass
---
duration_ms: *
type: 'test'
...
# Subtest: subtest sync throw fail
# Subtest: +sync throw fail
not ok 1 - +sync throw fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
failureType: 'testCodeFailure'
error: 'thrown from subtest sync throw fail'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
new Promise (<anonymous>)
*
*
Array.map (<anonymous>)
...
# Subtest: mixing describe/it and test should work
ok 2 - mixing describe/it and test should work
---
duration_ms: *
type: 'test'
...
1..2
not ok 22 - subtest sync throw fail
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'subtestsFailed'
error: '1 subtest failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: sync throw non-error fail
not ok 23 - sync throw non-error fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'Symbol(thrown symbol from sync throw non-error fail)'
code: 'ERR_TEST_FAILURE'
...
# Subtest: level 0a
# Subtest: level 1a
ok 1 - level 1a
---
duration_ms: *
type: 'test'
...
# Subtest: level 1b
ok 2 - level 1b
---
duration_ms: *
type: 'test'
...
# Subtest: level 1c
ok 3 - level 1c
---
duration_ms: *
type: 'test'
...
# Subtest: level 1d
ok 4 - level 1d
---
duration_ms: *
type: 'test'
...
1..4
ok 24 - level 0a
---
duration_ms: *
type: 'suite'
...
# Subtest: invalid subtest - pass but subtest fails
ok 25 - invalid subtest - pass but subtest fails
---
duration_ms: *
type: 'suite'
...
# Subtest: sync skip option
ok 26 - sync skip option # SKIP
---
duration_ms: *
type: 'test'
...
# Subtest: sync skip option with message
ok 27 - sync skip option with message # SKIP this is skipped
---
duration_ms: *
type: 'test'
...
# Subtest: sync skip option is false fail
not ok 28 - sync skip option is false fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'this should be executed'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
...
# Subtest: <anonymous>
ok 29 - <anonymous>
---
duration_ms: *
type: 'test'
...
# Subtest: functionOnly
ok 30 - functionOnly
---
duration_ms: *
type: 'test'
...
# Subtest: <anonymous>
ok 31 - <anonymous>
---
duration_ms: *
type: 'test'
...
# Subtest: test with only a name provided
ok 32 - test with only a name provided
---
duration_ms: *
type: 'test'
...
# Subtest: <anonymous>
ok 33 - <anonymous>
---
duration_ms: *
type: 'test'
...
# Subtest: <anonymous>
ok 34 - <anonymous> # SKIP
---
duration_ms: *
type: 'test'
...
# Subtest: test with a name and options provided
ok 35 - test with a name and options provided # SKIP
---
duration_ms: *
type: 'test'
...
# Subtest: functionAndOptions
ok 36 - functionAndOptions # SKIP
---
duration_ms: *
type: 'test'
...
# Subtest: callback pass
ok 37 - callback pass
---
duration_ms: *
type: 'test'
...
# Subtest: callback fail
not ok 38 - callback fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'callback failure'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
...
# Subtest: sync t is this in test
ok 39 - sync t is this in test
---
duration_ms: *
type: 'test'
...
# Subtest: async t is this in test
ok 40 - async t is this in test
---
duration_ms: *
type: 'test'
...
# Subtest: callback t is this in test
ok 41 - callback t is this in test
---
duration_ms: *
type: 'test'
...
# Subtest: callback also returns a Promise
not ok 42 - callback also returns a Promise
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'callbackAndPromisePresent'
error: 'passed a callback but also returned a Promise'
code: 'ERR_TEST_FAILURE'
...
# Subtest: callback throw
not ok 43 - callback throw
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'thrown from callback throw'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
...
# Subtest: callback called twice
not ok 44 - callback called twice
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'multipleCallbackInvocations'
error: 'callback invoked multiple times'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
...
# Subtest: callback called twice in different ticks
ok 45 - callback called twice in different ticks
---
duration_ms: *
type: 'test'
...
# Subtest: callback called twice in future tick
not ok 46 - callback called twice in future tick
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'uncaughtException'
error: 'callback invoked multiple times'
code: 'ERR_TEST_FAILURE'
stack: |-
*
...
# Subtest: callback async throw
not ok 47 - callback async throw
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'uncaughtException'
error: 'thrown from callback async throw'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
...
# Subtest: callback async throw after done
ok 48 - callback async throw after done
---
duration_ms: *
type: 'test'
...
# Subtest: custom inspect symbol fail
not ok 49 - custom inspect symbol fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'customized'
code: 'ERR_TEST_FAILURE'
...
# Subtest: custom inspect symbol that throws fail
not ok 50 - custom inspect symbol that throws fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: |-
{
foo: 1,
Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]]
}
code: 'ERR_TEST_FAILURE'
...
# Subtest: subtest sync throw fails
# Subtest: sync throw fails at first
not ok 1 - sync throw fails at first
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
failureType: 'testCodeFailure'
error: 'thrown from subtest sync throw fails at first'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
new Promise (<anonymous>)
*
*
Array.map (<anonymous>)
...
# Subtest: sync throw fails at second
not ok 2 - sync throw fails at second
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
failureType: 'testCodeFailure'
error: 'thrown from subtest sync throw fails at second'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
async Promise.all (index 0)
*
*
...
1..2
not ok 51 - subtest sync throw fails
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: describe sync throw fails
# Subtest: should not run
not ok 1 - should not run
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
1..1
not ok 52 - describe sync throw fails
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'thrown from describe'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: describe async throw fails
# Subtest: should not run
not ok 1 - should not run
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
1..1
not ok 53 - describe async throw fails
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'thrown from describe'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: timeouts
# Subtest: timed out async test
not ok 1 - timed out async test
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
failureType: 'testTimeoutFailure'
error: 'test timed out after 5ms'
code: 'ERR_TEST_FAILURE'
stack: |-
async Promise.all (index 0)
...
# Subtest: timed out callback test
not ok 2 - timed out callback test
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
failureType: 'testTimeoutFailure'
error: 'test timed out after 5ms'
code: 'ERR_TEST_FAILURE'
...
# Subtest: large timeout async test is ok
ok 3 - large timeout async test is ok
---
duration_ms: *
type: 'test'
...
# Subtest: large timeout callback test is ok
ok 4 - large timeout callback test is ok
---
duration_ms: *
type: 'test'
...
1..4
not ok 54 - timeouts
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: successful thenable
# Subtest: successful thenable
ok 1 - successful thenable
---
duration_ms: *
type: 'test'
...
# Subtest: rejected thenable
not ok 2 - rejected thenable
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
failureType: 'testCodeFailure'
error: 'custom error'
code: 'ERR_TEST_FAILURE'
stack: |-
*
...
1..2
not ok 55 - successful thenable
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'subtestsFailed'
error: '1 subtest failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: rejected thenable
not ok 56 - rejected thenable
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'custom error'
code: 'ERR_TEST_FAILURE'
stack: |-
*
...
# Subtest: async describe function
# Subtest: it inside describe 1
ok 1 - it inside describe 1
---
duration_ms: *
type: 'test'
...
# Subtest: it inside describe 2
ok 2 - it inside describe 2
---
duration_ms: *
type: 'test'
...
# Subtest: inner describe
# Subtest: it inside inner describe
ok 1 - it inside inner describe
---
duration_ms: *
type: 'test'
...
1..1
ok 3 - inner describe
---
duration_ms: *
type: 'suite'
...
1..3
ok 57 - async describe function
---
duration_ms: *
type: 'suite'
...
# Subtest: invalid subtest fail
not ok 58 - invalid subtest fail
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):5'
failureType: 'parentAlreadyFinished'
error: 'test could not be started because its parent finished'
code: 'ERR_TEST_FAILURE'
stack: |-
*
...
1..58
# Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/describe_it.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
# Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/describe_it.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
# Error: Test "immediate throw - passes but warns" at test/fixtures/test-runner/output/describe_it.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event.
# Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/describe_it.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
# Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/describe_it.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event.
# Error: Test "callback async throw after done" at test/fixtures/test-runner/output/describe_it.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event.
# tests 67
# suites 11
# pass 31
# fail 19
# cancelled 4
# skipped 9
# todo 4
# duration_ms *

View File

@ -0,0 +1,9 @@
'use strict';
require('../../../common');
const { describe, it } = require('node:test');
describe('nested - no tests', () => {
describe('nested', () => {
it('nested', () => {});
});
});

View File

@ -0,0 +1,30 @@
TAP version 13
# Subtest: nested - no tests
# Subtest: nested
# Subtest: nested
ok 1 - nested
---
duration_ms: *
type: 'test'
...
1..1
ok 1 - nested
---
duration_ms: *
type: 'suite'
...
1..1
ok 1 - nested - no tests
---
duration_ms: *
type: 'suite'
...
1..1
# tests 1
# suites 2
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,21 @@
// Flags: --test-reporter=dot
'use strict';
process.stdout.columns = 30;
process.env.FORCE_COLOR = '1';
delete process.env.NODE_DISABLE_COLORS;
delete process.env.NO_COLOR;
const test = require('node:test');
const { setTimeout } = require('timers/promises');
for (let i = 0; i < 100; i++) {
test(i + ' example', async () => {
if (i === 0) {
// So the reporter will run before all tests has started
await setTimeout(10);
}
// resize
if (i === 28)
process.stdout.columns = 41;
});
}

View File

@ -0,0 +1,3 @@
[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m
[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m
[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m

View File

@ -0,0 +1,7 @@
'use strict';
require('../../../common');
const fixtures = require('../../../common/fixtures');
const spawn = require('node:child_process').spawn;
spawn(process.execPath,
['--no-warnings', '--test-reporter', 'dot', fixtures.path('test-runner/output/output.js')], { stdio: 'inherit' });

View File

@ -0,0 +1,219 @@
..XX...X..XXX.X.....
XXX............X....
.....X...XXX.XX.....
XXXXXXX...XXXXX
Failed tests:
✖ sync fail todo (*ms) # TODO
Error: thrown from sync fail todo
*
*
*
*
*
*
*
✖ sync fail todo with message (*ms) # this is a failing todo
Error: thrown from sync fail todo with message
*
*
*
*
*
*
*
✖ sync throw fail (*ms)
Error: thrown from sync throw fail
*
*
*
*
*
*
*
✖ async throw fail (*ms)
Error: thrown from async throw fail
*
*
*
*
*
*
*
﹣ async skip fail (*ms) # SKIP
Error: thrown from async throw fail
*
*
*
*
*
*
*
✖ async assertion fail (*ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
true !== false
*
*
*
*
*
*
* {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: true,
expected: false,
operator: 'strictEqual'
}
✖ reject fail (*ms)
Error: rejected from reject fail
*
*
*
*
*
*
*
✖ +sync throw fail (*ms)
Error: thrown from subtest sync throw fail
*
*
*
*
*
*
*
*
*
*
✖ subtest sync throw fail (*ms)
'1 subtest failed'
✖ sync throw non-error fail (*ms)
Symbol(thrown symbol from sync throw non-error fail)
✖ sync skip option is false fail (*ms)
Error: this should be executed
*
*
*
*
*
*
*
✖ callback fail (*ms)
Error: callback failure
*
*
✖ callback also returns a Promise (*ms)
'passed a callback but also returned a Promise'
✖ callback throw (*ms)
Error: thrown from callback throw
*
*
*
*
*
*
*
✖ callback called twice (*ms)
'callback invoked multiple times'
✖ callback called twice in future tick (*ms)
Error [ERR_TEST_FAILURE]: callback invoked multiple times
* {
code: 'ERR_TEST_FAILURE',
failureType: 'multipleCallbackInvocations',
cause: 'callback invoked multiple times'
}
✖ callback async throw (*ms)
Error: thrown from callback async throw
*
*
✖ custom inspect symbol fail (*ms)
customized
✖ custom inspect symbol that throws fail (*ms)
{ foo: 1, Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]] }
✖ sync throw fails at first (*ms)
Error: thrown from subtest sync throw fails at first
*
*
*
*
*
*
*
*
*
*
✖ sync throw fails at second (*ms)
Error: thrown from subtest sync throw fails at second
*
*
*
*
*
*
✖ subtest sync throw fails (*ms)
'2 subtests failed'
✖ timed out async test (*ms)
'test timed out after *ms'
✖ timed out callback test (*ms)
'test timed out after *ms'
✖ rejected thenable (*ms)
'custom error'
✖ unfinished test with uncaughtException (*ms)
Error: foo
*
*
*
✖ unfinished test with unhandledRejection (*ms)
Error: bar
*
*
*
✖ assertion errors display actual and expected properly (*ms)
AssertionError [ERR_ASSERTION]: Expected values to be loosely deep-equal:
{
bar: 1,
baz: {
date: 1970-01-01T00:00:00.000Z,
null: null,
number: 1,
string: 'Hello',
undefined: undefined
},
boo: [
1
],
foo: 1
}
should loosely deep-equal
{
baz: {
date: 1970-01-01T00:00:00.000Z,
null: null,
number: 1,
string: 'Hello',
undefined: undefined
},
boo: [
1
],
circular: <ref *1> {
bar: 2,
c: [Circular *1]
}
}
* {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: [Object],
expected: [Object],
operator: 'deepEqual'
}
✖ invalid subtest fail (*ms)
'test could not be started because its parent finished'

View File

@ -0,0 +1,10 @@
// Flags: --test-reporter=dot
'use strict';
eval(`
const { test } = require('node:test');
test('passes');
test('fails', () => {
throw new Error('fail');
});
`);

View File

@ -0,0 +1,13 @@
.X
Failed tests:
✖ fails (*ms)
Error: fail
*
*
*
*
*
*
*

View File

@ -0,0 +1,10 @@
// Flags: --test-reporter=spec
'use strict';
eval(`
const { test } = require('node:test');
test('passes');
test('fails', () => {
throw new Error('fail');
});
`);

View File

@ -0,0 +1,22 @@
✔ passes (*ms)
✖ fails (*ms)
ℹ tests 2
ℹ suites 0
ℹ pass 1
ℹ fail 1
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms *
✖ failing tests:
✖ fails (*ms)
Error: fail
*
*
*
*
*
*
*

View File

@ -0,0 +1,10 @@
// Flags: --test-reporter=tap
'use strict';
eval(`
const { test } = require('node:test');
test('passes');
test('fails', () => {
throw new Error('fail');
});
`);

View File

@ -0,0 +1,33 @@
TAP version 13
# Subtest: passes
ok 1 - passes
---
duration_ms: *
type: 'test'
...
# Subtest: fails
not ok 2 - fails
---
duration_ms: *
type: 'test'
failureType: 'testCodeFailure'
error: 'fail'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
...
1..2
# tests 2
# suites 0
# pass 1
# fail 1
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,16 @@
// Flags: --test-name-pattern=enabled
'use strict';
const common = require('../../../common');
const { suite, test } = require('node:test');
suite('async suite', async () => {
await 1;
test('enabled 1', common.mustCall());
await 1;
test('not run', common.mustNotCall());
await 1;
});
suite('sync suite', () => {
test('enabled 2', common.mustCall());
});

View File

@ -0,0 +1,36 @@
TAP version 13
# Subtest: async suite
# Subtest: enabled 1
ok 1 - enabled 1
---
duration_ms: *
type: 'test'
...
1..1
ok 1 - async suite
---
duration_ms: *
type: 'suite'
...
# Subtest: sync suite
# Subtest: enabled 2
ok 1 - enabled 2
---
duration_ms: *
type: 'test'
...
1..1
ok 2 - sync suite
---
duration_ms: *
type: 'suite'
...
1..2
# tests 2
# suites 2
# pass 2
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,49 @@
// Flags: --test-only
import { describe, test, after } from 'node:test';
after(() => { console.log('with global after()'); });
await Promise.resolve();
console.log('Execution order was:');
const ll = (t) => { console.log(` * ${t.fullName}`); };
describe('A', () => {
test.only('A', ll);
test('B', ll);
describe.only('C', () => {
test.only('A', ll);
test('B', ll);
});
describe('D', () => {
test.only('A', ll);
test('B', ll);
});
});
describe.only('B', () => {
test('A', ll);
test('B', ll);
describe('C', () => {
test('A', ll);
});
});
describe('C', () => {
test.only('A', ll);
test('B', ll);
describe.only('C', () => {
test('A', ll);
test('B', ll);
});
describe('D', () => {
test('A', ll);
test.only('B', ll);
});
});
describe('D', () => {
test('A', ll);
test.only('B', ll);
});
describe.only('E', () => {
test('A', ll);
test('B', ll);
});
test.only('F', ll);

View File

@ -0,0 +1,180 @@
Execution order was:
* A > A
* A > C > A
* A > D > A
* B > A
* B > B
* B > C > A
* C > A
* C > C > A
* C > C > B
* C > D > B
* D > B
* E > A
* E > B
* F
with global after()
TAP version 13
# Subtest: A
# Subtest: A
ok 1 - A
---
duration_ms: *
type: 'test'
...
# Subtest: C
# Subtest: A
ok 1 - A
---
duration_ms: *
type: 'test'
...
1..1
ok 2 - C
---
duration_ms: *
type: 'suite'
...
# Subtest: D
# Subtest: A
ok 1 - A
---
duration_ms: *
type: 'test'
...
1..1
ok 3 - D
---
duration_ms: *
type: 'suite'
...
1..3
ok 1 - A
---
duration_ms: *
type: 'suite'
...
# Subtest: B
# Subtest: A
ok 1 - A
---
duration_ms: *
type: 'test'
...
# Subtest: B
ok 2 - B
---
duration_ms: *
type: 'test'
...
# Subtest: C
# Subtest: A
ok 1 - A
---
duration_ms: *
type: 'test'
...
1..1
ok 3 - C
---
duration_ms: *
type: 'suite'
...
1..3
ok 2 - B
---
duration_ms: *
type: 'suite'
...
# Subtest: C
# Subtest: A
ok 1 - A
---
duration_ms: *
type: 'test'
...
# Subtest: C
# Subtest: A
ok 1 - A
---
duration_ms: *
type: 'test'
...
# Subtest: B
ok 2 - B
---
duration_ms: *
type: 'test'
...
1..2
ok 2 - C
---
duration_ms: *
type: 'suite'
...
# Subtest: D
# Subtest: B
ok 1 - B
---
duration_ms: *
type: 'test'
...
1..1
ok 3 - D
---
duration_ms: *
type: 'suite'
...
1..3
ok 3 - C
---
duration_ms: *
type: 'suite'
...
# Subtest: D
# Subtest: B
ok 1 - B
---
duration_ms: *
type: 'test'
...
1..1
ok 4 - D
---
duration_ms: *
type: 'suite'
...
# Subtest: E
# Subtest: A
ok 1 - A
---
duration_ms: *
type: 'test'
...
# Subtest: B
ok 2 - B
---
duration_ms: *
type: 'test'
...
1..2
ok 5 - E
---
duration_ms: *
type: 'suite'
...
# Subtest: F
ok 6 - F
---
duration_ms: *
type: 'test'
...
1..6
# tests 14
# suites 10
# pass 14
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,15 @@
// Flags: --test-name-pattern=enabled
'use strict';
const common = require('../../../common');
const { suite, test } = require('node:test');
suite('suite 1', () => {
throw new Error('boom 1');
// eslint-disable-next-line no-unreachable
test('enabled - should not run', common.mustNotCall());
});
suite('suite 2', () => {
test('enabled - should get cancelled', common.mustNotCall());
throw new Error('boom 1');
});

View File

@ -0,0 +1,63 @@
TAP version 13
# Subtest: suite 1
not ok 1 - suite 1
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/filtered-suite-throws.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'boom 1'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: suite 2
# Subtest: enabled - should get cancelled
not ok 1 - enabled - should get cancelled
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/filtered-suite-throws.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
1..1
not ok 2 - suite 2
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/filtered-suite-throws.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'boom 1'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
1..2
# tests 1
# suites 2
# pass 0
# fail 0
# cancelled 1
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,27 @@
// Flags: --test-force-exit --test-reporter=spec
'use strict';
const { after, afterEach, before, beforeEach, test } = require('node:test');
before(() => {
console.log('BEFORE');
});
beforeEach(() => {
console.log('BEFORE EACH');
});
after(() => {
console.log('AFTER');
});
afterEach(() => {
console.log('AFTER EACH');
});
test('passes but oops', () => {
setTimeout(() => {
throw new Error('this should not have a chance to be thrown');
}, 1000);
});
test('also passes');

View File

@ -0,0 +1,16 @@
BEFORE
BEFORE EACH
AFTER EACH
BEFORE EACH
AFTER EACH
AFTER
✔ passes but oops (*ms)
✔ also passes (*ms)
ℹ tests 2
ℹ suites 0
ℹ pass 2
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms *

View File

@ -0,0 +1,6 @@
'use strict';
const common = require('../../../common');
const { before, after } = require('node:test');
before(common.mustCall(() => console.log('before')));
after(common.mustCall(() => console.log('after')));

View File

@ -0,0 +1,12 @@
before
TAP version 13
after
1..0
# tests 0
# suites 0
# pass 0
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,10 @@
'use strict';
const { it, after } = require('node:test');
after(() => {
throw new Error('this should fail the test');
});
it('this is a test', () => {
console.log('this is a test');
});

View File

@ -0,0 +1,34 @@
this is a test
TAP version 13
# Subtest: this is a test
ok 1 - this is a test
---
duration_ms: *
type: 'test'
...
not ok 2 - /test/fixtures/test-runner/output/global_after_should_fail_the_test.js
---
duration_ms: *
location: '/test/fixtures/test-runner/output/global_after_should_fail_the_test.js:(LINE):1'
failureType: 'hookFailed'
error: 'this should fail the test'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,78 @@
'use strict';
const { test, describe, it, before, after, beforeEach, afterEach } = require('node:test');
const assert = require('assert');
// This file should not have any global tests to reproduce bug #48844
const testArr = [];
before(() => testArr.push('global before'));
after(() => {
testArr.push('global after');
assert.deepStrictEqual(testArr, [
'global before',
'describe before',
'describe beforeEach',
'describe it 1',
'describe afterEach',
'describe beforeEach',
'describe test 2',
'describe afterEach',
'describe nested before',
'describe beforeEach',
'describe nested beforeEach',
'describe nested it 1',
'describe nested afterEach',
'describe afterEach',
'describe beforeEach',
'describe nested beforeEach',
'describe nested test 2',
'describe nested afterEach',
'describe afterEach',
'describe nested after',
'describe after',
'global after',
]);
});
describe('describe hooks with no global tests', () => {
before(() => {
testArr.push('describe before');
});
after(() => {
testArr.push('describe after');
});
beforeEach(() => {
testArr.push('describe beforeEach');
});
afterEach(() => {
testArr.push('describe afterEach');
});
it('1', () => testArr.push('describe it 1'));
test('2', () => testArr.push('describe test 2'));
describe('nested', () => {
before(() => {
testArr.push('describe nested before');
});
after(() => {
testArr.push('describe nested after');
});
beforeEach(() => {
testArr.push('describe nested beforeEach');
});
afterEach(() => {
testArr.push('describe nested afterEach');
});
it('nested 1', () => testArr.push('describe nested it 1'));
test('nested 2', () => testArr.push('describe nested test 2'));
});
});

View File

@ -0,0 +1,48 @@
TAP version 13
# Subtest: describe hooks with no global tests
# Subtest: 1
ok 1 - 1
---
duration_ms: *
type: 'test'
...
# Subtest: 2
ok 2 - 2
---
duration_ms: *
type: 'test'
...
# Subtest: nested
# Subtest: nested 1
ok 1 - nested 1
---
duration_ms: *
type: 'test'
...
# Subtest: nested 2
ok 2 - nested 2
---
duration_ms: *
type: 'test'
...
1..2
ok 3 - nested
---
duration_ms: *
type: 'suite'
...
1..3
ok 1 - describe hooks with no global tests
---
duration_ms: *
type: 'suite'
...
1..1
# tests 4
# suites 2
# pass 4
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,307 @@
'use strict';
const common = require('../../../common');
const assert = require('assert');
const { test, describe, it, before, after, beforeEach, afterEach } = require('node:test');
const { setTimeout } = require('node:timers/promises');
before((t) => t.diagnostic('before 1 called'));
after((t) => t.diagnostic('after 1 called'));
describe('describe hooks', () => {
const testArr = [];
before(function() {
testArr.push('before ' + this.name);
});
after(common.mustCall(function() {
testArr.push('after ' + this.name);
assert.deepStrictEqual(testArr, [
'before describe hooks',
'beforeEach 1', '1', 'afterEach 1',
'beforeEach 2', '2', 'afterEach 2',
'before nested',
'beforeEach nested 1', '+beforeEach nested 1', 'nested 1', '+afterEach nested 1', 'afterEach nested 1',
'beforeEach nested 2', '+beforeEach nested 2', 'nested 2', '+afterEach nested 2', 'afterEach nested 2',
'after nested',
'after describe hooks',
]);
}));
beforeEach(function() {
testArr.push('beforeEach ' + this.name);
});
afterEach(function() {
testArr.push('afterEach ' + this.name);
});
it('1', () => testArr.push('1'));
test('2', () => testArr.push('2'));
describe('nested', () => {
before(function() {
testArr.push('before ' + this.name);
});
after(function() {
testArr.push('after ' + this.name);
});
beforeEach(function() {
testArr.push('+beforeEach ' + this.name);
});
afterEach(function() {
testArr.push('+afterEach ' + this.name);
});
it('nested 1', () => testArr.push('nested 1'));
test('nested 2', () => testArr.push('nested 2'));
});
});
describe('describe hooks - no subtests', () => {
const testArr = [];
before(function() {
testArr.push('before ' + this.name);
});
after(common.mustCall(function() {
testArr.push('after ' + this.name);
assert.deepStrictEqual(testArr, [
'before describe hooks - no subtests',
'after describe hooks - no subtests',
]);
}));
beforeEach(common.mustNotCall());
afterEach(common.mustNotCall());
});
describe('before throws', () => {
before(() => { throw new Error('before'); });
it('1', () => {});
test('2', () => {});
});
describe('before throws - no subtests', () => {
before(() => { throw new Error('before'); });
after(common.mustCall());
});
describe('after throws', () => {
after(() => { throw new Error('after'); });
it('1', () => {});
test('2', () => {});
});
describe('after throws - no subtests', () => {
after(() => { throw new Error('after'); });
});
describe('beforeEach throws', () => {
beforeEach(() => { throw new Error('beforeEach'); });
it('1', () => {});
test('2', () => {});
});
describe('afterEach throws', () => {
afterEach(() => { throw new Error('afterEach'); });
it('1', () => {});
test('2', () => {});
});
describe('afterEach when test fails', () => {
afterEach(common.mustCall(2));
it('1', () => { throw new Error('test'); });
test('2', () => {});
});
describe('afterEach throws and test fails', () => {
afterEach(() => { throw new Error('afterEach'); });
it('1', () => { throw new Error('test'); });
test('2', () => {});
});
test('test hooks', async (t) => {
const testArr = [];
t.before((t) => testArr.push('before ' + t.name));
t.after(common.mustCall((t) => testArr.push('after ' + t.name)));
t.beforeEach((t) => testArr.push('beforeEach ' + t.name));
t.afterEach((t) => testArr.push('afterEach ' + t.name));
await t.test('1', () => testArr.push('1'));
await t.test('2', () => testArr.push('2'));
await t.test('nested', async (t) => {
t.before((t) => testArr.push('nested before ' + t.name));
t.after((t) => testArr.push('nested after ' + t.name));
t.beforeEach((t) => testArr.push('nested beforeEach ' + t.name));
t.afterEach((t) => testArr.push('nested afterEach ' + t.name));
await t.test('nested 1', () => testArr.push('nested1'));
await t.test('nested 2', () => testArr.push('nested 2'));
});
t.after(common.mustCall(() => {
assert.deepStrictEqual(testArr, [
'before test hooks',
'beforeEach 1', '1', 'afterEach 1',
'beforeEach 2', '2', 'afterEach 2',
'beforeEach nested',
'nested before nested',
'beforeEach nested 1', 'nested beforeEach nested 1', 'nested1', 'nested afterEach nested 1', 'afterEach nested 1',
// eslint-disable-next-line @stylistic/js/max-len
'beforeEach nested 2', 'nested beforeEach nested 2', 'nested 2', 'nested afterEach nested 2', 'afterEach nested 2',
'afterEach nested',
'nested after nested',
'after test hooks',
]);
}));
});
test('test hooks - no subtests', async (t) => {
const testArr = [];
t.before((t) => testArr.push('before ' + t.name));
t.after(common.mustCall((t) => testArr.push('after ' + t.name)));
t.beforeEach(common.mustNotCall());
t.afterEach(common.mustNotCall());
t.after(common.mustCall(() => {
assert.deepStrictEqual(testArr, [
'before test hooks - no subtests',
'after test hooks - no subtests',
]);
}));
});
test('t.before throws', async (t) => {
t.after(common.mustCall());
t.before(() => { throw new Error('before'); });
await t.test('1', () => {});
await t.test('2', () => {});
});
test('t.before throws - no subtests', async (t) => {
t.after(common.mustCall());
t.before(() => { throw new Error('before'); });
});
test('t.after throws', async (t) => {
t.before(common.mustCall());
t.after(() => { throw new Error('after'); });
await t.test('1', () => {});
await t.test('2', () => {});
});
test('t.after throws - no subtests', async (t) => {
t.before(common.mustCall());
t.after(() => { throw new Error('after'); });
});
test('t.beforeEach throws', async (t) => {
t.after(common.mustCall());
t.beforeEach(() => { throw new Error('beforeEach'); });
await t.test('1', () => {});
await t.test('2', () => {});
});
test('t.afterEach throws', async (t) => {
t.after(common.mustCall());
t.afterEach(() => { throw new Error('afterEach'); });
await t.test('1', () => {});
await t.test('2', () => {});
});
test('afterEach when test fails', async (t) => {
t.after(common.mustCall());
t.afterEach(common.mustCall(2));
await t.test('1', () => { throw new Error('test'); });
await t.test('2', () => {});
});
test('afterEach context when test passes', async (t) => {
t.afterEach(common.mustCall((ctx) => {
assert.strictEqual(ctx.name, '1');
assert.strictEqual(ctx.passed, true);
assert.strictEqual(ctx.error, null);
}));
await t.test('1', () => {});
});
test('afterEach context when test fails', async (t) => {
const err = new Error('test');
t.afterEach(common.mustCall((ctx) => {
assert.strictEqual(ctx.name, '1');
assert.strictEqual(ctx.passed, false);
assert.strictEqual(ctx.error, err);
}));
await t.test('1', () => { throw err; });
});
test('afterEach throws and test fails', async (t) => {
t.after(common.mustCall());
t.afterEach(() => { throw new Error('afterEach'); });
await t.test('1', () => { throw new Error('test'); });
await t.test('2', () => {});
});
test('t.after() is called if test body throws', (t) => {
t.after(() => {
t.diagnostic('- after() called');
});
throw new Error('bye');
});
describe('run after when before throws', () => {
after(common.mustCall(() => {
console.log('- after() called');
}));
before(() => { throw new Error('before'); });
it('1', () => {});
});
test('test hooks - async', async (t) => {
const testArr = [];
t.before(async (t) => {
testArr.push('before starting ' + t.name);
await setTimeout(10);
testArr.push('before ending ' + t.name);
});
t.after(async (t) => {
testArr.push('after starting ' + t.name);
await setTimeout(10);
testArr.push('after ending ' + t.name);
});
t.beforeEach(async (t) => {
testArr.push('beforeEach starting ' + t.name);
await setTimeout(10);
testArr.push('beforeEach ending ' + t.name);
});
t.afterEach(async (t) => {
testArr.push('afterEach starting ' + t.name);
await setTimeout(10);
testArr.push('afterEach ending ' + t.name);
});
await t.test('1', async () => {
testArr.push('1 starting');
await setTimeout(10);
testArr.push('1 ending');
});
await t.test('2', async () => {
testArr.push('2 starting');
await setTimeout(10);
testArr.push('2 ending');
});
t.after(common.mustCall(() => {
assert.deepStrictEqual(testArr, [
'before starting test hooks - async', 'before ending test hooks - async',
'beforeEach starting 1', 'beforeEach ending 1',
'1 starting', '1 ending',
'afterEach starting 1', 'afterEach ending 1',
'beforeEach starting 2', 'beforeEach ending 2',
'2 starting', '2 ending',
'afterEach starting 2', 'afterEach ending 2',
'after starting test hooks - async', 'after ending test hooks - async',
]);
}));
});
before((t) => t.diagnostic('before 2 called'));
after((t) => t.diagnostic('after 2 called'));

View File

@ -0,0 +1,844 @@
- after() called
TAP version 13
# Subtest: describe hooks
# Subtest: 1
ok 1 - 1
---
duration_ms: *
type: 'test'
...
# Subtest: 2
ok 2 - 2
---
duration_ms: *
type: 'test'
...
# Subtest: nested
# Subtest: nested 1
ok 1 - nested 1
---
duration_ms: *
type: 'test'
...
# Subtest: nested 2
ok 2 - nested 2
---
duration_ms: *
type: 'test'
...
1..2
ok 3 - nested
---
duration_ms: *
type: 'suite'
...
1..3
ok 1 - describe hooks
---
duration_ms: *
type: 'suite'
...
# Subtest: describe hooks - no subtests
ok 2 - describe hooks - no subtests
---
duration_ms: *
type: 'suite'
...
# Subtest: before throws
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
# Subtest: 2
not ok 2 - 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
1..2
not ok 3 - before throws
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'hookFailed'
error: 'before'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
...
# Subtest: before throws - no subtests
not ok 4 - before throws - no subtests
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'hookFailed'
error: 'before'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
...
# Subtest: after throws
# Subtest: 1
ok 1 - 1
---
duration_ms: *
type: 'test'
...
# Subtest: 2
ok 2 - 2
---
duration_ms: *
type: 'test'
...
1..2
not ok 5 - after throws
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'hookFailed'
error: 'after'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: after throws - no subtests
not ok 6 - after throws - no subtests
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'hookFailed'
error: 'after'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: beforeEach throws
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'hookFailed'
error: 'beforeEach'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
new Promise (<anonymous>)
...
# Subtest: 2
not ok 2 - 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'hookFailed'
error: 'beforeEach'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
async Promise.all (index 0)
...
1..2
not ok 7 - beforeEach throws
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: afterEach throws
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'hookFailed'
error: 'afterEach'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
async Promise.all (index 0)
*
...
# Subtest: 2
not ok 2 - 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'hookFailed'
error: 'afterEach'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
...
1..2
not ok 8 - afterEach throws
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: afterEach when test fails
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'testCodeFailure'
error: 'test'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
new Promise (<anonymous>)
*
*
Array.map (<anonymous>)
...
# Subtest: 2
ok 2 - 2
---
duration_ms: *
type: 'test'
...
1..2
not ok 9 - afterEach when test fails
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '1 subtest failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: afterEach throws and test fails
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'testCodeFailure'
error: 'test'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
new Promise (<anonymous>)
*
*
Array.map (<anonymous>)
...
# Subtest: 2
not ok 2 - 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'hookFailed'
error: 'afterEach'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
...
1..2
not ok 10 - afterEach throws and test fails
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: test hooks
# Subtest: 1
ok 1 - 1
---
duration_ms: *
type: 'test'
...
# Subtest: 2
ok 2 - 2
---
duration_ms: *
type: 'test'
...
# Subtest: nested
# Subtest: nested 1
ok 1 - nested 1
---
duration_ms: *
type: 'test'
...
# Subtest: nested 2
ok 2 - nested 2
---
duration_ms: *
type: 'test'
...
1..2
ok 3 - nested
---
duration_ms: *
type: 'test'
...
1..3
ok 11 - test hooks
---
duration_ms: *
type: 'test'
...
# Subtest: test hooks - no subtests
ok 12 - test hooks - no subtests
---
duration_ms: *
type: 'test'
...
# Subtest: t.before throws
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):11'
failureType: 'hookFailed'
error: 'before'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: 2
not ok 2 - 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):11'
failureType: 'hookFailed'
error: 'before'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
1..2
not ok 13 - t.before throws
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'before'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: t.before throws - no subtests
not ok 14 - t.before throws - no subtests
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'before'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: t.after throws
# Subtest: 1
ok 1 - 1
---
duration_ms: *
type: 'test'
...
# Subtest: 2
ok 2 - 2
---
duration_ms: *
type: 'test'
...
1..2
not ok 15 - t.after throws
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'hookFailed'
error: 'after'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
...
# Subtest: t.after throws - no subtests
not ok 16 - t.after throws - no subtests
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'hookFailed'
error: 'after'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
...
# Subtest: t.beforeEach throws
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):11'
failureType: 'hookFailed'
error: 'beforeEach'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
# Subtest: 2
not ok 2 - 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):11'
failureType: 'hookFailed'
error: 'beforeEach'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
...
1..2
not ok 17 - t.beforeEach throws
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: t.afterEach throws
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):11'
failureType: 'hookFailed'
error: 'afterEach'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
...
# Subtest: 2
not ok 2 - 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):11'
failureType: 'hookFailed'
error: 'afterEach'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
...
1..2
not ok 18 - t.afterEach throws
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: afterEach when test fails
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):11'
failureType: 'testCodeFailure'
error: 'test'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
...
# Subtest: 2
ok 2 - 2
---
duration_ms: *
type: 'test'
...
1..2
not ok 19 - afterEach when test fails
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '1 subtest failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: afterEach context when test passes
# Subtest: 1
ok 1 - 1
---
duration_ms: *
type: 'test'
...
1..1
ok 20 - afterEach context when test passes
---
duration_ms: *
type: 'test'
...
# Subtest: afterEach context when test fails
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):11'
failureType: 'testCodeFailure'
error: 'test'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
...
1..1
not ok 21 - afterEach context when test fails
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '1 subtest failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: afterEach throws and test fails
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):11'
failureType: 'testCodeFailure'
error: 'test'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
...
# Subtest: 2
not ok 2 - 2
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):11'
failureType: 'hookFailed'
error: 'afterEach'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
...
1..2
not ok 22 - afterEach throws and test fails
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: t.after() is called if test body throws
not ok 23 - t.after() is called if test body throws
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'testCodeFailure'
error: 'bye'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
...
# - after() called
# Subtest: run after when before throws
# Subtest: 1
not ok 1 - 1
---
duration_ms: *
type: 'test'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
1..1
not ok 24 - run after when before throws
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):1'
failureType: 'hookFailed'
error: 'before'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
...
# Subtest: test hooks - async
# Subtest: 1
ok 1 - 1
---
duration_ms: *
type: 'test'
...
# Subtest: 2
ok 2 - 2
---
duration_ms: *
type: 'test'
...
1..2
ok 25 - test hooks - async
---
duration_ms: *
type: 'test'
...
1..25
# before 1 called
# before 2 called
# after 1 called
# after 2 called
# tests 52
# suites 12
# pass 22
# fail 27
# cancelled 3
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,11 @@
'use strict';
require('../../../common');
const fixtures = require('../../../common/fixtures');
const spawn = require('node:child_process').spawn;
const child = spawn(process.execPath,
['--no-warnings', '--test-reporter', 'spec', fixtures.path('test-runner/output/hooks.js')],
{ stdio: 'pipe' });
// eslint-disable-next-line no-control-regex
child.stdout.on('data', (d) => process.stdout.write(d.toString().replace(/[^\x00-\x7F]/g, '').replace(/\u001b\[\d+m/g, '')));
child.stderr.pipe(process.stderr);

View File

@ -0,0 +1,461 @@
- after() called
describe hooks
1 (*ms)
2 (*ms)
nested
nested 1 (*ms)
nested 2 (*ms)
nested (*ms)
describe hooks (*ms)
describe hooks - no subtests (*ms)
before throws
1
2
before throws (*ms)
before throws - no subtests (*ms)
after throws
1 (*ms)
2 (*ms)
after throws (*ms)
after throws - no subtests (*ms)
beforeEach throws
1 (*ms)
2 (*ms)
beforeEach throws (*ms)
afterEach throws
1 (*ms)
2 (*ms)
afterEach throws (*ms)
afterEach when test fails
1 (*ms)
2 (*ms)
afterEach when test fails (*ms)
afterEach throws and test fails
1 (*ms)
2 (*ms)
afterEach throws and test fails (*ms)
test hooks
1 (*ms)
2 (*ms)
nested
nested 1 (*ms)
nested 2 (*ms)
nested (*ms)
test hooks (*ms)
test hooks - no subtests (*ms)
t.before throws
1 (*ms)
2 (*ms)
t.before throws (*ms)
t.before throws - no subtests (*ms)
t.after throws
1 (*ms)
2 (*ms)
t.after throws (*ms)
t.after throws - no subtests (*ms)
t.beforeEach throws
1 (*ms)
2 (*ms)
t.beforeEach throws (*ms)
t.afterEach throws
1 (*ms)
2 (*ms)
t.afterEach throws (*ms)
afterEach when test fails
1 (*ms)
2 (*ms)
afterEach when test fails (*ms)
afterEach context when test passes
1 (*ms)
afterEach context when test passes (*ms)
afterEach context when test fails
1 (*ms)
afterEach context when test fails (*ms)
afterEach throws and test fails
1 (*ms)
2 (*ms)
afterEach throws and test fails (*ms)
t.after() is called if test body throws (*ms)
- after() called
run after when before throws
1
run after when before throws (*ms)
test hooks - async
1 (*ms)
2 (*ms)
test hooks - async (*ms)
before 1 called
before 2 called
after 1 called
after 2 called
tests 52
suites 12
pass 22
fail 27
cancelled 3
skipped 0
todo 0
duration_ms *
failing tests:
*
1
'test did not finish before its parent and was cancelled'
*
2
'test did not finish before its parent and was cancelled'
*
before throws (*ms)
Error: before
*
*
*
*
*
*
*
*
*
before throws - no subtests (*ms)
Error: before
*
*
*
*
*
*
*
*
*
after throws (*ms)
Error: after
*
*
*
*
*
*
*
*
*
*
*
after throws - no subtests (*ms)
Error: after
*
*
*
*
*
*
*
*
*
*
*
1 (*ms)
Error: beforeEach
*
*
*
*
*
*
*
*
*
at new Promise (<anonymous>)
*
2 (*ms)
Error: beforeEach
*
*
*
*
*
*
*
*
*
at async Promise.all (index 0)
*
1 (*ms)
Error: afterEach
*
*
*
*
*
*
*
*
at async Promise.all (index 0)
*
*
2 (*ms)
Error: afterEach
*
*
*
*
*
*
*
*
*
*
1 (*ms)
Error: test
*
*
*
*
*
*
at new Promise (<anonymous>)
*
*
at Array.map (<anonymous>)
*
1 (*ms)
Error: test
*
*
*
*
*
*
at new Promise (<anonymous>)
*
*
at Array.map (<anonymous>)
*
2 (*ms)
Error: afterEach
*
*
*
*
*
*
*
*
*
*
1 (*ms)
Error: before
*
*
*
*
*
*
*
*
*
*
*
2 (*ms)
Error: before
*
*
*
*
*
*
*
*
*
*
*
t.before throws (*ms)
Error: before
*
*
*
*
*
*
*
*
*
*
*
t.before throws - no subtests (*ms)
Error: before
*
*
*
*
*
*
*
*
*
*
*
t.after throws (*ms)
Error: after
*
*
*
*
*
*
*
*
*
*
t.after throws - no subtests (*ms)
Error: after
*
*
*
*
*
*
*
*
*
*
1 (*ms)
Error: beforeEach
*
*
*
*
*
*
*
*
*
*
*
2 (*ms)
Error: beforeEach
*
*
*
*
*
*
*
*
*
*
1 (*ms)
Error: afterEach
*
*
*
*
*
*
*
*
*
2 (*ms)
Error: afterEach
*
*
*
*
*
*
*
*
*
*
1 (*ms)
Error: test
*
*
*
*
*
*
*
*
*
*
1 (*ms)
Error: test
*
*
*
*
*
1 (*ms)
Error: test
*
*
*
*
*
*
*
*
*
*
2 (*ms)
Error: afterEach
*
*
*
*
*
*
*
*
*
*
t.after() is called if test body throws (*ms)
Error: bye
*
*
*
*
*
1
'test did not finish before its parent and was cancelled'
*
run after when before throws (*ms)
Error: before
*
*
*
*
*
*
*
*

View File

@ -0,0 +1,11 @@
'use strict';
require('../../../common');
const fixtures = require('../../../common/fixtures');
const spawn = require('node:child_process').spawn;
spawn(process.execPath,
[
'--no-warnings', '--test-reporter', 'junit',
fixtures.path('test-runner/output/output.js'),
],
{ stdio: 'inherit' });

View File

@ -0,0 +1,521 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testcase name="sync pass todo" time="*" classname="test">
<skipped type="todo" message="true"/>
</testcase>
<testcase name="sync pass todo with message" time="*" classname="test">
<skipped type="todo" message="this is a passing todo"/>
</testcase>
<testcase name="sync fail todo" time="*" classname="test" failure="thrown from sync fail todo">
<skipped type="todo" message="true"/>
<failure type="testCodeFailure" message="thrown from sync fail todo">
[Error [ERR_TEST_FAILURE]: thrown from sync fail todo] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: thrown from sync fail todo
*
*
*
*
*
*
*
}
</failure>
</testcase>
<testcase name="sync fail todo with message" time="*" classname="test" failure="thrown from sync fail todo with message">
<skipped type="todo" message="this is a failing todo"/>
<failure type="testCodeFailure" message="thrown from sync fail todo with message">
[Error [ERR_TEST_FAILURE]: thrown from sync fail todo with message] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: thrown from sync fail todo with message
*
*
*
*
*
*
*
}
</failure>
</testcase>
<testcase name="sync skip pass" time="*" classname="test">
<skipped type="skipped" message="true"/>
</testcase>
<testcase name="sync skip pass with message" time="*" classname="test">
<skipped type="skipped" message="this is skipped"/>
</testcase>
<testcase name="sync pass" time="*" classname="test"/>
<!-- this test should pass -->
<testcase name="sync throw fail" time="*" classname="test" failure="thrown from sync throw fail">
<failure type="testCodeFailure" message="thrown from sync throw fail">
[Error [ERR_TEST_FAILURE]: thrown from sync throw fail] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: thrown from sync throw fail
*
*
*
*
*
*
*
}
</failure>
</testcase>
<testcase name="async skip pass" time="*" classname="test">
<skipped type="skipped" message="true"/>
</testcase>
<testcase name="async pass" time="*" classname="test"/>
<testcase name="async throw fail" time="*" classname="test" failure="thrown from async throw fail">
<failure type="testCodeFailure" message="thrown from async throw fail">
[Error [ERR_TEST_FAILURE]: thrown from async throw fail] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: thrown from async throw fail
*
*
*
*
*
*
*
}
</failure>
</testcase>
<testcase name="async skip fail" time="*" classname="test" failure="thrown from async throw fail">
<skipped type="skipped" message="true"/>
<failure type="testCodeFailure" message="thrown from async throw fail">
[Error [ERR_TEST_FAILURE]: thrown from async throw fail] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: thrown from async throw fail
*
*
*
*
*
*
*
}
</failure>
</testcase>
<testcase name="async assertion fail" time="*" classname="test" failure="Expected values to be strictly equal:true !== false">
<failure type="testCodeFailure" message="Expected values to be strictly equal:true !== false">
[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal:
true !== false
] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
true !== false
*
*
*
*
*
*
* {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: true,
expected: false,
operator: 'strictEqual'
}
}
</failure>
</testcase>
<testcase name="resolve pass" time="*" classname="test"/>
<testcase name="reject fail" time="*" classname="test" failure="rejected from reject fail">
<failure type="testCodeFailure" message="rejected from reject fail">
[Error [ERR_TEST_FAILURE]: rejected from reject fail] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: rejected from reject fail
*
*
*
*
*
*
*
}
</failure>
</testcase>
<testcase name="unhandled rejection - passes but warns" time="*" classname="test"/>
<testcase name="async unhandled rejection - passes but warns" time="*" classname="test"/>
<testcase name="immediate throw - passes but warns" time="*" classname="test"/>
<testcase name="immediate reject - passes but warns" time="*" classname="test"/>
<testcase name="immediate resolve pass" time="*" classname="test"/>
<testsuite name="subtest sync throw fail" time="*" disabled="0" errors="0" tests="1" failures="1" skipped="0" hostname="HOSTNAME">
<testcase name="+sync throw fail" time="*" classname="test" failure="thrown from subtest sync throw fail">
<failure type="testCodeFailure" message="thrown from subtest sync throw fail">
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
*
* {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: thrown from subtest sync throw fail
*
*
*
*
*
*
*
*
*
*
}
</failure>
</testcase>
<!-- this subtest should make its parent test fail -->
</testsuite>
<testcase name="sync throw non-error fail" time="*" classname="test" failure="Symbol(thrown symbol from sync throw non-error fail)">
<failure type="testCodeFailure" message="Symbol(thrown symbol from sync throw non-error fail)">
[Error [ERR_TEST_FAILURE]: Symbol(thrown symbol from sync throw non-error fail)] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: Symbol(thrown symbol from sync throw non-error fail) }
</failure>
</testcase>
<testsuite name="level 0a" time="*" disabled="0" errors="0" tests="4" failures="0" skipped="0" hostname="HOSTNAME">
<testcase name="level 1a" time="*" classname="test"/>
<testcase name="level 1b" time="*" classname="test"/>
<testcase name="level 1c" time="*" classname="test"/>
<testcase name="level 1d" time="*" classname="test"/>
</testsuite>
<testsuite name="top level" time="*" disabled="0" errors="0" tests="2" failures="0" skipped="0" hostname="HOSTNAME">
<testcase name="+long running" time="*" classname="test"/>
<testsuite name="+short running" time="*" disabled="0" errors="0" tests="1" failures="0" skipped="0" hostname="HOSTNAME">
<testcase name="++short running" time="*" classname="test"/>
</testsuite>
</testsuite>
<testcase name="invalid subtest - pass but subtest fails" time="*" classname="test"/>
<testcase name="sync skip option" time="*" classname="test">
<skipped type="skipped" message="true"/>
</testcase>
<testcase name="sync skip option with message" time="*" classname="test">
<skipped type="skipped" message="this is skipped"/>
</testcase>
<testcase name="sync skip option is false fail" time="*" classname="test" failure="this should be executed">
<failure type="testCodeFailure" message="this should be executed">
[Error [ERR_TEST_FAILURE]: this should be executed] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: this should be executed
*
*
*
*
*
*
*
}
</failure>
</testcase>
<testcase name="&lt;anonymous>" time="*" classname="test"/>
<testcase name="functionOnly" time="*" classname="test"/>
<testcase name="&lt;anonymous>" time="*" classname="test"/>
<testcase name="test with only a name provided" time="*" classname="test"/>
<testcase name="&lt;anonymous>" time="*" classname="test"/>
<testcase name="&lt;anonymous>" time="*" classname="test">
<skipped type="skipped" message="true"/>
</testcase>
<testcase name="test with a name and options provided" time="*" classname="test">
<skipped type="skipped" message="true"/>
</testcase>
<testcase name="functionAndOptions" time="*" classname="test">
<skipped type="skipped" message="true"/>
</testcase>
<testcase name="callback pass" time="*" classname="test"/>
<testcase name="callback fail" time="*" classname="test" failure="callback failure">
<failure type="testCodeFailure" message="callback failure">
[Error [ERR_TEST_FAILURE]: callback failure] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: callback failure
*
*
}
</failure>
</testcase>
<testcase name="sync t is this in test" time="*" classname="test"/>
<testcase name="async t is this in test" time="*" classname="test"/>
<testcase name="callback t is this in test" time="*" classname="test"/>
<testcase name="callback also returns a Promise" time="*" classname="test" failure="passed a callback but also returned a Promise">
<failure type="callbackAndPromisePresent" message="passed a callback but also returned a Promise">
[Error [ERR_TEST_FAILURE]: passed a callback but also returned a Promise] { code: 'ERR_TEST_FAILURE', failureType: 'callbackAndPromisePresent', cause: 'passed a callback but also returned a Promise' }
</failure>
</testcase>
<testcase name="callback throw" time="*" classname="test" failure="thrown from callback throw">
<failure type="testCodeFailure" message="thrown from callback throw">
[Error [ERR_TEST_FAILURE]: thrown from callback throw] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: thrown from callback throw
*
*
*
*
*
*
*
}
</failure>
</testcase>
<testcase name="callback called twice" time="*" classname="test" failure="callback invoked multiple times">
<failure type="multipleCallbackInvocations" message="callback invoked multiple times">
Error [ERR_TEST_FAILURE]: callback invoked multiple times
*
* {
code: 'ERR_TEST_FAILURE',
failureType: 'multipleCallbackInvocations',
cause: 'callback invoked multiple times'
}
</failure>
</testcase>
<testcase name="callback called twice in different ticks" time="*" classname="test"/>
<testcase name="callback called twice in future tick" time="*" classname="test" failure="callback invoked multiple times">
<failure type="uncaughtException" message="callback invoked multiple times">
Error [ERR_TEST_FAILURE]: callback invoked multiple times
* {
code: 'ERR_TEST_FAILURE',
failureType: 'uncaughtException',
cause: Error [ERR_TEST_FAILURE]: callback invoked multiple times
* {
code: 'ERR_TEST_FAILURE',
failureType: 'multipleCallbackInvocations',
cause: 'callback invoked multiple times'
}
}
</failure>
</testcase>
<testcase name="callback async throw" time="*" classname="test" failure="thrown from callback async throw">
<failure type="uncaughtException" message="thrown from callback async throw">
Error [ERR_TEST_FAILURE]: thrown from callback async throw
* {
code: 'ERR_TEST_FAILURE',
failureType: 'uncaughtException',
cause: Error: thrown from callback async throw
*
*
}
</failure>
</testcase>
<testcase name="callback async throw after done" time="*" classname="test"/>
<testsuite name="only is set on subtests but not in only mode" time="*" disabled="0" errors="0" tests="3" failures="0" skipped="0" hostname="HOSTNAME">
<testcase name="running subtest 1" time="*" classname="test"/>
<testcase name="running subtest 3" time="*" classname="test"/>
<testcase name="running subtest 4" time="*" classname="test"/>
</testsuite>
<testcase name="custom inspect symbol fail" time="*" classname="test" failure="customized">
<failure type="testCodeFailure" message="customized">
[Error [ERR_TEST_FAILURE]: customized] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: customized }
</failure>
</testcase>
<testcase name="custom inspect symbol that throws fail" time="*" classname="test" failure="{ foo: 1, Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]]}">
<failure type="testCodeFailure" message="{ foo: 1, Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]]}">
[Error [ERR_TEST_FAILURE]: {
foo: 1,
Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]]
}] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: { foo: 1, Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]] }
}
</failure>
</testcase>
<testsuite name="subtest sync throw fails" time="*" disabled="0" errors="0" tests="2" failures="2" skipped="0" hostname="HOSTNAME">
<testcase name="sync throw fails at first" time="*" classname="test" failure="thrown from subtest sync throw fails at first">
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at first">
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
*
* {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: thrown from subtest sync throw fails at first
*
*
*
*
*
*
*
*
*
*
}
</failure>
</testcase>
<testcase name="sync throw fails at second" time="*" classname="test" failure="thrown from subtest sync throw fails at second">
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at second">
[Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: Error: thrown from subtest sync throw fails at second
*
*
*
*
*
*
}
</failure>
</testcase>
</testsuite>
<testcase name="timed out async test" time="*" classname="test" failure="test timed out after 5ms">
<failure type="testTimeoutFailure" message="test timed out after 5ms">
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms' }
</failure>
</testcase>
<testcase name="timed out callback test" time="*" classname="test" failure="test timed out after 5ms">
<failure type="testTimeoutFailure" message="test timed out after 5ms">
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms' }
</failure>
</testcase>
<testcase name="large timeout async test is ok" time="*" classname="test"/>
<testcase name="large timeout callback test is ok" time="*" classname="test"/>
<testcase name="successful thenable" time="*" classname="test"/>
<testcase name="rejected thenable" time="*" classname="test" failure="custom error">
<failure type="testCodeFailure" message="custom error">
[Error [ERR_TEST_FAILURE]: custom error] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: 'custom error' }
</failure>
</testcase>
<testcase name="unfinished test with uncaughtException" time="*" classname="test" failure="foo">
<failure type="uncaughtException" message="foo">
Error [ERR_TEST_FAILURE]: foo
* {
code: 'ERR_TEST_FAILURE',
failureType: 'uncaughtException',
cause: Error: foo
*
*
*
}
</failure>
</testcase>
<testcase name="unfinished test with unhandledRejection" time="*" classname="test" failure="bar">
<failure type="unhandledRejection" message="bar">
Error [ERR_TEST_FAILURE]: bar
* {
code: 'ERR_TEST_FAILURE',
failureType: 'unhandledRejection',
cause: Error: bar
*
*
*
}
</failure>
</testcase>
<testcase name="assertion errors display actual and expected properly" time="*" classname="test" failure="Expected values to be loosely deep-equal:{ bar: 1, baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], foo: 1}should loosely deep-equal{ baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], circular: &lt;ref *1> { bar: 2, c: [Circular *1] }}">
<failure type="testCodeFailure" message="Expected values to be loosely deep-equal:{ bar: 1, baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], foo: 1}should loosely deep-equal{ baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], circular: &lt;ref *1> { bar: 2, c: [Circular *1] }}">
[Error [ERR_TEST_FAILURE]: Expected values to be loosely deep-equal:
{
bar: 1,
baz: {
date: 1970-01-01T00:00:00.000Z,
null: null,
number: 1,
string: 'Hello',
undefined: undefined
},
boo: [
1
],
foo: 1
}
should loosely deep-equal
{
baz: {
date: 1970-01-01T00:00:00.000Z,
null: null,
number: 1,
string: 'Hello',
undefined: undefined
},
boo: [
1
],
circular: &lt;ref *1> {
bar: 2,
c: [Circular *1]
}
}] {
code: 'ERR_TEST_FAILURE',
failureType: 'testCodeFailure',
cause: AssertionError [ERR_ASSERTION]: Expected values to be loosely deep-equal:
{
bar: 1,
baz: {
date: 1970-01-01T00:00:00.000Z,
null: null,
number: 1,
string: 'Hello',
undefined: undefined
},
boo: [
1
],
foo: 1
}
should loosely deep-equal
{
baz: {
date: 1970-01-01T00:00:00.000Z,
null: null,
number: 1,
string: 'Hello',
undefined: undefined
},
boo: [
1
],
circular: &lt;ref *1> {
bar: 2,
c: [Circular *1]
}
}
* {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: [Object],
expected: [Object],
operator: 'deepEqual'
}
}
</failure>
</testcase>
<testcase name="invalid subtest fail" time="*" classname="test" failure="test could not be started because its parent finished">
<failure type="parentAlreadyFinished" message="test could not be started because its parent finished">
Error [ERR_TEST_FAILURE]: test could not be started because its parent finished
* {
code: 'ERR_TEST_FAILURE',
failureType: 'parentAlreadyFinished',
cause: 'test could not be started because its parent finished'
}
</failure>
</testcase>
<!-- Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:72:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. -->
<!-- Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:76:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. -->
<!-- Error: A resource generated asynchronous activity after the test ended. This activity created the error "Error: uncaught from outside of a test" which triggered an uncaughtException event, caught by the test runner. -->
<!-- Error: Test "immediate throw - passes but warns" at test/fixtures/test-runner/output/output.js:80:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event. -->
<!-- Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:86:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. -->
<!-- Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:251:1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. -->
<!-- Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:269:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. -->
<!-- tests 75 -->
<!-- suites 0 -->
<!-- pass 36 -->
<!-- fail 24 -->
<!-- cancelled 2 -->
<!-- skipped 9 -->
<!-- todo 4 -->
<!-- duration_ms * -->
</testsuites>

View File

@ -0,0 +1,16 @@
'use strict';
require('../../../common');
const fixtures = require('../../../common/fixtures');
const spawn = require('node:child_process').spawn;
spawn(process.execPath,
[
'--no-warnings',
'--experimental-test-coverage',
'--test-coverage-exclude=!test/**',
'--test-reporter',
'lcov',
fixtures.path('test-runner/output/output.js'),
],
{ stdio: 'inherit' },
);

View File

@ -0,0 +1,720 @@
TN:
SF:test/fixtures/test-runner/output/output.js
FN:8,anonymous_0
FN:12,anonymous_1
FN:16,anonymous_2
FN:21,anonymous_3
FN:26,anonymous_4
FN:30,anonymous_5
FN:34,anonymous_6
FN:38,anonymous_7
FN:42,anonymous_8
FN:46,anonymous_9
FN:50,anonymous_10
FN:54,anonymous_11
FN:59,anonymous_12
FN:64,anonymous_13
FN:68,anonymous_14
FN:72,anonymous_15
FN:76,anonymous_16
FN:80,anonymous_17
FN:81,anonymous_18
FN:86,anonymous_19
FN:87,anonymous_20
FN:92,anonymous_21
FN:93,anonymous_22
FN:94,anonymous_23
FN:100,anonymous_24
FN:101,anonymous_25
FN:107,anonymous_26
FN:111,anonymous_27
FN:112,anonymous_28
FN:113,anonymous_29
FN:114,anonymous_30
FN:122,anonymous_31
FN:123,anonymous_32
FN:130,anonymous_33
FN:131,anonymous_34
FN:132,anonymous_35
FN:140,anonymous_36
FN:141,anonymous_37
FN:142,anonymous_38
FN:150,anonymous_39
FN:151,anonymous_40
FN:159,anonymous_41
FN:160,anonymous_42
FN:161,anonymous_43
FN:166,anonymous_44
FN:167,anonymous_45
FN:171,anonymous_46
FN:172,anonymous_47
FN:173,anonymous_48
FN:179,anonymous_49
FN:183,anonymous_50
FN:187,anonymous_51
FN:195,functionOnly
FN:198,anonymous_53
FN:213,functionAndOptions
FN:215,anonymous_55
FN:219,anonymous_56
FN:220,anonymous_57
FN:225,anonymous_58
FN:229,anonymous_59
FN:233,anonymous_60
FN:238,anonymous_61
FN:242,anonymous_62
FN:246,anonymous_63
FN:251,anonymous_64
FN:256,anonymous_65
FN:257,anonymous_66
FN:263,anonymous_67
FN:264,anonymous_68
FN:269,anonymous_69
FN:270,anonymous_70
FN:277,anonymous_71
FN:287,anonymous_72
FN:289,obj
FN:298,anonymous_74
FN:300,obj
FN:309,anonymous_76
FN:310,anonymous_77
FN:313,anonymous_78
FN:318,anonymous_79
FN:319,anonymous_80
FN:320,anonymous_81
FN:327,anonymous_82
FN:328,anonymous_83
FN:335,anonymous_84
FN:336,anonymous_85
FN:341,anonymous_86
FN:345,anonymous_87
FN:348,get then
FN:351,anonymous_89
FN:356,anonymous_90
FN:359,get then
FN:362,anonymous_92
FN:367,anonymous_93
FN:368,anonymous_94
FN:369,anonymous_95
FN:373,anonymous_96
FN:374,anonymous_97
FN:375,anonymous_98
FN:381,anonymous_99
FN:385,anonymous_100
FNDA:1,anonymous_0
FNDA:1,anonymous_1
FNDA:1,anonymous_2
FNDA:1,anonymous_3
FNDA:1,anonymous_4
FNDA:1,anonymous_5
FNDA:1,anonymous_6
FNDA:1,anonymous_7
FNDA:1,anonymous_8
FNDA:1,anonymous_9
FNDA:1,anonymous_10
FNDA:1,anonymous_11
FNDA:1,anonymous_12
FNDA:1,anonymous_13
FNDA:1,anonymous_14
FNDA:1,anonymous_15
FNDA:1,anonymous_16
FNDA:1,anonymous_17
FNDA:1,anonymous_18
FNDA:1,anonymous_19
FNDA:1,anonymous_20
FNDA:1,anonymous_21
FNDA:1,anonymous_22
FNDA:1,anonymous_23
FNDA:1,anonymous_24
FNDA:1,anonymous_25
FNDA:1,anonymous_26
FNDA:1,anonymous_27
FNDA:1,anonymous_28
FNDA:1,anonymous_29
FNDA:1,anonymous_30
FNDA:1,anonymous_31
FNDA:1,anonymous_32
FNDA:1,anonymous_33
FNDA:1,anonymous_34
FNDA:1,anonymous_35
FNDA:1,anonymous_36
FNDA:1,anonymous_37
FNDA:1,anonymous_38
FNDA:1,anonymous_39
FNDA:1,anonymous_40
FNDA:1,anonymous_41
FNDA:1,anonymous_42
FNDA:1,anonymous_43
FNDA:1,anonymous_44
FNDA:1,anonymous_45
FNDA:1,anonymous_46
FNDA:1,anonymous_47
FNDA:1,anonymous_48
FNDA:0,anonymous_49
FNDA:0,anonymous_50
FNDA:1,anonymous_51
FNDA:1,functionOnly
FNDA:1,anonymous_53
FNDA:0,functionAndOptions
FNDA:1,anonymous_55
FNDA:1,anonymous_56
FNDA:1,anonymous_57
FNDA:1,anonymous_58
FNDA:1,anonymous_59
FNDA:1,anonymous_60
FNDA:1,anonymous_61
FNDA:1,anonymous_62
FNDA:1,anonymous_63
FNDA:1,anonymous_64
FNDA:1,anonymous_65
FNDA:1,anonymous_66
FNDA:1,anonymous_67
FNDA:1,anonymous_68
FNDA:1,anonymous_69
FNDA:1,anonymous_70
FNDA:1,anonymous_71
FNDA:1,anonymous_72
FNDA:1,obj
FNDA:1,anonymous_74
FNDA:1,obj
FNDA:1,anonymous_76
FNDA:1,anonymous_77
FNDA:1,anonymous_78
FNDA:1,anonymous_79
FNDA:1,anonymous_80
FNDA:1,anonymous_81
FNDA:1,anonymous_82
FNDA:1,anonymous_83
FNDA:1,anonymous_84
FNDA:1,anonymous_85
FNDA:1,anonymous_86
FNDA:1,anonymous_87
FNDA:1,get then
FNDA:1,anonymous_89
FNDA:1,anonymous_90
FNDA:1,get then
FNDA:1,anonymous_92
FNDA:1,anonymous_93
FNDA:1,anonymous_94
FNDA:1,anonymous_95
FNDA:1,anonymous_96
FNDA:1,anonymous_97
FNDA:1,anonymous_98
FNDA:1,anonymous_99
FNDA:1,anonymous_100
FNF:101
FNH:98
BRDA:1,0,0,1
BRDA:8,1,0,1
BRDA:12,2,0,1
BRDA:16,3,0,1
BRDA:21,4,0,1
BRDA:26,5,0,1
BRDA:30,6,0,1
BRDA:34,7,0,1
BRDA:38,8,0,1
BRDA:42,9,0,1
BRDA:46,10,0,1
BRDA:50,11,0,1
BRDA:54,12,0,1
BRDA:59,13,0,1
BRDA:64,14,0,1
BRDA:68,15,0,1
BRDA:72,16,0,1
BRDA:76,17,0,1
BRDA:80,18,0,1
BRDA:81,19,0,1
BRDA:86,20,0,1
BRDA:87,21,0,1
BRDA:92,22,0,1
BRDA:93,23,0,1
BRDA:94,24,0,1
BRDA:100,25,0,1
BRDA:101,26,0,1
BRDA:107,27,0,1
BRDA:111,28,0,1
BRDA:112,29,0,1
BRDA:113,30,0,1
BRDA:114,31,0,1
BRDA:122,32,0,1
BRDA:123,33,0,1
BRDA:130,34,0,1
BRDA:131,35,0,1
BRDA:132,36,0,1
BRDA:140,37,0,1
BRDA:141,38,0,1
BRDA:142,39,0,1
BRDA:150,40,0,1
BRDA:151,41,0,1
BRDA:159,42,0,1
BRDA:160,43,0,1
BRDA:161,44,0,1
BRDA:166,45,0,1
BRDA:167,46,0,1
BRDA:171,47,0,1
BRDA:172,48,0,1
BRDA:173,49,0,1
BRDA:187,50,0,1
BRDA:195,51,0,1
BRDA:198,52,0,1
BRDA:215,53,0,1
BRDA:219,54,0,1
BRDA:220,55,0,1
BRDA:225,56,0,1
BRDA:229,57,0,1
BRDA:233,58,0,1
BRDA:238,59,0,1
BRDA:242,60,0,1
BRDA:246,61,0,1
BRDA:251,62,0,1
BRDA:256,63,0,1
BRDA:257,64,0,1
BRDA:263,65,0,1
BRDA:264,66,0,1
BRDA:269,67,0,1
BRDA:270,68,0,1
BRDA:277,69,0,1
BRDA:287,70,0,1
BRDA:289,71,0,1
BRDA:298,72,0,1
BRDA:300,73,0,1
BRDA:309,74,0,1
BRDA:310,75,0,1
BRDA:313,76,0,1
BRDA:318,77,0,1
BRDA:319,78,0,1
BRDA:320,79,0,1
BRDA:327,80,0,1
BRDA:328,81,0,1
BRDA:335,82,0,1
BRDA:336,83,0,1
BRDA:341,84,0,1
BRDA:345,85,0,1
BRDA:348,86,0,1
BRDA:349,87,0,0
BRDA:351,88,0,1
BRDA:356,89,0,1
BRDA:359,90,0,1
BRDA:360,91,0,0
BRDA:362,92,0,1
BRDA:367,93,0,1
BRDA:370,94,0,0
BRDA:368,95,0,1
BRDA:369,96,0,1
BRDA:373,97,0,1
BRDA:376,98,0,0
BRDA:374,99,0,1
BRDA:375,100,0,1
BRDA:381,101,0,1
BRDA:385,102,0,1
BRF:103
BRH:99
DA:1,1
DA:2,1
DA:3,1
DA:4,1
DA:5,1
DA:6,1
DA:7,1
DA:8,1
DA:9,1
DA:10,1
DA:11,1
DA:12,1
DA:13,1
DA:14,1
DA:15,1
DA:16,1
DA:17,1
DA:18,1
DA:19,1
DA:20,1
DA:21,1
DA:22,1
DA:23,1
DA:24,1
DA:25,1
DA:26,1
DA:27,1
DA:28,1
DA:29,1
DA:30,1
DA:31,1
DA:32,1
DA:33,1
DA:34,1
DA:35,1
DA:36,1
DA:37,1
DA:38,1
DA:39,1
DA:40,1
DA:41,1
DA:42,1
DA:43,1
DA:44,1
DA:45,1
DA:46,1
DA:47,1
DA:48,1
DA:49,1
DA:50,1
DA:51,1
DA:52,1
DA:53,1
DA:54,1
DA:55,1
DA:56,1
DA:57,1
DA:58,1
DA:59,1
DA:60,1
DA:61,1
DA:62,1
DA:63,1
DA:64,1
DA:65,1
DA:66,1
DA:67,1
DA:68,1
DA:69,1
DA:70,1
DA:71,1
DA:72,1
DA:73,1
DA:74,1
DA:75,1
DA:76,1
DA:77,1
DA:78,1
DA:79,1
DA:80,1
DA:81,1
DA:82,1
DA:83,1
DA:84,1
DA:85,1
DA:86,1
DA:87,1
DA:88,1
DA:89,1
DA:90,1
DA:91,1
DA:92,1
DA:93,1
DA:94,1
DA:95,1
DA:96,1
DA:97,1
DA:98,1
DA:99,1
DA:100,1
DA:101,1
DA:102,1
DA:103,1
DA:104,1
DA:105,1
DA:106,1
DA:107,1
DA:108,1
DA:109,1
DA:110,1
DA:111,1
DA:112,1
DA:113,1
DA:114,1
DA:115,1
DA:116,1
DA:117,1
DA:118,1
DA:119,1
DA:120,1
DA:121,1
DA:122,1
DA:123,1
DA:124,1
DA:125,1
DA:126,1
DA:127,1
DA:128,1
DA:129,1
DA:130,1
DA:131,1
DA:132,1
DA:133,1
DA:134,1
DA:135,1
DA:136,1
DA:137,1
DA:138,1
DA:139,1
DA:140,1
DA:141,1
DA:142,1
DA:143,1
DA:144,1
DA:145,1
DA:146,1
DA:147,1
DA:148,1
DA:149,1
DA:150,1
DA:151,1
DA:152,1
DA:153,1
DA:154,1
DA:155,1
DA:156,1
DA:157,1
DA:158,1
DA:159,1
DA:160,1
DA:161,1
DA:162,1
DA:163,1
DA:164,1
DA:165,1
DA:166,1
DA:167,1
DA:168,1
DA:169,1
DA:170,1
DA:171,1
DA:172,1
DA:173,1
DA:174,1
DA:175,1
DA:176,1
DA:177,1
DA:178,1
DA:179,1
DA:180,0
DA:181,1
DA:182,1
DA:183,1
DA:184,0
DA:185,1
DA:186,1
DA:187,1
DA:188,1
DA:189,1
DA:190,1
DA:191,1
DA:192,1
DA:193,1
DA:194,1
DA:195,1
DA:196,1
DA:197,1
DA:198,1
DA:199,1
DA:200,1
DA:201,1
DA:202,1
DA:203,1
DA:204,1
DA:205,1
DA:206,1
DA:207,1
DA:208,1
DA:209,1
DA:210,1
DA:211,1
DA:212,1
DA:213,1
DA:214,1
DA:215,1
DA:216,1
DA:217,1
DA:218,1
DA:219,1
DA:220,1
DA:221,1
DA:222,1
DA:223,1
DA:224,1
DA:225,1
DA:226,1
DA:227,1
DA:228,1
DA:229,1
DA:230,1
DA:231,1
DA:232,1
DA:233,1
DA:234,1
DA:235,1
DA:236,1
DA:237,1
DA:238,1
DA:239,1
DA:240,1
DA:241,1
DA:242,1
DA:243,1
DA:244,1
DA:245,1
DA:246,1
DA:247,1
DA:248,1
DA:249,1
DA:250,1
DA:251,1
DA:252,1
DA:253,1
DA:254,1
DA:255,1
DA:256,1
DA:257,1
DA:258,1
DA:259,1
DA:260,1
DA:261,1
DA:262,1
DA:263,1
DA:264,1
DA:265,1
DA:266,1
DA:267,1
DA:268,1
DA:269,1
DA:270,1
DA:271,1
DA:272,1
DA:273,1
DA:274,1
DA:275,1
DA:276,1
DA:277,1
DA:278,1
DA:279,1
DA:280,1
DA:281,1
DA:282,1
DA:283,1
DA:284,1
DA:285,1
DA:286,1
DA:287,1
DA:288,1
DA:289,1
DA:290,1
DA:291,1
DA:292,1
DA:293,1
DA:294,1
DA:295,1
DA:296,1
DA:297,1
DA:298,1
DA:299,1
DA:300,1
DA:301,1
DA:302,1
DA:303,1
DA:304,1
DA:305,1
DA:306,1
DA:307,1
DA:308,1
DA:309,1
DA:310,1
DA:311,1
DA:312,1
DA:313,1
DA:314,1
DA:315,1
DA:316,1
DA:317,1
DA:318,1
DA:319,1
DA:320,1
DA:321,1
DA:322,1
DA:323,1
DA:324,1
DA:325,1
DA:326,1
DA:327,1
DA:328,1
DA:329,1
DA:330,1
DA:331,1
DA:332,1
DA:333,1
DA:334,1
DA:335,1
DA:336,1
DA:337,1
DA:338,1
DA:339,1
DA:340,1
DA:341,1
DA:342,1
DA:343,1
DA:344,1
DA:345,1
DA:346,1
DA:347,1
DA:348,1
DA:349,1
DA:350,1
DA:351,1
DA:352,1
DA:353,1
DA:354,1
DA:355,1
DA:356,1
DA:357,1
DA:358,1
DA:359,1
DA:360,1
DA:361,1
DA:362,1
DA:363,1
DA:364,1
DA:365,1
DA:366,1
DA:367,1
DA:368,1
DA:369,1
DA:370,1
DA:371,1
DA:372,1
DA:373,1
DA:374,1
DA:375,1
DA:376,1
DA:377,1
DA:378,1
DA:379,1
DA:380,1
DA:381,1
DA:382,1
DA:383,1
DA:384,1
DA:385,1
DA:386,1
DA:387,1
DA:388,1
DA:389,1
DA:390,1
DA:391,1
DA:392,1
DA:393,1
DA:394,1
DA:395,1
DA:396,1
DA:397,1
DA:398,1
DA:399,1
DA:400,1
DA:401,1
DA:402,1
DA:403,1
DA:404,1
DA:405,1
DA:406,1
LH:404
LF:406
end_of_record

View File

@ -0,0 +1,10 @@
// Flags: --test-skip-pattern=disabled --test-name-pattern=enabled
'use strict';
const common = require('../../../common');
const {
test,
} = require('node:test');
test('disabled', common.mustNotCall());
test('enabled', common.mustCall());
test('enabled disabled', common.mustNotCall());

View File

@ -0,0 +1,16 @@
TAP version 13
# Subtest: enabled
ok 1 - enabled
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,89 @@
// Flags: --test-name-pattern=enabled --test-name-pattern=yes --test-name-pattern=/pattern/i --test-name-pattern=/^DescribeForMatchWithAncestors\sNestedDescribeForMatchWithAncestors\sNestedTest$/
'use strict';
const common = require('../../../common');
const {
after,
afterEach,
before,
beforeEach,
describe,
it,
test,
} = require('node:test');
test('top level test disabled', common.mustNotCall());
test('top level skipped test disabled', { skip: true }, common.mustNotCall());
test('top level skipped test enabled', { skip: true }, common.mustNotCall());
it('top level it enabled', common.mustCall());
it('top level it disabled', common.mustNotCall());
it.skip('top level skipped it disabled', common.mustNotCall());
it.skip('top level skipped it enabled', common.mustNotCall());
describe('top level describe never disabled', common.mustCall());
describe.skip('top level skipped describe disabled', common.mustNotCall());
describe.skip('top level skipped describe enabled', common.mustNotCall());
test('top level runs because name includes PaTtErN', common.mustCall());
test('top level test enabled', common.mustCall(async (t) => {
t.beforeEach(common.mustCall());
t.afterEach(common.mustCall());
await t.test(
'nested test runs because name includes PATTERN',
common.mustCall(),
);
}));
describe('top level describe enabled', () => {
before(common.mustCall());
beforeEach(common.mustCall(3));
afterEach(common.mustCall(3));
after(common.mustCall());
it('nested it not disabled', common.mustCall());
it('nested it enabled', common.mustCall());
describe('nested describe not disabled', common.mustCall());
describe('nested describe enabled', common.mustCall(() => {
it('is enabled', common.mustCall());
}));
});
describe('yes', function() {
it('no', () => {});
it('yes', () => {});
describe('maybe', function() {
it('no', () => {});
it('yes', () => {});
});
});
describe('no', function() {
it('no', () => {});
it('yes', () => {});
describe('maybe', function() {
it('no', () => {});
it('yes', () => {});
});
});
describe('no with todo', { todo: true }, () => {
it('no', () => {});
it('yes', () => {});
describe('maybe', function() {
it('no', () => {});
it('yes', () => {});
});
});
describe('DescribeForMatchWithAncestors', () => {
it('NestedTest', () => common.mustNotCall());
describe('NestedDescribeForMatchWithAncestors', () => {
it('NestedTest', common.mustCall());
});
});
describe('DescribeForMatchWithAncestors', () => {
it('NestedTest', () => common.mustNotCall());
});

View File

@ -0,0 +1,201 @@
TAP version 13
# Subtest: top level skipped test enabled
ok 1 - top level skipped test enabled # SKIP
---
duration_ms: *
type: 'test'
...
# Subtest: top level it enabled
ok 2 - top level it enabled
---
duration_ms: *
type: 'test'
...
# Subtest: top level skipped it enabled
ok 3 - top level skipped it enabled # SKIP
---
duration_ms: *
type: 'test'
...
# Subtest: top level skipped describe enabled
ok 4 - top level skipped describe enabled # SKIP
---
duration_ms: *
type: 'suite'
...
# Subtest: top level runs because name includes PaTtErN
ok 5 - top level runs because name includes PaTtErN
---
duration_ms: *
type: 'test'
...
# Subtest: top level test enabled
# Subtest: nested test runs because name includes PATTERN
ok 1 - nested test runs because name includes PATTERN
---
duration_ms: *
type: 'test'
...
1..1
ok 6 - top level test enabled
---
duration_ms: *
type: 'test'
...
# Subtest: top level describe enabled
# Subtest: nested it not disabled
ok 1 - nested it not disabled
---
duration_ms: *
type: 'test'
...
# Subtest: nested it enabled
ok 2 - nested it enabled
---
duration_ms: *
type: 'test'
...
# Subtest: nested describe not disabled
ok 3 - nested describe not disabled
---
duration_ms: *
type: 'suite'
...
# Subtest: nested describe enabled
# Subtest: is enabled
ok 1 - is enabled
---
duration_ms: *
type: 'test'
...
1..1
ok 4 - nested describe enabled
---
duration_ms: *
type: 'suite'
...
1..4
ok 7 - top level describe enabled
---
duration_ms: *
type: 'suite'
...
# Subtest: yes
# Subtest: no
ok 1 - no
---
duration_ms: *
type: 'test'
...
# Subtest: yes
ok 2 - yes
---
duration_ms: *
type: 'test'
...
# Subtest: maybe
# Subtest: no
ok 1 - no
---
duration_ms: *
type: 'test'
...
# Subtest: yes
ok 2 - yes
---
duration_ms: *
type: 'test'
...
1..2
ok 3 - maybe
---
duration_ms: *
type: 'suite'
...
1..3
ok 8 - yes
---
duration_ms: *
type: 'suite'
...
# Subtest: no
# Subtest: yes
ok 1 - yes
---
duration_ms: *
type: 'test'
...
# Subtest: maybe
# Subtest: yes
ok 1 - yes
---
duration_ms: *
type: 'test'
...
1..1
ok 2 - maybe
---
duration_ms: *
type: 'suite'
...
1..2
ok 9 - no
---
duration_ms: *
type: 'suite'
...
# Subtest: no with todo
# Subtest: yes
ok 1 - yes
---
duration_ms: *
type: 'test'
...
# Subtest: maybe
# Subtest: yes
ok 1 - yes
---
duration_ms: *
type: 'test'
...
1..1
ok 2 - maybe
---
duration_ms: *
type: 'suite'
...
1..2
ok 10 - no with todo # TODO
---
duration_ms: *
type: 'suite'
...
# Subtest: DescribeForMatchWithAncestors
# Subtest: NestedDescribeForMatchWithAncestors
# Subtest: NestedTest
ok 1 - NestedTest
---
duration_ms: *
type: 'test'
...
1..1
ok 1 - NestedDescribeForMatchWithAncestors
---
duration_ms: *
type: 'suite'
...
1..1
ok 11 - DescribeForMatchWithAncestors
---
duration_ms: *
type: 'suite'
...
1..11
# tests 18
# suites 12
# pass 16
# fail 0
# cancelled 0
# skipped 2
# todo 0
# duration_ms *

View File

@ -0,0 +1,13 @@
// Flags: --test-only --test-name-pattern=enabled
'use strict';
const common = require('../../../common');
const { test } = require('node:test');
test('enabled and only', { only: true }, common.mustCall(async (t) => {
await t.test('enabled', common.mustCall());
await t.test('disabled but parent not', common.mustCall());
}));
test('enabled but not only', common.mustNotCall());
test('only does not match pattern', { only: true }, common.mustNotCall());
test('not only and does not match pattern', common.mustNotCall());

View File

@ -0,0 +1,29 @@
TAP version 13
# Subtest: enabled and only
# Subtest: enabled
ok 1 - enabled
---
duration_ms: *
type: 'test'
...
# Subtest: disabled but parent not
ok 2 - disabled but parent not
---
duration_ms: *
type: 'test'
...
1..2
ok 1 - enabled and only
---
duration_ms: *
type: 'test'
...
1..1
# tests 3
# suites 0
# pass 3
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,12 @@
'use strict';
require('../../../common');
const test = require('node:test');
// When run alone, the test below does not keep the event loop alive.
test('does not keep event loop alive', async (t) => {
await t.test('+does not keep event loop alive', async (t) => {
return new Promise((resolve) => {
setTimeout(resolve, 1000).unref();
});
});
});

View File

@ -0,0 +1,23 @@
TAP version 13
# Subtest: does not keep event loop alive
# Subtest: +does not keep event loop alive
ok 1 - +does not keep event loop alive
---
duration_ms: *
type: 'test'
...
1..1
ok 1 - does not keep event loop alive
---
duration_ms: *
type: 'test'
...
1..1
# tests 2
# suites 0
# pass 2
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *

View File

@ -0,0 +1,6 @@
'use strict';
require('../../../common');
const test = require('node:test');
// No TAP output should be generated.
console.log(test.name);

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1,6 @@
'use strict';
process.env.FORCE_COLOR = 1;
const test = require('node:test');
test('passing test', () => {});

View File

@ -0,0 +1,9 @@
✔ passing test (*ms)
ℹ tests 1
ℹ suites 0
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms *

View File

@ -0,0 +1,144 @@
// Flags: --test-only
'use strict';
const common = require('../../../common');
const { test, describe, it } = require('node:test');
// These tests should be skipped based on the 'only' option.
test('only = undefined', common.mustNotCall());
test('only = undefined, skip = string', { skip: 'skip message' }, common.mustNotCall());
test('only = undefined, skip = true', { skip: true }, common.mustNotCall());
test('only = undefined, skip = false', { skip: false }, common.mustNotCall());
test('only = false', { only: false }, common.mustNotCall());
test('only = false, skip = string', { only: false, skip: 'skip message' }, common.mustNotCall());
test('only = false, skip = true', { only: false, skip: true }, common.mustNotCall());
test('only = false, skip = false', { only: false, skip: false }, common.mustNotCall());
// These tests should be skipped based on the 'skip' option.
test('only = true, skip = string', { only: true, skip: 'skip message' }, common.mustNotCall());
test('only = true, skip = true', { only: true, skip: true }, common.mustNotCall());
// An 'only' test with subtests.
test('only = true, with subtests', { only: true }, common.mustCall(async (t) => {
// These subtests should run.
await t.test('running subtest 1', common.mustCall());
await t.test('running subtest 2', common.mustCall());
// Switch the context to only execute 'only' tests.
t.runOnly(true);
await t.test('skipped subtest 1', common.mustNotCall());
await t.test('skipped subtest 2', common.mustNotCall());
await t.test('running subtest 3', { only: true }, common.mustCall());
// Switch the context back to execute all tests.
t.runOnly(false);
await t.test('running subtest 4', common.mustCall(async (t) => {
// These subtests should run.
await t.test('running sub-subtest 1', common.mustCall());
await t.test('running sub-subtest 2', common.mustCall());
// Switch the context to only execute 'only' tests.
t.runOnly(true);
await t.test('skipped sub-subtest 1', common.mustNotCall());
await t.test('skipped sub-subtest 2', common.mustNotCall());
}));
// Explicitly do not run these tests.
await t.test('skipped subtest 3', { only: false }, common.mustNotCall());
await t.test('skipped subtest 4', { skip: true }, common.mustNotCall());
}));
describe.only('describe only = true, with subtests', common.mustCall(() => {
it.only('`it` subtest 1 should run', common.mustCall());
it('`it` subtest 2 should not run', common.mustNotCall());
}));
describe.only('describe only = true, with a mixture of subtests', common.mustCall(() => {
it.only('`it` subtest 1', common.mustCall());
// eslint-disable-next-line no-restricted-syntax
it.only('`it` async subtest 1', common.mustCall(async () => {}));
it('`it` subtest 2 only=true', { only: true }, common.mustCall());
it('`it` subtest 2 only=false', { only: false }, common.mustNotCall());
it.skip('`it` subtest 3 skip', common.mustNotCall());
it.todo('`it` subtest 4 todo', { only: false }, common.mustNotCall());
test.only('`test` subtest 1', common.mustCall());
// eslint-disable-next-line no-restricted-syntax
test.only('`test` async subtest 1', common.mustCall(async () => {}));
test('`test` subtest 2 only=true', { only: true }, common.mustCall());
test('`test` subtest 2 only=false', { only: false }, common.mustNotCall());
test.skip('`test` subtest 3 skip', common.mustNotCall());
test.todo('`test` subtest 4 todo', { only: false }, common.mustNotCall());
}));
describe.only('describe only = true, with subtests', common.mustCall(() => {
test.only('subtest should run', common.mustCall());
test('async subtest should not run', common.mustNotCall());
test('subtest should be skipped', { only: false }, common.mustNotCall());
}));
describe('describe only = undefined, with nested only subtest', common.mustCall(() => {
test('subtest should not run', common.mustNotCall());
describe('nested describe', common.mustCall(() => {
test('subtest should not run', common.mustNotCall());
test.only('nested test should run', common.mustCall());
}));
}));
describe('describe only = undefined, with subtests', common.mustCall(() => {
test('async subtest should not run', common.mustNotCall());
}));
describe('describe only = false, with subtests', { only: false }, common.mustNotCall(() => {
test('async subtest should not run', common.mustNotCall());
}));
describe.only('describe only = true, with nested subtests', common.mustCall(() => {
test('async subtest should run', common.mustCall());
describe('nested describe', common.mustCall(() => {
test('nested test should run', common.mustCall());
}));
}));
describe('describe only = false, with nested only subtests', { only: false }, common.mustNotCall(() => {
test('async subtest should not run', common.mustNotCall());
describe('nested describe', common.mustNotCall(() => {
test.only('nested test should run', common.mustNotCall());
}));
}));
test('nested tests with run only', { only: true }, common.mustCall(async (t) => {
// Within this test, all subtests are run by default.
await t.test('running subtest - 1');
// The test context can be updated to run subtests with the 'only' option.
await t.runOnly(true);
await t.test('this subtest is now skipped - 2', common.mustNotCall());
await t.test('this subtest is run - 3', { only: true }, common.mustCall(async (t) => {
await t.test('this subtest is run - 4', common.mustCall());
await t.test('this subtest is run - 5', { only: true }, common.mustCall());
}));
// Switch the context back to execute all tests.
await t.runOnly(false);
await t.test('this subtest is now run - 6');
// Explicitly do not run these tests.
await t.test('skipped subtest - 7', { only: false }, common.mustNotCall());
await t.test('skipped subtest - 8', { skip: true }, common.mustNotCall());
}));

View File

@ -0,0 +1,231 @@
TAP version 13
# Subtest: only = true, skip = string
ok 1 - only = true, skip = string # SKIP skip message
---
duration_ms: *
type: 'test'
...
# Subtest: only = true, skip = true
ok 2 - only = true, skip = true # SKIP
---
duration_ms: *
type: 'test'
...
# Subtest: only = true, with subtests
# Subtest: running subtest 1
ok 1 - running subtest 1
---
duration_ms: *
type: 'test'
...
# Subtest: running subtest 2
ok 2 - running subtest 2
---
duration_ms: *
type: 'test'
...
# Subtest: running subtest 3
ok 3 - running subtest 3
---
duration_ms: *
type: 'test'
...
# Subtest: running subtest 4
# Subtest: running sub-subtest 1
ok 1 - running sub-subtest 1
---
duration_ms: *
type: 'test'
...
# Subtest: running sub-subtest 2
ok 2 - running sub-subtest 2
---
duration_ms: *
type: 'test'
...
1..2
ok 4 - running subtest 4
---
duration_ms: *
type: 'test'
...
# Subtest: skipped subtest 4
ok 5 - skipped subtest 4 # SKIP
---
duration_ms: *
type: 'test'
...
1..5
ok 3 - only = true, with subtests
---
duration_ms: *
type: 'test'
...
# Subtest: describe only = true, with subtests
# Subtest: `it` subtest 1 should run
ok 1 - `it` subtest 1 should run
---
duration_ms: *
type: 'test'
...
1..1
ok 4 - describe only = true, with subtests
---
duration_ms: *
type: 'suite'
...
# Subtest: describe only = true, with a mixture of subtests
# Subtest: `it` subtest 1
ok 1 - `it` subtest 1
---
duration_ms: *
type: 'test'
...
# Subtest: `it` async subtest 1
ok 2 - `it` async subtest 1
---
duration_ms: *
type: 'test'
...
# Subtest: `it` subtest 2 only=true
ok 3 - `it` subtest 2 only=true
---
duration_ms: *
type: 'test'
...
# Subtest: `test` subtest 1
ok 4 - `test` subtest 1
---
duration_ms: *
type: 'test'
...
# Subtest: `test` async subtest 1
ok 5 - `test` async subtest 1
---
duration_ms: *
type: 'test'
...
# Subtest: `test` subtest 2 only=true
ok 6 - `test` subtest 2 only=true
---
duration_ms: *
type: 'test'
...
1..6
ok 5 - describe only = true, with a mixture of subtests
---
duration_ms: *
type: 'suite'
...
# Subtest: describe only = true, with subtests
# Subtest: subtest should run
ok 1 - subtest should run
---
duration_ms: *
type: 'test'
...
1..1
ok 6 - describe only = true, with subtests
---
duration_ms: *
type: 'suite'
...
# Subtest: describe only = undefined, with nested only subtest
# Subtest: nested describe
# Subtest: nested test should run
ok 1 - nested test should run
---
duration_ms: *
type: 'test'
...
1..1
ok 1 - nested describe
---
duration_ms: *
type: 'suite'
...
1..1
ok 7 - describe only = undefined, with nested only subtest
---
duration_ms: *
type: 'suite'
...
# Subtest: describe only = true, with nested subtests
# Subtest: async subtest should run
ok 1 - async subtest should run
---
duration_ms: *
type: 'test'
...
# Subtest: nested describe
# Subtest: nested test should run
ok 1 - nested test should run
---
duration_ms: *
type: 'test'
...
1..1
ok 2 - nested describe
---
duration_ms: *
type: 'suite'
...
1..2
ok 8 - describe only = true, with nested subtests
---
duration_ms: *
type: 'suite'
...
# Subtest: nested tests with run only
# Subtest: running subtest - 1
ok 1 - running subtest - 1
---
duration_ms: *
type: 'test'
...
# Subtest: this subtest is run - 3
# Subtest: this subtest is run - 4
ok 1 - this subtest is run - 4
---
duration_ms: *
type: 'test'
...
# Subtest: this subtest is run - 5
ok 2 - this subtest is run - 5
---
duration_ms: *
type: 'test'
...
1..2
ok 2 - this subtest is run - 3
---
duration_ms: *
type: 'test'
...
# Subtest: this subtest is now run - 6
ok 3 - this subtest is now run - 6
---
duration_ms: *
type: 'test'
...
# Subtest: skipped subtest - 8
ok 4 - skipped subtest - 8 # SKIP
---
duration_ms: *
type: 'test'
...
1..4
ok 9 - nested tests with run only
---
duration_ms: *
type: 'test'
...
1..9
# tests 28
# suites 7
# pass 24
# fail 0
# cancelled 0
# skipped 4
# todo 0
# duration_ms *

View File

@ -0,0 +1,406 @@
// Flags: --no-warnings
'use strict';
require('../../../common');
const assert = require('node:assert');
const test = require('node:test');
const util = require('util');
test('sync pass todo', (t) => {
t.todo();
});
test('sync pass todo with message', (t) => {
t.todo('this is a passing todo');
});
test('sync fail todo', (t) => {
t.todo();
throw new Error('thrown from sync fail todo');
});
test('sync fail todo with message', (t) => {
t.todo('this is a failing todo');
throw new Error('thrown from sync fail todo with message');
});
test('sync skip pass', (t) => {
t.skip();
});
test('sync skip pass with message', (t) => {
t.skip('this is skipped');
});
test('sync pass', (t) => {
t.diagnostic('this test should pass');
});
test('sync throw fail', () => {
throw new Error('thrown from sync throw fail');
});
test('async skip pass', async (t) => {
t.skip();
});
test('async pass', async () => {
});
test('async throw fail', async () => {
throw new Error('thrown from async throw fail');
});
test('async skip fail', async (t) => {
t.skip();
throw new Error('thrown from async throw fail');
});
test('async assertion fail', async () => {
// Make sure the assert module is handled.
assert.strictEqual(true, false);
});
test('resolve pass', () => {
return Promise.resolve();
});
test('reject fail', () => {
return Promise.reject(new Error('rejected from reject fail'));
});
test('unhandled rejection - passes but warns', () => {
Promise.reject(new Error('rejected from unhandled rejection fail'));
});
test('async unhandled rejection - passes but warns', async () => {
Promise.reject(new Error('rejected from async unhandled rejection fail'));
});
test('immediate throw - passes but warns', () => {
setImmediate(() => {
throw new Error('thrown from immediate throw fail');
});
});
test('immediate reject - passes but warns', () => {
setImmediate(() => {
Promise.reject(new Error('rejected from immediate reject fail'));
});
});
test('immediate resolve pass', () => {
return new Promise((resolve) => {
setImmediate(() => {
resolve();
});
});
});
test('subtest sync throw fail', async (t) => {
await t.test('+sync throw fail', (t) => {
t.diagnostic('this subtest should make its parent test fail');
throw new Error('thrown from subtest sync throw fail');
});
});
test('sync throw non-error fail', async (t) => {
throw Symbol('thrown symbol from sync throw non-error fail');
});
test('level 0a', { concurrency: 4 }, async (t) => {
t.test('level 1a', async (t) => {
const p1a = new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 100);
});
return p1a;
});
test('level 1b', async (t) => {
const p1b = new Promise((resolve) => {
resolve();
});
return p1b;
});
t.test('level 1c', async (t) => {
const p1c = new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 200);
});
return p1c;
});
t.test('level 1d', async (t) => {
const p1c = new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 150);
});
return p1c;
});
const p0a = new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 300);
});
return p0a;
});
test('top level', { concurrency: 2 }, async (t) => {
t.test('+long running', async (t) => {
return new Promise((resolve, reject) => {
setTimeout(resolve, 300).unref();
});
});
t.test('+short running', async (t) => {
t.test('++short running', async (t) => {});
});
});
test('invalid subtest - pass but subtest fails', (t) => {
setImmediate(() => {
t.test('invalid subtest fail', () => {
throw new Error('this should not be thrown');
});
});
});
test('sync skip option', { skip: true }, (t) => {
throw new Error('this should not be executed');
});
test('sync skip option with message', { skip: 'this is skipped' }, (t) => {
throw new Error('this should not be executed');
});
test('sync skip option is false fail', { skip: false }, (t) => {
throw new Error('this should be executed');
});
// A test with no arguments provided.
test();
// A test with only a named function provided.
test(function functionOnly() {});
// A test with only an anonymous function provided.
test(() => {});
// A test with only a name provided.
test('test with only a name provided');
// A test with an empty string name.
test('');
// A test with only options provided.
test({ skip: true });
// A test with only a name and options provided.
test('test with a name and options provided', { skip: true });
// A test with only options and a function provided.
test({ skip: true }, function functionAndOptions() {});
test('callback pass', (t, done) => {
setImmediate(done);
});
test('callback fail', (t, done) => {
setImmediate(() => {
done(new Error('callback failure'));
});
});
test('sync t is this in test', function(t) {
assert.strictEqual(this, t);
});
test('async t is this in test', async function(t) {
assert.strictEqual(this, t);
});
test('callback t is this in test', function(t, done) {
assert.strictEqual(this, t);
done();
});
test('callback also returns a Promise', async (t, done) => {
throw new Error('thrown from callback also returns a Promise');
});
test('callback throw', (t, done) => {
throw new Error('thrown from callback throw');
});
test('callback called twice', (t, done) => {
done();
done();
});
test('callback called twice in different ticks', (t, done) => {
setImmediate(done);
done();
});
test('callback called twice in future tick', (t, done) => {
setImmediate(() => {
done();
done();
});
});
test('callback async throw', (t, done) => {
setImmediate(() => {
throw new Error('thrown from callback async throw');
});
});
test('callback async throw after done', (t, done) => {
setImmediate(() => {
throw new Error('thrown from callback async throw after done');
});
done();
});
test('only is set on subtests but not in only mode', async (t) => {
// All of these subtests should run.
await t.test('running subtest 1');
t.runOnly(true);
await t.test('running subtest 2');
await t.test('running subtest 3', { only: true });
t.runOnly(false);
await t.test('running subtest 4');
});
test('custom inspect symbol fail', () => {
const obj = {
[util.inspect.custom]() {
return 'customized';
},
foo: 1,
};
throw obj;
});
test('custom inspect symbol that throws fail', () => {
const obj = {
[util.inspect.custom]() {
throw new Error('bad-inspect');
},
foo: 1,
};
throw obj;
});
test('subtest sync throw fails', async (t) => {
await t.test('sync throw fails at first', (t) => {
throw new Error('thrown from subtest sync throw fails at first');
});
await t.test('sync throw fails at second', (t) => {
throw new Error('thrown from subtest sync throw fails at second');
});
});
test('timed out async test', { timeout: 5 }, async (t) => {
return new Promise((resolve) => {
setTimeout(() => {
// Empty timer so the process doesn't exit before the timeout triggers.
}, 5);
setTimeout(resolve, 30_000_000).unref();
});
});
test('timed out callback test', { timeout: 5 }, (t, done) => {
setTimeout(() => {
// Empty timer so the process doesn't exit before the timeout triggers.
}, 5);
setTimeout(done, 30_000_000).unref();
});
test('large timeout async test is ok', { timeout: 30_000_000 }, async (t) => {
return new Promise((resolve) => {
setTimeout(resolve, 10);
});
});
test('large timeout callback test is ok', { timeout: 30_000_000 }, (t, done) => {
setTimeout(done, 10);
});
test('successful thenable', () => {
let thenCalled = false;
return {
get then() {
if (thenCalled) throw new Error();
thenCalled = true;
return (successHandler) => successHandler();
},
};
});
test('rejected thenable', () => {
let thenCalled = false;
return {
get then() {
if (thenCalled) throw new Error();
thenCalled = true;
return (_, errorHandler) => errorHandler('custom error');
},
};
});
test('unfinished test with uncaughtException', async () => {
await new Promise(() => {
setTimeout(() => { throw new Error('foo'); });
});
});
test('unfinished test with unhandledRejection', async () => {
await new Promise(() => {
setTimeout(() => Promise.reject(new Error('bar')));
});
});
// Verify that uncaught exceptions outside of any tests are handled after the
// test harness has finished bootstrapping itself.
setImmediate(() => {
throw new Error('uncaught from outside of a test');
});
test('assertion errors display actual and expected properly', async () => {
// Make sure the assert module is handled.
const circular = { bar: 2 };
circular.c = circular;
const tmpLimit = Error.stackTraceLimit;
Error.stackTraceLimit = 1;
const boo = [1];
const baz = {
date: new Date(0),
null: null,
number: 1,
string: 'Hello',
undefined: undefined,
};
try {
// eslint-disable-next-line no-restricted-properties
assert.deepEqual({ foo: 1, bar: 1, boo, baz }, { boo, baz, circular });
} catch (err) {
Error.stackTraceLimit = tmpLimit;
throw err;
}
});

Some files were not shown because too many files have changed in this diff Show More