Skip to content

Commit

Permalink
chore: change test
Browse files Browse the repository at this point in the history
  • Loading branch information
mysteryven committed Dec 31, 2022
1 parent 20f0c47 commit 76ceaff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
3 changes: 0 additions & 3 deletions test/reporters/fixtures/vitest.config.ts
@@ -1,7 +1,4 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
reporters: 'default',
},
})
6 changes: 6 additions & 0 deletions test/reporters/tests/custom-reporter.spec.ts
Expand Up @@ -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)
})
20 changes: 0 additions & 20 deletions 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'
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 76ceaff

Please sign in to comment.