From 76ceaffe601f3425dabc04dd8ae2e6e1ba854f8e Mon Sep 17 00:00:00 2001 From: wenzhe Date: Sat, 31 Dec 2022 10:55:00 +0800 Subject: [PATCH] chore: change test --- test/reporters/fixtures/vitest.config.ts | 3 --- test/reporters/tests/custom-reporter.spec.ts | 6 ++++++ test/reporters/tests/reporters.spec.ts | 20 -------------------- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/test/reporters/fixtures/vitest.config.ts b/test/reporters/fixtures/vitest.config.ts index f6be0c1dd611..1b3a79748ed4 100644 --- a/test/reporters/fixtures/vitest.config.ts +++ b/test/reporters/fixtures/vitest.config.ts @@ -1,7 +1,4 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ - test: { - reporters: 'default', - }, }) diff --git a/test/reporters/tests/custom-reporter.spec.ts b/test/reporters/tests/custom-reporter.spec.ts index 9524bf911726..e3598aa361b5 100644 --- a/test/reporters/tests/custom-reporter.spec.ts +++ b/test/reporters/tests/custom-reporter.spec.ts @@ -71,4 +71,10 @@ describe.concurrent('custom reporters', () => { const stdout = await runWithRetry('--config', 'without-custom-reporter.vitest.config.ts', '--reporter', customJSReporterPath) expect(stdout).includes('hello from custom reporter') }, TIMEOUT) + + test('overrides reporters by given a CLI argument --reporter works', async () => { + const stdout = await runWithRetry('--config', 'deps-reporter.vitest.config.ts', '--reporter', customJSReporterPath) + expect(stdout).not.includes('hello from package reporter') + expect(stdout).includes('hello from custom reporter') + }, TIMEOUT) }) diff --git a/test/reporters/tests/reporters.spec.ts b/test/reporters/tests/reporters.spec.ts index c712f676b1b0..d26db9b953b7 100644 --- a/test/reporters/tests/reporters.spec.ts +++ b/test/reporters/tests/reporters.spec.ts @@ -1,7 +1,6 @@ import { existsSync, readFileSync, rmSync } from 'fs' import { afterEach, expect, test, vi } from 'vitest' import { normalize, resolve } from 'pathe' -import { execa } from 'execa' import { JsonReporter } from '../../../packages/vitest/src/node/reporters/json' import { JUnitReporter } from '../../../packages/vitest/src/node/reporters/junit' import { TapReporter } from '../../../packages/vitest/src/node/reporters/tap' @@ -343,25 +342,6 @@ test('json reporter with outputFile object in non-existing directory', async () rmSync(rootDirectory, { recursive: true }) }) -const skip = (process.platform === 'win32' || process.platform === 'darwin') && process.env.CI -const root = resolve(__dirname, '../fixtures') - -test.skipIf(skip)('Cli can overrides reporters by --reporter', async () => { - const { stdout } = await execa('npx', ['vitest', 'run', 'all-passing-or-skipped.test.ts', '--reporter=json'], { - cwd: root, - env: { - ...process.env, - CI: 'true', - NO_COLOR: 'true', - }, - stdio: 'pipe', - }).catch(e => e) - - expect(() => { - JSON.parse(stdout) - }).not.toThrowError() -}, 60_000) - /** * Ensure environment and OS specific paths are consistent in snapshots */