Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
Something went wrong. Try again.
6.3 kB · 192 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193import type { TestProjectInlineConfiguration } from 'vitest/config'import Module from 'node:module'import { defineConfig } from 'vitest/config'
const GENERIC_TESTS = 'test/**.test.ts'const V8_TESTS = 'test/**.v8.test.ts'const ISTANBUL_TESTS = 'test/**.istanbul.test.ts'const CUSTOM_TESTS = 'test/**.custom.test.ts'const UNIT_TESTS = 'test/**.unit.test.ts'const BROWSER_TESTS = 'test/**.browser.test.ts'const FIXTURES = '**/fixtures/**'
export default defineConfig({ test: { fsModuleCache: true, watchTriggerPatterns: [ { pattern: /test\/coverage-test\/fixtures/, testsToRun: () => [], }, ], reporters: process.env.CI ? 'minimal' : 'verbose', isolate: false, setupFiles: ['./setup.ts'], projects: [ // Test cases for v8-provider { extends: true, test: { name: { label: 'v8', color: 'green' }, env: { COVERAGE_PROVIDER: 'v8' }, include: [GENERIC_TESTS, V8_TESTS], exclude: [ISTANBUL_TESTS, UNIT_TESTS, CUSTOM_TESTS, BROWSER_TESTS, FIXTURES], }, },
// Test cases for istanbul-provider { extends: true, test: { name: { label: 'istanbul', color: 'magenta' }, env: { COVERAGE_PROVIDER: 'istanbul' }, include: [GENERIC_TESTS, ISTANBUL_TESTS], exclude: [V8_TESTS, UNIT_TESTS, CUSTOM_TESTS, BROWSER_TESTS, FIXTURES], }, },
// Test cases for custom-provider { extends: true, test: { name: { label: 'custom', color: 'yellow' }, env: { COVERAGE_PROVIDER: 'custom' }, include: [CUSTOM_TESTS], exclude: [FIXTURES], }, },
// Test cases for browser. Browser mode itself is activated by COVERAGE_BROWSER env var. { extends: true, test: { name: { label: 'istanbul-browser', color: 'blue' }, env: { COVERAGE_PROVIDER: 'istanbul', COVERAGE_BROWSER: 'true' }, testTimeout: 15_000, include: [ BROWSER_TESTS,
// Other non-provider-specific tests that should be run on browser mode as well '**/all.test.ts', '**/isolation.test.ts', '**/include-exclude.test.ts', '**/allow-external.test.ts', '**/ignore-hints.test.ts', '**/import-attributes.test.ts', '**/pre-transpiled-source.test.ts', '**/multi-suite.test.ts', '**/setup-files.test.ts', '**/results-snapshot.test.ts', '**/reporters.test.ts', '**/temporary-files.test.ts', '**/test-reporter-conflicts.test.ts', '**/vue.test.ts', '**/in-source.test.ts', '**/query-param-transforms.test.ts', '**/test/cjs-dependency.test.ts', '**/test/source-maps.test.ts', '**/test/mock-autospy.test.ts', '**/test/mock-importActual.test.ts', '**/virtual-files.test.ts', ], exclude: [FIXTURES], }, }, { extends: true, test: { name: { label: 'v8-browser', color: 'red' }, env: { COVERAGE_PROVIDER: 'v8', COVERAGE_BROWSER: 'true' }, testTimeout: 15_000, include: [ BROWSER_TESTS,
// Other non-provider-specific tests that should be run on browser mode as well '**/all.test.ts', '**/isolation.test.ts', '**/include-exclude.test.ts', '**/allow-external.test.ts', '**/ignore-hints.test.ts', '**/import-attributes.test.ts', '**/pre-transpiled-source.test.ts', '**/multi-suite.test.ts', '**/setup-files.test.ts', '**/results-snapshot.test.ts', '**/reporters.test.ts', '**/temporary-files.test.ts', '**/test-reporter-conflicts.test.ts', '**/vue.test.ts', '**/in-source.test.ts', '**/query-param-transforms.test.ts', '**/test/cjs-dependency.test.ts', '**/test/source-maps.test.ts', '**/test/mock-autospy.test.ts', '**/test/mock-importActual.test.ts', '**/virtual-files.test.ts', ], exclude: [FIXTURES], }, },
// Test cases for native runner // @ts-expect-error Module.registerHooks is only available in Node.js v21+ ...(Module.registerHooks ? [ { extends: true, test: { name: { label: 'native', color: 'green' }, env: { COVERAGE_PROVIDER: 'v8', VITE_MODULE_RUNNER: 'false' }, include: [GENERIC_TESTS, V8_TESTS], exclude: [ ISTANBUL_TESTS, UNIT_TESTS, CUSTOM_TESTS, BROWSER_TESTS, FIXTURES,
// Unsupported features '**/vue.test.ts', '**/workspace.multi-transform.test.ts', '**/web-worker.test.ts', '**/virtual-files.test.ts', '**/query-param-transforms.test.ts', '**/multi-environment.test.ts', '**/import-meta-env.test.ts', '**/decorators.test.ts', '**/import-attributes.test.ts', ], }, } satisfies TestProjectInlineConfiguration, ] : []),
// Test cases that aren't provider specific { extends: true, test: { name: { label: 'unit', color: 'cyan' }, include: [UNIT_TESTS], typecheck: { enabled: true, include: ['**/test/*.test-d.ts'], tsconfig: '../../tsconfig.check.json', ignoreSourceErrors: true, }, }, }, ], fileParallelism: false, onConsoleLog(log) { if (log.includes('ERROR: Coverage for')) { // Ignore threshold error messages return false }
if (log.includes('Updating thresholds to configuration file.')) { // Ignore threshold updating messages return false } }, },})