Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/vitest/src/node/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ export abstract class BaseReporter implements Reporter {
)
}

else if (this.ctx.config.hideSkippedTests && (test.mode === 'skip' || test.result?.state === 'skip')) {
// Skipped tests are hidden when --hideSkippedTests
}

// also print skipped tests that have notes
else if (test.result?.state === 'skip' && test.result.note) {
this.log(` ${getStateSymbol(test)} ${getTestName(test)}${c.dim(c.gray(` [${test.result.note}]`))}`)
Expand Down
25 changes: 25 additions & 0 deletions test/reporters/tests/default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,29 @@ describe('default reporter', async () => {
expect(result.stderr).not.toContain(`Serialized Error`)
expect(result.stderr).not.toContain(`status: 'not found'`)
})

test('prints skipped tests by default when a single file is run', async () => {
const { stdout } = await runVitest({
include: ['fixtures/all-passing-or-skipped.test.ts'],
reporters: [['default', { isTTY: true, summary: false }]],
config: 'fixtures/vitest.config.ts',
})

expect(stdout).toContain('✓ fixtures/all-passing-or-skipped.test.ts (2 tests | 1 skipped)')
expect(stdout).toContain('✓ 2 + 3 = 5')
expect(stdout).toContain('↓ 3 + 3 = 6')
})

test('hides skipped tests when --hideSkippedTests and a single file is run', async () => {
const { stdout } = await runVitest({
include: ['fixtures/all-passing-or-skipped.test.ts'],
reporters: [['default', { isTTY: true, summary: false }]],
hideSkippedTests: true,
config: false,
})

expect(stdout).toContain('✓ fixtures/all-passing-or-skipped.test.ts (2 tests | 1 skipped)')
expect(stdout).toContain('✓ 2 + 3 = 5')
expect(stdout).not.toContain('↓ 3 + 3 = 6')
})
}, 120000)
25 changes: 25 additions & 0 deletions test/reporters/tests/verbose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,28 @@ test('prints error properties', async () => {

expect(result.stderr).toContain(`Serialized Error: { code: 404, status: 'not found' }`)
})

test('prints skipped tests by default', async () => {
const { stdout } = await runVitest({
include: ['fixtures/all-passing-or-skipped.test.ts'],
reporters: [['verbose', { isTTY: true, summary: false }]],
config: false,
})

expect(stdout).toContain('✓ fixtures/all-passing-or-skipped.test.ts (2 tests | 1 skipped)')
expect(stdout).toContain('✓ 2 + 3 = 5')
expect(stdout).toContain('↓ 3 + 3 = 6')
})

test('hides skipped tests when --hideSkippedTests', async () => {
const { stdout } = await runVitest({
include: ['fixtures/all-passing-or-skipped.test.ts'],
reporters: [['verbose', { isTTY: true, summary: false }]],
hideSkippedTests: true,
config: false,
})

expect(stdout).toContain('✓ fixtures/all-passing-or-skipped.test.ts (2 tests | 1 skipped)')
expect(stdout).toContain('✓ 2 + 3 = 5')
expect(stdout).not.toContain('↓ 3 + 3 = 6')
})
Loading