diff --git a/packages/vitest/src/node/reporters/base.ts b/packages/vitest/src/node/reporters/base.ts index 2847a4e21c10..1f4cf9edbf7c 100644 --- a/packages/vitest/src/node/reporters/base.ts +++ b/packages/vitest/src/node/reporters/base.ts @@ -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}]`))}`) diff --git a/test/reporters/tests/default.test.ts b/test/reporters/tests/default.test.ts index cb641423e0fe..7fac2612734e 100644 --- a/test/reporters/tests/default.test.ts +++ b/test/reporters/tests/default.test.ts @@ -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) diff --git a/test/reporters/tests/verbose.test.ts b/test/reporters/tests/verbose.test.ts index 59e08dff6b4c..7c760147ca5e 100644 --- a/test/reporters/tests/verbose.test.ts +++ b/test/reporters/tests/verbose.test.ts @@ -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') +})