Repository navigation
Open
Labels
feature requestIssues requesting new Node.js features.
Description
What is the problem this feature will solve?
Say you have two test files, test/a.js and test/b.js. Both files have the following content:
import { describe, test } from 'node:test'
describe('describe block A', () => {
test('test case A', () => {})
test('test case B', () => {})
})
describe('describe block B', () => {
test('test case A', () => {})
test('test case B', () => {})
})There’s also an empty file named testc.js.
If you run node --test, this emits:
$ node --test
▶ describe block A
✔ test case A (0.408184ms)
✔ test case B (3.565091ms)
✔ describe block A (4.674605ms)
▶ describe block B
✔ test case A (0.087119ms)
✔ test case B (0.06021ms)
✔ describe block B (0.275746ms)
▶ describe block A
✔ test case A (0.410494ms)
✔ test case B (3.642989ms)
✔ describe block A (4.863342ms)
▶ describe block B
✔ test case A (0.193488ms)
✔ test case B (0.120418ms)
✔ describe block B (0.575732ms)
✔ test/c.js (21.739458ms)
ℹ tests 9
ℹ suites 4
ℹ pass 9
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 52.575358The problem here is that test/a.js and test/b.js log the exact same output. It’s not obvious which describe blocks or test cases ran in which file. The status of test/c.js is logged, because it contains no tests.
This example is contrived of course, but it’s not unthinkable that two or more files have the same top-level describe block or test names.
What is the feature you are proposing to solve the problem?
Log a test file name the same way as a describe block:
▶ test/a.js
▶ describe block A
✔ test case A (0.408184ms)
✔ test case B (3.565091ms)
✔ describe block A (4.674605ms)
▶ describe block B
✔ test case A (0.087119ms)
✔ test case B (0.06021ms)
✔ describe block B (0.275746ms)
✔ test/a.js (…ms)
▶ test/b.js
▶ describe block A
✔ test case A (0.410494ms)
✔ test case B (3.642989ms)
✔ describe block A (4.863342ms)
▶ describe block B
✔ test case A (0.193488ms)
✔ test case B (0.120418ms)
✔ describe block B (0.575732ms)
✔ test/b.js (…ms)
✔ test/c.js (21.739458ms)
ℹ tests 9
ℹ suites 4
ℹ pass 9
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 52.575358
What alternatives have you considered?
- The file name could be logged at the top of the bottom of the file’s output without indenting the rest of the output.
- The file name may or may not be omitted from logging if there’s only one test file.
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.
Type
Projects
- StatusShow more project fieldsAwaiting Triage
Activity