Skip to content

Commit 721a5b8

Browse files
authoredDec 1, 2024··
fix(reporters): check --hideSkippedTests in base reporter (#6988)
1 parent 1fa16f9 commit 721a5b8

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
 

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

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ export abstract class BaseReporter implements Reporter {
134134
)
135135
}
136136

137+
else if (this.ctx.config.hideSkippedTests && (test.mode === 'skip' || test.result?.state === 'skip')) {
138+
// Skipped tests are hidden when --hideSkippedTests
139+
}
140+
137141
// also print skipped tests that have notes
138142
else if (test.result?.state === 'skip' && test.result.note) {
139143
this.log(` ${getStateSymbol(test)} ${getTestName(test)}${c.dim(c.gray(` [${test.result.note}]`))}`)

‎test/reporters/tests/default.test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,29 @@ describe('default reporter', async () => {
6969
expect(result.stderr).not.toContain(`Serialized Error`)
7070
expect(result.stderr).not.toContain(`status: 'not found'`)
7171
})
72+
73+
test('prints skipped tests by default when a single file is run', async () => {
74+
const { stdout } = await runVitest({
75+
include: ['fixtures/all-passing-or-skipped.test.ts'],
76+
reporters: [['default', { isTTY: true, summary: false }]],
77+
config: 'fixtures/vitest.config.ts',
78+
})
79+
80+
expect(stdout).toContain('✓ fixtures/all-passing-or-skipped.test.ts (2 tests | 1 skipped)')
81+
expect(stdout).toContain('✓ 2 + 3 = 5')
82+
expect(stdout).toContain('↓ 3 + 3 = 6')
83+
})
84+
85+
test('hides skipped tests when --hideSkippedTests and a single file is run', async () => {
86+
const { stdout } = await runVitest({
87+
include: ['fixtures/all-passing-or-skipped.test.ts'],
88+
reporters: [['default', { isTTY: true, summary: false }]],
89+
hideSkippedTests: true,
90+
config: false,
91+
})
92+
93+
expect(stdout).toContain('✓ fixtures/all-passing-or-skipped.test.ts (2 tests | 1 skipped)')
94+
expect(stdout).toContain('✓ 2 + 3 = 5')
95+
expect(stdout).not.toContain('↓ 3 + 3 = 6')
96+
})
7297
}, 120000)

‎test/reporters/tests/verbose.test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,28 @@ test('prints error properties', async () => {
2424

2525
expect(result.stderr).toContain(`Serialized Error: { code: 404, status: 'not found' }`)
2626
})
27+
28+
test('prints skipped tests by default', async () => {
29+
const { stdout } = await runVitest({
30+
include: ['fixtures/all-passing-or-skipped.test.ts'],
31+
reporters: [['verbose', { isTTY: true, summary: false }]],
32+
config: false,
33+
})
34+
35+
expect(stdout).toContain('✓ fixtures/all-passing-or-skipped.test.ts (2 tests | 1 skipped)')
36+
expect(stdout).toContain('✓ 2 + 3 = 5')
37+
expect(stdout).toContain('↓ 3 + 3 = 6')
38+
})
39+
40+
test('hides skipped tests when --hideSkippedTests', async () => {
41+
const { stdout } = await runVitest({
42+
include: ['fixtures/all-passing-or-skipped.test.ts'],
43+
reporters: [['verbose', { isTTY: true, summary: false }]],
44+
hideSkippedTests: true,
45+
config: false,
46+
})
47+
48+
expect(stdout).toContain('✓ fixtures/all-passing-or-skipped.test.ts (2 tests | 1 skipped)')
49+
expect(stdout).toContain('✓ 2 + 3 = 5')
50+
expect(stdout).not.toContain('↓ 3 + 3 = 6')
51+
})

0 commit comments

Comments
 (0)
Please sign in to comment.