Skip to content

Commit

Permalink
test_runner: hide new line when no error in spec reporter
Browse files Browse the repository at this point in the history
PR-URL: #52297
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
  • Loading branch information
MoLow authored Apr 2, 2024
1 parent ac9e5e7 commit e57992f
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 30 deletions.
4 changes: 2 additions & 2 deletions lib/internal/test_runner/reporter/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class SpecReporter extends Transform {
const error = this.#formatError(data.details?.error, indent);
if (hasChildren) {
// If this test has had children - it was already reported, so slightly modify the output
const err = data.details?.error?.failureType === 'subtestsFailed' ? '' : error;
return `${prefix}${indent}${color}${symbols['arrow:right']}${colors.white}${title}\n${err}`;
const err = !error || data.details?.error?.failureType === 'subtestsFailed' ? '' : `\n${error}`;
return `${prefix}${indent}${color}${symbols['arrow:right']}${colors.white}${title}${err}`;
}
if (skip !== undefined) {
color = colors.gray;
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/test-runner/output/default_output.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
[32m'test did not finish before its parent and was cancelled'[39m

[31m▶ [39mparent [90m(*ms)[39m

[34mℹ tests 6[39m
[34mℹ suites 0[39m
[34mℹ pass 1[39m
Expand Down
14 changes: 0 additions & 14 deletions test/fixtures/test-runner/output/hooks_spec_reporter.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
nested 1 (*ms)
nested 2 (*ms)
nested (*ms)

describe hooks (*ms)

describe hooks - no subtests (*ms)
before throws
1
Expand Down Expand Up @@ -96,7 +94,6 @@
*

beforeEach throws (*ms)

afterEach throws
1 (*ms)
Error: afterEach
Expand Down Expand Up @@ -124,7 +121,6 @@
*

afterEach throws (*ms)

afterEach when test fails
1 (*ms)
Error: test
Expand All @@ -141,7 +137,6 @@

2 (*ms)
afterEach when test fails (*ms)

afterEach throws and test fails
1 (*ms)
Error: test
Expand Down Expand Up @@ -169,17 +164,14 @@
*

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)
Expand Down Expand Up @@ -293,7 +285,6 @@
*

t.beforeEach throws (*ms)

t.afterEach throws
1 (*ms)
Error: afterEach
Expand Down Expand Up @@ -322,7 +313,6 @@
*

t.afterEach throws (*ms)

afterEach when test fails
1 (*ms)
Error: test
Expand All @@ -338,11 +328,9 @@

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)
Error: test
Expand All @@ -352,7 +340,6 @@
*

afterEach context when test fails (*ms)

afterEach throws and test fails
1 (*ms)
Error: test
Expand Down Expand Up @@ -380,7 +367,6 @@
*

afterEach throws and test fails (*ms)

t.after() is called if test body throws (*ms)
Error: bye
*
Expand Down
6 changes: 0 additions & 6 deletions test/fixtures/test-runner/output/spec_reporter.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@

this subtest should make its parent test fail
subtest sync throw fail (*ms)

sync throw non-error fail (*ms)
Symbol(thrown symbol from sync throw non-error fail)

Expand All @@ -117,17 +116,14 @@
level 1c (*ms)
level 1d (*ms)
level 0a (*ms)

top level
+long running (*ms)
'test did not finish before its parent and was cancelled'

+short running
++short running (*ms)
+short running (*ms)

top level (*ms)

invalid subtest - pass but subtest fails (*ms)
sync skip option (*ms) # SKIP
sync skip option with message (*ms) # this is skipped
Expand Down Expand Up @@ -197,7 +193,6 @@
'only' and 'runOnly' require the --test-only command-line option.
running subtest 4 (*ms)
only is set but not in only mode (*ms)

'only' and 'runOnly' require the --test-only command-line option.
custom inspect symbol fail (*ms)
customized
Expand Down Expand Up @@ -231,7 +226,6 @@
*

subtest sync throw fails (*ms)

timed out async test (*ms)
'test timed out after *ms'

Expand Down
6 changes: 0 additions & 6 deletions test/fixtures/test-runner/output/spec_reporter_cli.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@

this subtest should make its parent test fail
subtest sync throw fail (*ms)

sync throw non-error fail (*ms)
Symbol(thrown symbol from sync throw non-error fail)

Expand All @@ -117,17 +116,14 @@
level 1c (*ms)
level 1d (*ms)
level 0a (*ms)

top level
+long running (*ms)
'test did not finish before its parent and was cancelled'

+short running
++short running (*ms)
+short running (*ms)

top level (*ms)

invalid subtest - pass but subtest fails (*ms)
sync skip option (*ms) # SKIP
sync skip option with message (*ms) # this is skipped
Expand Down Expand Up @@ -197,7 +193,6 @@
'only' and 'runOnly' require the --test-only command-line option.
running subtest 4 (*ms)
only is set but not in only mode (*ms)

'only' and 'runOnly' require the --test-only command-line option.
custom inspect symbol fail (*ms)
customized
Expand Down Expand Up @@ -231,7 +226,6 @@
*

subtest sync throw fails (*ms)

timed out async test (*ms)
'test timed out after *ms'

Expand Down
1 change: 0 additions & 1 deletion test/fixtures/test-runner/output/suite-skip-hooks.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ AFTER 2
﹣ should not run (*ms) # SKIP
✔ should run 2 (*ms)
▶ suite runs with mixture of skipped tests (*ms)

ℹ tests 4
ℹ suites 2
ℹ pass 2
Expand Down

0 comments on commit e57992f

Please sign in to comment.