Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
d596803
doc: add path rules and validation for export targets in package.json
0hmX Jun 9, 2025
893999e
src: replace V8 Fast API todo comment with note comment
dario-piotrowicz Jun 9, 2025
a4d7560
test: close FileHandle objects in tests explicitly
jasnell Jun 9, 2025
713fbad
test_runner: support object property mocking
idango10 Jun 9, 2025
4347ce3
src: add new CopyUtimes function to reduce code duplication
dario-piotrowicz Jun 9, 2025
dc10238
deps: update zlib to 1.3.1-470d3a2
nodejs-github-bot Jun 10, 2025
80eac14
deps: update simdjson to 3.13.0
nodejs-github-bot Jun 10, 2025
3aa2762
deps: update sqlite to 3.50.1
nodejs-github-bot Jun 10, 2025
181014a
test: cleanup status files
panva Jun 10, 2025
e9c6fa5
src: replace std::array with static arrays in contextify
mertcanaltin Jun 10, 2025
85f062c
test: deflake async-hooks/test-improper-order on AIX
bakigul1 Jun 3, 2025
7e34aa4
test: skip tests failing when run under root
LiviaMedeiros Jun 10, 2025
839964e
fs: allow correct handling of burst in fs-events with AsyncIterator
pipobscure Jun 10, 2025
450f481
deps: update amaro to 1.0.0
nodejs-github-bot Jun 11, 2025
76e3c8a
test: update WPT for es-exceptions to 2f96fa1996
nodejs-github-bot Jun 11, 2025
aa657f0
test: split indirect eval import tests
legendecas Jun 11, 2025
a3c7a63
module: allow cycles in require() in the CJS handling in ESM loader
joyeecheung Jun 11, 2025
9b28f40
module: remove experimental warning from type stripping
marco-ippolito Jun 11, 2025
fa089d6
test: update WPT for dom/abort to dc928169ee
nodejs-github-bot Jun 11, 2025
94e53d4
test: update WPT for urlpattern to 3ffda23e5a
nodejs-github-bot Jun 1, 2025
b1f60d2
http2: add diagnostics channel 'http2.server.stream.close'
RaisinTen Jun 11, 2025
b11da11
http2: fix DEP0194 message
climba03003 Jun 11, 2025
afbaf92
tools: improve release proposal linter
aduh95 Jun 11, 2025
6390f70
lib,src: support DOMException ser-des
legendecas Jun 11, 2025
b6760b3
esm: syncify default path of `ModuleLoader.load`
JakobJingleheimer Jun 11, 2025
ffff8ce
typings: add ZSTD_COMPRESS, ZSTD_DECOMPRESS to internalBinding
nektro Jun 12, 2025
45f7d16
module: refactor commonjs typescript loader
marco-ippolito Jun 12, 2025
ff8a369
module: fix typescript import.meta.main
marco-ippolito Jun 12, 2025
c1f9791
tools: edit commit-queue workflow file
aduh95 Jun 12, 2025
1cc77c7
doc: punctuation fix for Node-API versioning clarification
jiacai2050 Jun 12, 2025
268c8c1
tools: remove config.status under `make distclean`
Renegade334 Jun 12, 2025
b22e970
tools: switch to `@stylistic/eslint-plugin`
targos Jun 13, 2025
ec808b3
test: use `common.skipIfInspectorDisabled()` to skip tests
dario-piotrowicz Jun 13, 2025
dfb0144
src: enhance error messages for unknown options
pmarchini Jun 13, 2025
e6a1787
tools: bump brace-expansion from 1.1.11 to 1.1.12 in /tools/eslint
dependabot[bot] Jun 14, 2025
dc2f23e
tools: bump `brace-expansion` in `/tools/clang-format`
dependabot[bot] Jun 14, 2025
ef0230a
url: add fileURLToPathBuffer API
jasnell Jun 12, 2025
b7e488c
test: refactor repl tab complete tests
dario-piotrowicz Jun 15, 2025
c39d570
test: reduce the use of private symbols in test-events-once.js
kt3k Jun 15, 2025
17df800
typings: add Atomics primordials
Renegade334 Jun 4, 2025
704b1fa
test: add tests for REPL custom evals
dario-piotrowicz Jun 15, 2025
841609a
doc: add islandryu to collaborators
islandryu Jun 16, 2025
fb4378b
fs: add UV_ENOSPC to list of things to pass to err directly
jackyzha0 Jun 16, 2025
6f7b895
util: inspect: do not crash on an Error stack pointing to itself
SamVerschueren Jun 16, 2025
82b18ba
repl: fix tab completion not working with computer string properties
dario-piotrowicz Jun 17, 2025
c9e7b5e
test_runner: prefer `Atomics` primordials
Renegade334 Jun 4, 2025
af18c0e
fs: remove IIFE in glob
LiviaMedeiros May 21, 2025
f125310
doc: run license-builder
github-actions[bot] Jun 18, 2025
62b5879
fs: avoid computing time coefficient constants in runtime
LiviaMedeiros Jun 18, 2025
7bb1246
doc: add history entry for TS support in hooks
aduh95 Jun 18, 2025
d94b184
test: deflake test-buffer-large-size-buffer-alloc
lpinca Jun 18, 2025
68671f4
deps: upgrade npm to 11.4.2
npm-cli-bot Jun 20, 2025
6e0ee39
test: skip the test if the buffer allocation fails
lpinca Jun 20, 2025
b5ff3f4
tools: include toolchain.gypi in abseil.gyp
legendecas Jun 20, 2025
be93091
inspector: add protocol methods retrieving sent/received data
legendecas Jun 20, 2025
e2e88d4
doc: fix wrong RFC number in http2
deokjinkim Jun 20, 2025
fa6854f
deps: update amaro to 1.1.0
nodejs-github-bot Jun 20, 2025
96c78d7
fs: make `Dir` disposers idempotent
Renegade334 Jun 20, 2025
4b61f10
deps: V8: cherry-pick e3df60f3f5ab
legendecas Jun 19, 2025
081c708
lib: make domexception a native error
legendecas Jun 12, 2025
a0b1378
src: pass resource on permission checks for spawn
RafaelGSS Jun 21, 2025
8eec789
test: correct SIMD support comment
richardlau Jun 21, 2025
9df1cfe
tools: make nodedownload module compatible with Python 3.14
frenzymadness Jun 22, 2025
3faa4e8
test: deflake test-buffer-large-size-buffer-alloc-unsafe
lpinca Jun 22, 2025
d9c2b70
test: refactor repl save-load tests
dario-piotrowicz Jun 22, 2025
d0e42ff
repl: avoid deprecated `require.extensions` in tab completion
gulbaki Jun 23, 2025
6ef7329
Revert "test_runner: automatically wait for subtests to finish"
romainmenke May 11, 2025
8b0c5ed
Revert "test_runner: remove promises returned by test()"
romainmenke May 11, 2025
dce1995
Revert "test_runner: remove promises returned by t.test()"
romainmenke May 11, 2025
7cdda92
test: fix test-timeout-flag after revert of auto subtest wait
pmarchini May 14, 2025
2ba2c93
build: fix typo 'Stoage' to 'Storage' in help text
ganglike248 Jun 23, 2025
7643ce9
deps: update acorn to 8.15.0
nodejs-github-bot Jun 23, 2025
97fbfd8
doc: fix stability 1.x links excluding the decimal digit
dario-piotrowicz Jun 23, 2025
11811c1
deps: update nghttp2 to 1.66.0
nodejs-github-bot Jun 24, 2025
7498383
lib: make `validateInternalField()` throw `ERR_INVALID_THIS`
LiviaMedeiros Jun 19, 2025
20089e2
lib: rename `validateInternalField` into `validateThisInternalField`
LiviaMedeiros Jun 19, 2025
8c20896
src: add FromV8Value<T>() for integral and enum types
Aditi-1400 Jun 24, 2025
4c2c100
meta: add @nodejs/inspector as codeowner
legendecas Jun 24, 2025
c9dc0a8
http: fix keep-alive not timing out after post-request empty line
islandryu Jun 24, 2025
a1529d5
test_runner: automatically wait for subtests to finish
cjihrig Jan 19, 2025
7419750
2025-06-24, Version 24.3.0 (Current)
RafaelGSS Jun 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "test_runner: remove promises returned by t.test()"
This reverts commit 1a2eb15.

PR-URL: #58282
Fixes: #58227
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
  • Loading branch information
romainmenke authored and RafaelGSS committed Jun 23, 2025
commit dce1995c550edf8b08c07a1152acbd0834295aa8
62 changes: 36 additions & 26 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ top level test with two subtests.

```js
test('top level test', async (t) => {
t.test('subtest 1', (t) => {
await t.test('subtest 1', (t) => {
assert.strictEqual(1, 1);
});

t.test('subtest 2', (t) => {
await t.test('subtest 2', (t) => {
assert.strictEqual(2, 2);
});
});
Expand All @@ -118,7 +118,12 @@ test('top level test', async (t) => {
> **Note:** `beforeEach` and `afterEach` hooks are triggered
> between each subtest execution.

Any subtest failures cause the parent test to fail.
In this example, `await` is used to ensure that both subtests have completed.
This is necessary because tests do not wait for their subtests to
complete, unlike tests created within suites.
Any subtests that are still outstanding when their parent finishes
are cancelled and treated as failures. Any subtest failures cause the parent
test to fail.

## Skipping tests

Expand Down Expand Up @@ -236,20 +241,20 @@ that are not executed are omitted from the test runner output.
// The suite's 'only' option is set, so these tests are run.
test('this test is run', { only: true }, async (t) => {
// Within this test, all subtests are run by default.
t.test('running subtest');
await t.test('running subtest');

// The test context can be updated to run subtests with the 'only' option.
t.runOnly(true);
t.test('this subtest is now skipped');
t.test('this subtest is run', { only: true });
await t.test('this subtest is now skipped');
await t.test('this subtest is run', { only: true });

// Switch the context back to execute all tests.
t.runOnly(false);
t.test('this subtest is now run');
await t.test('this subtest is now run');

// Explicitly do not run these tests.
t.test('skipped subtest 3', { only: false });
t.test('skipped subtest 4', { skip: true });
await t.test('skipped subtest 3', { only: false });
await t.test('skipped subtest 4', { skip: true });
});

// The 'only' option is not set, so this test is skipped.
Expand Down Expand Up @@ -304,13 +309,13 @@ multiple times (e.g. `--test-name-pattern="test 1"`,

```js
test('test 1', async (t) => {
t.test('test 2');
t.test('test 3');
await t.test('test 2');
await t.test('test 3');
});

test('Test 4', async (t) => {
t.test('Test 5');
t.test('test 6');
await t.test('Test 5');
await t.test('test 6');
});
```

Expand Down Expand Up @@ -3388,9 +3393,12 @@ before each subtest of the current test.
```js
test('top level test', async (t) => {
t.beforeEach((t) => t.diagnostic(`about to run ${t.name}`));
t.test('This is a subtest', (t) => {
assert.ok('some relevant assertion here');
});
await t.test(
'This is a subtest',
(t) => {
assert.ok('some relevant assertion here');
},
);
});
```

Expand Down Expand Up @@ -3448,9 +3456,12 @@ after each subtest of the current test.
```js
test('top level test', async (t) => {
t.afterEach((t) => t.diagnostic(`finished running ${t.name}`));
t.test('This is a subtest', (t) => {
assert.ok('some relevant assertion here');
});
await t.test(
'This is a subtest',
(t) => {
assert.ok('some relevant assertion here');
},
);
});
```

Expand Down Expand Up @@ -3702,8 +3713,10 @@ no-op.
test('top level test', (t) => {
// The test context can be set to run subtests with the 'only' option.
t.runOnly(true);
t.test('this subtest is now skipped');
t.test('this subtest is run', { only: true });
return Promise.all([
t.test('this subtest is now skipped'),
t.test('this subtest is run', { only: true }),
]);
});
```

Expand Down Expand Up @@ -3775,10 +3788,6 @@ added:
- v18.0.0
- v16.17.0
changes:
- version:
- v24.0.0
pr-url: https://github.com/nodejs/node/pull/56664
description: This function no longer returns a `Promise`.
- version:
- v18.8.0
- v16.18.0
Expand Down Expand Up @@ -3823,13 +3832,14 @@ changes:
to this function is a [`TestContext`][] object. If the test uses callbacks,
the callback function is passed as the second argument. **Default:** A no-op
function.
* Returns: {Promise} Fulfilled with `undefined` once the test completes.

This function is used to create subtests under the current test. This function
behaves in the same fashion as the top level [`test()`][] function.

```js
test('top level test', async (t) => {
t.test(
await t.test(
'This is a subtest',
{ only: false, skip: false, concurrency: 1, todo: false, plan: 1 },
(t) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class TestContext {
Test, name, options, fn, overrides,
);

subtest.start();
return subtest.start();
}

before(fn, options) {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/test-runner/output/dot_reporter.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ Failed tests:
*
*
*
*
*
✖ subtest sync throw fails (*ms)
'2 subtests failed'
✖ timed out async test (*ms)
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/test-runner/output/hooks.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ not ok 16 - t.after throws - no subtests
*
*
*
*
...
1..2
not ok 17 - t.beforeEach throws
Expand Down Expand Up @@ -606,6 +607,8 @@ not ok 17 - t.beforeEach throws
*
*
*
*
*
...
# Subtest: 2
not ok 2 - 2
Expand All @@ -626,6 +629,7 @@ not ok 17 - t.beforeEach throws
*
*
*
*
...
1..2
not ok 18 - t.afterEach throws
Expand Down Expand Up @@ -753,6 +757,7 @@ not ok 21 - afterEach context when test fails
*
*
*
*
...
1..2
not ok 22 - afterEach throws and test fails
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/test-runner/output/hooks_spec_reporter.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@
*
*
*
*

*
1 (*ms)
Expand All @@ -375,6 +376,8 @@
*
*
*
*
*

*
2 (*ms)
Expand All @@ -388,6 +391,7 @@
*
*
*
*

*
1 (*ms)
Expand Down Expand Up @@ -435,6 +439,7 @@
*
*
*
*

*
t.after() is called if test body throws (*ms)
Expand Down
5 changes: 4 additions & 1 deletion test/fixtures/test-runner/output/junit_reporter.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
</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] {
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
Expand All @@ -365,6 +366,8 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
*
*
*
*
*
}
</failure>
</testcase>
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/test-runner/output/output.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ not ok 51 - custom inspect symbol that throws fail
*
*
*
*
*
...
1..2
not ok 52 - subtest sync throw fails
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/test-runner/output/output_cli.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ not ok 51 - custom inspect symbol that throws fail
*
*
*
*
*
...
1..2
not ok 52 - subtest sync throw fails
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/test-runner/output/spec_reporter.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@
*
*
*
*
*

*
timed out async test (*ms)
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/test-runner/output/spec_reporter_cli.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@
*
*
*
*
*

*
timed out async test (*ms)
Expand Down
14 changes: 6 additions & 8 deletions test/parallel/test-runner-module-mocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,13 @@ test('mocks are automatically restored', async (t) => {
assert.strictEqual(mocked.fn(), 43);
});

t.test('checks original behavior', async () => {
const cjsMock = require(cjsFixture);
const esmMock = await import(esmFixture);
const cjsMock = require(cjsFixture);
const esmMock = await import(esmFixture);

assert.strictEqual(cjsMock.string, 'original cjs string');
assert.strictEqual(cjsMock.fn, undefined);
assert.strictEqual(esmMock.string, 'original esm string');
assert.strictEqual(esmMock.fn, undefined);
});
assert.strictEqual(cjsMock.string, 'original cjs string');
assert.strictEqual(cjsMock.fn, undefined);
assert.strictEqual(esmMock.string, 'original esm string');
assert.strictEqual(esmMock.fn, undefined);
});

test('mocks can be restored independently', async (t) => {
Expand Down