Skip to content

Commit e2c3fbf

Browse files
committed
fix(repoters): show test count in suite row like v2 did
1 parent 8e9b8e4 commit e2c3fbf

File tree

5 files changed

+26
-31
lines changed

5 files changed

+26
-31
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Task } from '@vitest/runner'
2-
import { getFullName } from '@vitest/runner/utils'
2+
import { getFullName, getTests } from '@vitest/runner/utils'
33
import c from 'tinyrainbow'
44
import { DefaultReporter } from './default'
55
import { F_RIGHT } from './renderers/figures'
@@ -48,9 +48,10 @@ export class VerboseReporter extends DefaultReporter {
4848

4949
protected printSuite(task: Task): void {
5050
const indentation = ' '.repeat(getIndentation(task))
51+
const tests = getTests(task)
5152
const state = getStateSymbol(task)
5253

53-
this.log(` ${indentation}${state} ${task.name}`)
54+
this.log(` ${indentation}${state} ${task.name} ${c.dim(`(${tests.length})`)}`)
5455
}
5556

5657
protected getTestName(test: Task): string {

test/reporters/fixtures/verbose/example-1.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ test("test pass in root", () => {});
55
test.skip("test skip in root", () => {});
66

77
describe("suite in root", () => {
8-
test("test pass in 1. suite (1)", () => {});
8+
test("test pass in 1. suite #1", () => {});
99

10-
test("test pass in 1. suite (2)", () => {});
10+
test("test pass in 1. suite #2", () => {});
1111

1212
describe("suite in suite", () => {
13-
test("test pass in nested suite (1)", () => {});
13+
test("test pass in nested suite #1", () => {});
1414

15-
test("test pass in nested suite (2)", () => {});
15+
test("test pass in nested suite #2", () => {});
1616

1717
describe("suite in nested suite", () => {
1818
test("test failure in 2x nested suite", () => {
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import { test, describe } from "vitest";
22

3-
test("test 0.1", () => {
4-
//
5-
});
3+
test("test 0.1", () => {});
64

7-
test.skip("test 0.2", () => {
8-
//
9-
});
5+
test.skip("test 0.2", () => {});
106

117
describe("suite 1.1", () => {
12-
test("test 1.1", () => {
13-
//
14-
});
8+
test("test 1.1", () => {});
159
});

test/reporters/tests/merge-reports.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ test('merge reports', async () => {
100100
❯ second.test.ts (3 tests | 1 failed) <time>
101101
× test 2-1 <time>
102102
→ expected 1 to be 2 // Object.is equality
103-
✓ group > test 2-2
104-
✓ group > test 2-3
103+
✓ group > test 2-2
104+
✓ group > test 2-3
105105
106106
Test Files 2 failed (2)
107107
Tests 2 failed | 3 passed (5)

test/reporters/tests/verbose.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,24 @@ test('renders tree when in TTY', async () => {
9696
"❯ fixtures/verbose/example-1.test.ts (10 tests | 1 failed | 4 skipped) [...]ms
9797
✓ test pass in root
9898
↓ test skip in root
99-
❯ suite in root
100-
✓ test pass in 1. suite (1)
101-
✓ test pass in 1. suite (2)
102-
❯ suite in suite
103-
✓ test pass in nested suite (1)
104-
✓ test pass in nested suite (2)
105-
❯ suite in nested suite
99+
❯ suite in root (5)
100+
✓ test pass in 1. suite #1
101+
✓ test pass in 1. suite #2
102+
❯ suite in suite (3)
103+
✓ test pass in nested suite #1
104+
✓ test pass in nested suite #2
105+
❯ suite in nested suite (1)
106106
× test failure in 2x nested suite [...]ms
107107
→ expected 'should fail' to be 'as expected' // Object.is equality
108-
↓ suite skip in root
108+
↓ suite skip in root (3)
109109
↓ test 1.3
110-
↓ suite in suite
110+
↓ suite in suite (2)
111111
↓ test in nested suite
112112
↓ test failure in nested suite of skipped suite
113113
✓ fixtures/verbose/example-2.test.ts (3 tests | 1 skipped) [...]ms
114114
✓ test 0.1
115115
↓ test 0.2
116-
✓ suite 1.1
116+
✓ suite 1.1 (1)
117117
✓ test 1.1"
118118
`)
119119
})
@@ -139,10 +139,10 @@ test('does not render tree when in non-TTY', async () => {
139139

140140
expect(trimReporterOutput(stdout)).toMatchInlineSnapshot(`
141141
"✓ fixtures/verbose/example-1.test.ts > test pass in root
142-
✓ fixtures/verbose/example-1.test.ts > suite in root > test pass in 1. suite (1)
143-
✓ fixtures/verbose/example-1.test.ts > suite in root > test pass in 1. suite (2)
144-
✓ fixtures/verbose/example-1.test.ts > suite in root > suite in suite > test pass in nested suite (1)
145-
✓ fixtures/verbose/example-1.test.ts > suite in root > suite in suite > test pass in nested suite (2)
142+
✓ fixtures/verbose/example-1.test.ts > suite in root > test pass in 1. suite #1
143+
✓ fixtures/verbose/example-1.test.ts > suite in root > test pass in 1. suite #2
144+
✓ fixtures/verbose/example-1.test.ts > suite in root > suite in suite > test pass in nested suite #1
145+
✓ fixtures/verbose/example-1.test.ts > suite in root > suite in suite > test pass in nested suite #2
146146
× fixtures/verbose/example-1.test.ts > suite in root > suite in suite > suite in nested suite > test failure in 2x nested suite
147147
→ expected 'should fail' to be 'as expected' // Object.is equality
148148
✓ fixtures/verbose/example-2.test.ts > test 0.1

0 commit comments

Comments
 (0)