-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
test_runner: display coverage errors in dot reporter #64695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
elephant-y
wants to merge
2
commits into
nodejs:main
Choose a base branch
from
elephant-y:fix/dot-reporter-coverage-errors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+206
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| 'use strict'; | ||
| require('../../../common'); | ||
| const fixtures = require('../../../common/fixtures'); | ||
| const spawn = require('node:child_process').spawn; | ||
|
|
||
| spawn( | ||
| process.execPath, | ||
| [ | ||
| '--no-warnings', | ||
| '--test-reporter', 'dot', | ||
| '--experimental-test-coverage', | ||
| '--test-coverage-lines=100', | ||
| '--test-coverage-branches=100', | ||
| '--test-coverage-functions=100', | ||
| fixtures.path('test-runner/output/output.js'), | ||
| ], | ||
| { stdio: 'inherit' }, | ||
| ); |
168 changes: 168 additions & 0 deletions
168
test/fixtures/test-runner/output/dot_reporter_coverage.snapshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| ........XX...X..XXX. | ||
| X.....XXX........... | ||
| .X.........X...XXX.X | ||
| X.....XXXXXXX...XXXX | ||
| X | ||
|
|
||
| Failed tests: | ||
|
|
||
| ⚠ sync fail todo (*ms) # TODO | ||
| Error: thrown from sync fail todo | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:42:9) | ||
| at <node-internal-frames> | ||
| ⚠ sync fail todo with message (*ms) # this is a failing todo | ||
| Error: thrown from sync fail todo with message | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:47:9) | ||
| at <node-internal-frames> | ||
| ✖ sync throw fail (*ms) | ||
| Error: thrown from sync throw fail | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:63:9) | ||
| at <node-internal-frames> | ||
| ✖ async throw fail (*ms) | ||
| Error: thrown from async throw fail | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:75:9) | ||
| at <node-internal-frames> | ||
| ﹣ async skip fail (*ms) # SKIP | ||
| Error: thrown from async throw fail | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:80:9) | ||
| at <node-internal-frames> | ||
| ✖ async assertion fail (*ms) | ||
| AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: | ||
|
|
||
| true !== false | ||
|
|
||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:85:10) | ||
| at <node-internal-frames> | ||
| at <node-internal-frames> { | ||
| generatedMessage: true, | ||
| code: 'ERR_ASSERTION', | ||
| actual: true, | ||
| expected: false, | ||
| operator: 'strictEqual', | ||
| diff: 'simple' | ||
| } | ||
| ✖ reject fail (*ms) | ||
| Error: rejected from reject fail | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:93:25) | ||
| at <node-internal-frames> | ||
| ✖ +sync throw fail (*ms) | ||
| Error: thrown from subtest sync throw fail | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:127:11) | ||
| at <node-internal-frames> | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:125:11) | ||
| at <node-internal-frames> | ||
| ✖ subtest sync throw fail (*ms) | ||
| '1 subtest failed' | ||
| ✖ sync throw non-error fail (*ms) | ||
| Symbol(thrown symbol from sync throw non-error fail) | ||
| ✖ sync skip option is false fail (*ms) | ||
| Error: this should be executed | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:212:9) | ||
| at <node-internal-frames> | ||
| ✖ callback fail (*ms) | ||
| Error: callback failure | ||
| at Immediate.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:245:10) | ||
| at <node-internal-frames> | ||
| ✖ callback also returns a Promise (*ms) | ||
| 'passed a callback but also returned a Promise' | ||
| ✖ callback throw (*ms) | ||
| Error: thrown from callback throw | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:267:9) | ||
| at <node-internal-frames> | ||
| ✖ callback called twice (*ms) | ||
| 'callback invoked multiple times' | ||
| ✖ callback called twice in future tick (*ms) | ||
| Error [ERR_TEST_FAILURE]: callback invoked multiple times | ||
| at Immediate.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:283:5) { | ||
| code: 'ERR_TEST_FAILURE', | ||
| failureType: 'multipleCallbackInvocations', | ||
| cause: 'callback invoked multiple times' | ||
| } | ||
| ✖ callback async throw (*ms) | ||
| Error: thrown from callback async throw | ||
| at Immediate.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:289:11) | ||
| at <node-internal-frames> | ||
| ✖ custom inspect symbol fail (*ms) | ||
| customized | ||
| ✖ custom inspect symbol that throws fail (*ms) | ||
| { foo: 1, Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]] } | ||
| ✖ sync throw fails at first (*ms) | ||
| Error: thrown from subtest sync throw fails at first | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:335:11) | ||
| at <node-internal-frames> | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:334:11) | ||
| at <node-internal-frames> | ||
| ✖ sync throw fails at second (*ms) | ||
| Error: thrown from subtest sync throw fails at second | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:338:11) | ||
| at <node-internal-frames> | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:337:11) | ||
| at <node-internal-frames> | ||
| ✖ subtest sync throw fails (*ms) | ||
| '2 subtests failed' | ||
| ✖ timed out async test (*ms) | ||
| 'test timed out after *ms' | ||
| ✖ timed out callback test (*ms) | ||
| 'test timed out after *ms' | ||
| ✖ rejected thenable (*ms) | ||
| 'custom error' | ||
| ✖ unfinished test with uncaughtException (*ms) | ||
| Error: foo | ||
| at Timeout._onTimeout (<project-root>/test/fixtures/test-runner/output/output.js:393:30) | ||
| at <node-internal-frames> | ||
| ✖ unfinished test with unhandledRejection (*ms) | ||
| Error: bar | ||
| at Timeout._onTimeout (<project-root>/test/fixtures/test-runner/output/output.js:399:37) | ||
| at <node-internal-frames> | ||
| ✖ assertion errors display actual and expected properly (*ms) | ||
| AssertionError [ERR_ASSERTION]: Expected values to be loosely deep-equal: | ||
|
|
||
| { | ||
| bar: 1, | ||
| baz: { | ||
| date: 1970-01-01T00:00:00.000Z, | ||
| null: null, | ||
| number: 1, | ||
| string: 'Hello', | ||
| undefined: undefined | ||
| }, | ||
| boo: [ | ||
| 1 | ||
| ], | ||
| foo: 1 | ||
| } | ||
|
|
||
| should loosely deep-equal | ||
|
|
||
| { | ||
| baz: { | ||
| date: 1970-01-01T00:00:00.000Z, | ||
| null: null, | ||
| number: 1, | ||
| string: 'Hello', | ||
| undefined: undefined | ||
| }, | ||
| boo: [ | ||
| 1 | ||
| ], | ||
| circular: <ref *1> { | ||
| bar: 2, | ||
| c: [Circular *1] | ||
| } | ||
| } | ||
| at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:425:12) { | ||
| generatedMessage: true, | ||
| code: 'ERR_ASSERTION', | ||
| actual: [Object], | ||
| expected: [Object], | ||
| operator: 'deepEqual', | ||
| diff: 'simple' | ||
| } | ||
| ✖ invalid subtest fail (*ms) | ||
| 'test could not be created because its parent finished' | ||
|
|
||
| Diagnostic errors: | ||
|
|
||
| Error: *% line coverage does not meet threshold of 100.00%. | ||
| Error: *% branch coverage does not meet threshold of 100.00%. | ||
| Error: *% function coverage does not meet threshold of 100.00%. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Test that dot reporter output with coverage includes diagnostic errors | ||
| import '../common/index.mjs'; | ||
| import * as fixtures from '../common/fixtures.mjs'; | ||
| import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; | ||
|
|
||
| ensureCwdIsProjectRoot(); | ||
| await spawnAndAssert( | ||
| fixtures.path('test-runner/output/dot_reporter_coverage.js'), | ||
| specTransform, | ||
| ); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to yield in place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dot reporter is designed to be minimal — yielding diagnostic errors inline would break the dot grid alignment mid-run. This is the same pattern used by failedTests, which also collects and displays at the end rather than yielding inline. Keeping the output clean during the run, then showing errors after, is consistent with the dot reporter's philosophy.