test_runner: simplify hook running logic · nodejs/node@7021b3b · GitHub
Skip to content

Commit 7021b3b

Browse files
cjihrigmarco-ippolito
authored andcommitted
test_runner: simplify hook running logic
This commit removes some asynchronous logic from the runHook() method and replaces ArrayPrototypeReduce() with a for loop. PR-URL: #55963 Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent e99584c commit 7021b3b

5 files changed

Lines changed: 21 additions & 25 deletions

File tree

lib/internal/test_runner/test.js

Lines changed: 4 additions & 4 deletions

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ not ok 2 - 2 after describe
101101
*
102102
*
103103
*
104-
async Promise.all (index 0)
104+
*
105105
...
106106
# Subtest: test 2
107107
not ok 2 - test 2
@@ -122,7 +122,7 @@ not ok 2 - 2 after describe
122122
*
123123
*
124124
*
125-
async Promise.all (index 0)
125+
*
126126
...
127127
1..2
128128
not ok 3 - 3 beforeEach describe

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ not ok 2 - /test/fixtures/test-runner/output/global_after_should_fail_the_test.j
2121
*
2222
*
2323
*
24-
*
2524
...
2625
1..1
2726
# tests 1

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ not ok 3 - before throws
7777
*
7878
*
7979
*
80-
*
8180
...
8281
# Subtest: before throws - no subtests
8382
not ok 4 - before throws - no subtests
@@ -97,7 +96,6 @@ not ok 4 - before throws - no subtests
9796
*
9897
*
9998
*
100-
*
10199
...
102100
# Subtest: after throws
103101
# Subtest: 1
@@ -129,6 +127,7 @@ not ok 5 - after throws
129127
*
130128
*
131129
*
130+
*
132131
...
133132
# Subtest: after throws - no subtests
134133
not ok 6 - after throws - no subtests
@@ -149,6 +148,7 @@ not ok 6 - after throws - no subtests
149148
*
150149
*
151150
*
151+
*
152152
...
153153
# Subtest: beforeEach throws
154154
# Subtest: 1
@@ -167,9 +167,9 @@ not ok 6 - after throws - no subtests
167167
*
168168
*
169169
*
170-
async Promise.all (index 0)
171170
*
172171
*
172+
new Promise (<anonymous>)
173173
...
174174
# Subtest: 2
175175
not ok 2 - 2
@@ -188,6 +188,8 @@ not ok 6 - after throws - no subtests
188188
*
189189
*
190190
*
191+
*
192+
async Promise.all (index 0)
191193
...
192194
1..2
193195
not ok 7 - beforeEach throws
@@ -482,7 +484,6 @@ not ok 15 - t.after throws
482484
*
483485
*
484486
*
485-
*
486487
...
487488
# Subtest: t.after throws - no subtests
488489
not ok 16 - t.after throws - no subtests
@@ -502,7 +503,6 @@ not ok 16 - t.after throws - no subtests
502503
*
503504
*
504505
*
505-
*
506506
...
507507
# Subtest: t.beforeEach throws
508508
# Subtest: 1
@@ -765,7 +765,6 @@ not ok 24 - run after when before throws
765765
*
766766
*
767767
*
768-
*
769768
...
770769
# Subtest: test hooks - async
771770
# Subtest: 1

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

Lines changed: 10 additions & 12 deletions

0 commit comments

Comments
 (0)