Skip to content

Commit bd9cc9d

Browse files
authored
fix: don't print column in test names when includeTaskLocation is enabled (#10681)
1 parent 9a48d92 commit bd9cc9d

7 files changed

Lines changed: 29 additions & 29 deletions

File tree

docs/guide/reporters.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ Example output:
248248
An example with `--includeTaskLocation`:
249249

250250
```bash
251-
✓ __tests__/file1.test.ts:2:1 > first test file > 2 + 2 should equal 4 1ms
252-
✓ __tests__/file1.test.ts:3:1 > first test file > 4 - 2 should equal 2 1ms
253-
✓ __tests__/file2.test.ts:2:1 > second test file > 1 + 1 should equal 2 1ms
254-
✓ __tests__/file2.test.ts:3:1 > second test file > 2 - 1 should equal 1 1ms
251+
✓ __tests__/file1.test.ts:2 > first test file > 2 + 2 should equal 4 1ms
252+
✓ __tests__/file1.test.ts:3 > first test file > 4 - 2 should equal 2 1ms
253+
✓ __tests__/file2.test.ts:2 > second test file > 1 + 1 should equal 2 1ms
254+
✓ __tests__/file2.test.ts:3 > second test file > 2 - 1 should equal 1 1ms
255255

256256
Test Files 2 passed (2)
257257
Tests 4 passed (4)

packages/vitest/src/node/reporters/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export abstract class BaseReporter implements Reporter {
307307

308308
let name = test.file.name
309309
if (test.location) {
310-
name += c.dim(`:${test.location.line}:${test.location.column}`)
310+
name += c.dim(`:${test.location.line}`)
311311
}
312312
name += separator
313313
name += getTestName(test, separator)

packages/vitest/src/node/reporters/verbose.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class VerboseReporter extends DefaultReporter {
2626

2727
title += test.module.task.name
2828
if (test.location) {
29-
title += c.dim(`:${test.location.line}:${test.location.column}`)
29+
title += c.dim(`:${test.location.line}`)
3030
}
3131
title += separator
3232

test/e2e/test/no-module-runner.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ if (import.meta.vitest) {
517517
"
518518
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
519519
520-
FAIL in-source.ts:12:3 > works
520+
FAIL in-source.ts:12 > works
521521
Error: test throws correctly
522522
❯ <anonymous> in-source.ts:13:11
523523
11|

test/e2e/test/public-api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ it.each([
4646

4747
expect(stderr).toBe('')
4848

49-
expect(stdout).toContain('custom.spec.ts:14:1 > custom')
49+
expect(stdout).toContain('custom.spec.ts:14 > custom')
5050

5151
const suiteMeta = { done: true }
5252
const testMeta = { custom: 'some-custom-handler' }

test/e2e/test/reporters/verbose.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,20 @@ test('renders locations if enabled', async () => {
135135
})
136136

137137
expect(trimReporterOutput(stdout)).toMatchInlineSnapshot(`
138-
"✓ fixtures/reporters/verbose/example-1.test.ts:3:1 > test pass in root [...]ms
139-
↓ fixtures/reporters/verbose/example-1.test.ts:5:6 > test skip in root
140-
✓ fixtures/reporters/verbose/example-1.test.ts:8:3 > suite in root > test pass in 1. suite #1 [...]ms
141-
✓ fixtures/reporters/verbose/example-1.test.ts:10:3 > suite in root > test pass in 1. suite #2 [...]ms
142-
✓ fixtures/reporters/verbose/example-1.test.ts:13:5 > suite in root > suite in suite > test pass in nested suite #1 [...]ms
143-
✓ fixtures/reporters/verbose/example-1.test.ts:15:5 > suite in root > suite in suite > test pass in nested suite #2 [...]ms
144-
× fixtures/reporters/verbose/example-1.test.ts:18:7 > suite in root > suite in suite > suite in nested suite > test failure in 2x nested suite [...]ms
138+
"✓ fixtures/reporters/verbose/example-1.test.ts:3 > test pass in root [...]ms
139+
↓ fixtures/reporters/verbose/example-1.test.ts:5 > test skip in root
140+
✓ fixtures/reporters/verbose/example-1.test.ts:8 > suite in root > test pass in 1. suite #1 [...]ms
141+
✓ fixtures/reporters/verbose/example-1.test.ts:10 > suite in root > test pass in 1. suite #2 [...]ms
142+
✓ fixtures/reporters/verbose/example-1.test.ts:13 > suite in root > suite in suite > test pass in nested suite #1 [...]ms
143+
✓ fixtures/reporters/verbose/example-1.test.ts:15 > suite in root > suite in suite > test pass in nested suite #2 [...]ms
144+
× fixtures/reporters/verbose/example-1.test.ts:18 > suite in root > suite in suite > suite in nested suite > test failure in 2x nested suite [...]ms
145145
→ expected 'should fail' to be 'as expected' // Object.is equality
146-
↓ fixtures/reporters/verbose/example-1.test.ts:26:3 > suite skip in root > test 1.3
147-
↓ fixtures/reporters/verbose/example-1.test.ts:29:5 > suite skip in root > suite in suite > test in nested suite
148-
↓ fixtures/reporters/verbose/example-1.test.ts:31:5 > suite skip in root > suite in suite > test failure in nested suite of skipped suite
149-
✓ fixtures/reporters/verbose/example-2.test.ts:3:1 > test 0.1 [...]ms
150-
↓ fixtures/reporters/verbose/example-2.test.ts:5:6 > test 0.2
151-
✓ fixtures/reporters/verbose/example-2.test.ts:8:3 > suite 1.1 > test 1.1 [...]ms"
146+
↓ fixtures/reporters/verbose/example-1.test.ts:26 > suite skip in root > test 1.3
147+
↓ fixtures/reporters/verbose/example-1.test.ts:29 > suite skip in root > suite in suite > test in nested suite
148+
↓ fixtures/reporters/verbose/example-1.test.ts:31 > suite skip in root > suite in suite > test failure in nested suite of skipped suite
149+
✓ fixtures/reporters/verbose/example-2.test.ts:3 > test 0.1 [...]ms
150+
↓ fixtures/reporters/verbose/example-2.test.ts:5 > test 0.2
151+
✓ fixtures/reporters/verbose/example-2.test.ts:8 > suite 1.1 > test 1.1 [...]ms"
152152
`)
153153
})
154154

test/typescript/test/__snapshots__/runner.test.ts.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TypeCheckError: This expression is not callable. Type 'ExpectVoid<number>' has n
1212
`;
1313
1414
exports[`should fail > typecheck files 2`] = `
15-
" FAIL fail.test-d.ts:7:1 > nested suite
15+
" FAIL fail.test-d.ts:7 > nested suite
1616
TypeCheckError: This expression is not callable. Type 'ExpectVoid<number>' has no call signatures.
1717
❯ fail.test-d.ts:15:19
1818
13| })
@@ -23,7 +23,7 @@ TypeCheckError: This expression is not callable. Type 'ExpectVoid<number>' has n
2323
`;
2424
2525
exports[`should fail > typecheck files 3`] = `
26-
" FAIL expect-error.test-d.ts:4:1 > failing test with expect-error
26+
" FAIL expect-error.test-d.ts:4 > failing test with expect-error
2727
TypeCheckError: Unused '@ts-expect-error' directive.
2828
❯ expect-error.test-d.ts:5:3
2929
3| //
@@ -34,7 +34,7 @@ TypeCheckError: Unused '@ts-expect-error' directive.
3434
`;
3535
3636
exports[`should fail > typecheck files 4`] = `
37-
" FAIL fail.test-d.ts:3:1 > failing test
37+
" FAIL fail.test-d.ts:3 > failing test
3838
TypeCheckError: Type 'string' does not satisfy the constraint '"Expected string, Actual number"'.
3939
❯ fail.test-d.ts:4:33
4040
2|
@@ -45,7 +45,7 @@ TypeCheckError: Type 'string' does not satisfy the constraint '"Expected string,
4545
`;
4646
4747
exports[`should fail > typecheck files 5`] = `
48-
" FAIL fail.test-d.ts:9:5 > nested suite > nested 2 > failing test 2
48+
" FAIL fail.test-d.ts:9 > nested suite > nested 2 > failing test 2
4949
TypeCheckError: This expression is not callable. Type 'ExpectVoid<number>' has no call signatures.
5050
❯ fail.test-d.ts:10:23
5151
8| describe('nested 2', () => {
@@ -56,7 +56,7 @@ TypeCheckError: This expression is not callable. Type 'ExpectVoid<number>' has n
5656
`;
5757
5858
exports[`should fail > typecheck files 6`] = `
59-
" FAIL fail.test-d.ts:9:5 > nested suite > nested 2 > failing test 2
59+
" FAIL fail.test-d.ts:9 > nested suite > nested 2 > failing test 2
6060
TypeCheckError: This expression is not callable. Type 'ExpectUndefined<number>' has no call signatures.
6161
❯ fail.test-d.ts:11:23
6262
9| test('failing test 2', () => {
@@ -67,7 +67,7 @@ TypeCheckError: This expression is not callable. Type 'ExpectUndefined<number>'
6767
`;
6868
6969
exports[`should fail > typecheck files 7`] = `
70-
" FAIL js-fail.test-d.js:5:1 > js test fails
70+
" FAIL js-fail.test-d.js:5 > js test fails
7171
TypeCheckError: This expression is not callable. Type 'ExpectArray<number>' has no call signatures.
7272
❯ js-fail.test-d.js:6:19
7373
4|
@@ -78,7 +78,7 @@ TypeCheckError: This expression is not callable. Type 'ExpectArray<number>' has
7878
`;
7979
8080
exports[`should fail > typecheck files 8`] = `
81-
" FAIL node-types.test-d.ts:3:1 > buffer is not available
81+
" FAIL node-types.test-d.ts:3 > buffer is not available
8282
TypeCheckError: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try \`npm i --save-dev @types/node\` and then add 'node' to the types field in your tsconfig.
8383
❯ node-types.test-d.ts:4:3
8484
2|
@@ -89,7 +89,7 @@ TypeCheckError: Cannot find name 'Buffer'. Do you need to install type definitio
8989
`;
9090
9191
exports[`should fail > typecheck files 9`] = `
92-
" FAIL only.test-d.ts:3:1 > failing test
92+
" FAIL only.test-d.ts:3 > failing test
9393
TypeCheckError: Type 'string' does not satisfy the constraint '"Expected string, Actual number"'.
9494
❯ only.test-d.ts:4:33
9595
2|

0 commit comments

Comments
 (0)