test_runner: remove promises returned by test() · nodejs/node@9671826 · GitHub
Skip to content

Commit 9671826

Browse files
cjihrigjasnell
authored andcommitted
test_runner: remove promises returned by test()
This commit updates the test() and suite() APIs to no longer return a Promise. Fixes: #51292 PR-URL: #56664 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Raz Luvaton <rluvaton@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent aa3523e commit 9671826

5 files changed

Lines changed: 23 additions & 47 deletions

File tree

doc/api/test.md

Lines changed: 9 additions & 23 deletions

lib/internal/test_runner/harness.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,12 @@ function runInParentContext(Factory) {
312312
function run(name, options, fn, overrides) {
313313
const parent = testResources.get(executionAsyncId()) || lazyBootstrapRoot();
314314
const subtest = parent.createSubtest(Factory, name, options, fn, overrides);
315+
315316
if (parent instanceof Suite) {
316-
return PromiseResolve();
317+
return;
317318
}
318319

319-
return startSubtestAfterBootstrap(subtest);
320+
startSubtestAfterBootstrap(subtest);
320321
}
321322

322323
const test = (name, options, fn) => {
@@ -325,7 +326,7 @@ function runInParentContext(Factory) {
325326
loc: getCallerLocation(),
326327
};
327328

328-
return run(name, options, fn, overrides);
329+
run(name, options, fn, overrides);
329330
};
330331
ArrayPrototypeForEach(['skip', 'todo', 'only'], (keyword) => {
331332
test[keyword] = (name, options, fn) => {
@@ -335,7 +336,7 @@ function runInParentContext(Factory) {
335336
loc: getCallerLocation(),
336337
};
337338

338-
return run(name, options, fn, overrides);
339+
run(name, options, fn, overrides);
339340
};
340341
});
341342
return test;

test/parallel/test-runner-coverage-source-map.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,4 @@ describe('Coverage with source maps', async () => {
122122
t.assert.strictEqual(spawned.code, 1);
123123
});
124124
}
125-
}).then(common.mustCall());
125+
});

test/parallel/test-runner-misc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ if (process.argv[2] === 'child') {
1818
assert.strictEqual(signal.aborted, false);
1919
testSignal = signal;
2020
await setTimeout(50);
21-
})).finally(common.mustCall(() => {
22-
test(() => assert.strictEqual(testSignal.aborted, true));
2321
}));
22+
test(() => assert.strictEqual(testSignal.aborted, true));
2423

2524
// TODO(benjamingr) add more tests to describe + AbortSignal
2625
// this just tests the parameter is passed

test/parallel/test-runner-typechecking.js

Lines changed: 7 additions & 17 deletions

0 commit comments

Comments
 (0)