test_runner: remove promises returned by t.test() · nodejs/node@1a2eb15 · GitHub
Skip to content

Commit 1a2eb15

Browse files
cjihrigjasnell
authored andcommitted
test_runner: remove promises returned by t.test()
This commit updates the TestContext.prototype.test() API 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 9671826 commit 1a2eb15

11 files changed

Lines changed: 36 additions & 67 deletions

File tree

doc/api/test.md

Lines changed: 26 additions & 36 deletions

lib/internal/test_runner/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ class TestContext {
304304
Test, name, options, fn, overrides,
305305
);
306306

307-
return subtest.start();
307+
subtest.start();
308308
}
309309

310310
before(fn, options) {

test/fixtures/test-runner/output/dot_reporter.snapshot

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ Failed tests:
154154
*
155155
*
156156
*
157-
*
158-
*
159157
✖ subtest sync throw fails (*ms)
160158
'2 subtests failed'
161159
✖ timed out async test (*ms)

test/fixtures/test-runner/output/hooks.snapshot

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ not ok 16 - t.after throws - no subtests
576576
*
577577
*
578578
*
579-
*
580579
...
581580
1..2
582581
not ok 17 - t.beforeEach throws
@@ -607,8 +606,6 @@ not ok 17 - t.beforeEach throws
607606
*
608607
*
609608
*
610-
*
611-
*
612609
...
613610
# Subtest: 2
614611
not ok 2 - 2
@@ -629,7 +626,6 @@ not ok 17 - t.beforeEach throws
629626
*
630627
*
631628
*
632-
*
633629
...
634630
1..2
635631
not ok 18 - t.afterEach throws
@@ -757,7 +753,6 @@ not ok 21 - afterEach context when test fails
757753
*
758754
*
759755
*
760-
*
761756
...
762757
1..2
763758
not ok 22 - afterEach throws and test fails

test/fixtures/test-runner/output/hooks_spec_reporter.snapshot

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@
363363
*
364364
*
365365
*
366-
*
367366

368367
*
369368
1 (*ms)
@@ -376,8 +375,6 @@
376375
*
377376
*
378377
*
379-
*
380-
*
381378

382379
*
383380
2 (*ms)
@@ -391,7 +388,6 @@
391388
*
392389
*
393390
*
394-
*
395391

396392
*
397393
1 (*ms)
@@ -439,7 +435,6 @@
439435
*
440436
*
441437
*
442-
*
443438

444439
*
445440
t.after() is called if test body throws (*ms)

test/fixtures/test-runner/output/junit_reporter.snapshot

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
351351
</testcase>
352352
<testcase name="sync throw fails at second" time="*" classname="test" failure="thrown from subtest sync throw fails at second">
353353
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at second">
354-
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
355-
* {
354+
[Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second] {
356355
code: 'ERR_TEST_FAILURE',
357356
failureType: 'testCodeFailure',
358357
cause: Error: thrown from subtest sync throw fails at second
@@ -362,8 +361,6 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
362361
*
363362
*
364363
*
365-
*
366-
*
367364
}
368365
</failure>
369366
</testcase>

test/fixtures/test-runner/output/output.snapshot

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,6 @@ not ok 51 - custom inspect symbol that throws fail
598598
*
599599
*
600600
*
601-
*
602-
*
603601
...
604602
1..2
605603
not ok 52 - subtest sync throw fails

test/fixtures/test-runner/output/output_cli.snapshot

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,6 @@ not ok 51 - custom inspect symbol that throws fail
606606
*
607607
*
608608
*
609-
*
610-
*
611609
...
612610
1..2
613611
not ok 52 - subtest sync throw fails

test/fixtures/test-runner/output/spec_reporter.snapshot

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,6 @@
285285
*
286286
*
287287
*
288-
*
289-
*
290288

291289
*
292290
timed out async test (*ms)

test/fixtures/test-runner/output/spec_reporter_cli.snapshot

Lines changed: 0 additions & 2 deletions

0 commit comments

Comments
 (0)