|
1 | 1 | import { defineConfig } from 'vitest/config' |
2 | 2 |
|
| 3 | +const GENERIC_TESTS = 'test/**.test.ts' |
| 4 | +const V8_TESTS = 'test/**.v8.test.ts' |
| 5 | +const ISTANBUL_TESTS = 'test/**.istanbul.test.ts' |
| 6 | +const CUSTOM_TESTS = 'test/**.custom.test.ts' |
| 7 | +const UNIT_TESTS = 'test/**.unit.test.ts' |
| 8 | +const BROWSER_TESTS = 'test/**.browser.test.ts' |
| 9 | + |
| 10 | +const config = defineConfig({ |
| 11 | + test: { |
| 12 | + pool: 'threads', |
| 13 | + setupFiles: ['./setup.ts'], |
| 14 | + }, |
| 15 | +}) |
| 16 | + |
3 | 17 | export default defineConfig({ |
4 | 18 | test: { |
5 | 19 | reporters: 'verbose', |
6 | 20 | isolate: false, |
| 21 | + projects: [ |
| 22 | + // Test cases for v8-provider |
| 23 | + { |
| 24 | + test: { |
| 25 | + ...config.test, |
| 26 | + name: { label: 'v8', color: 'green' }, |
| 27 | + env: { COVERAGE_PROVIDER: 'v8' }, |
| 28 | + include: [GENERIC_TESTS, V8_TESTS], |
| 29 | + exclude: [ |
| 30 | + ISTANBUL_TESTS, |
| 31 | + UNIT_TESTS, |
| 32 | + CUSTOM_TESTS, |
| 33 | + BROWSER_TESTS, |
| 34 | + ], |
| 35 | + }, |
| 36 | + }, |
| 37 | + |
| 38 | + // Test cases for istanbul-provider |
| 39 | + { |
| 40 | + test: { |
| 41 | + ...config.test, |
| 42 | + name: { label: 'istanbul', color: 'magenta' }, |
| 43 | + env: { COVERAGE_PROVIDER: 'istanbul' }, |
| 44 | + include: [GENERIC_TESTS, ISTANBUL_TESTS], |
| 45 | + exclude: [ |
| 46 | + V8_TESTS, |
| 47 | + UNIT_TESTS, |
| 48 | + CUSTOM_TESTS, |
| 49 | + BROWSER_TESTS, |
| 50 | + ], |
| 51 | + }, |
| 52 | + }, |
| 53 | + |
| 54 | + // Test cases for custom-provider |
| 55 | + { |
| 56 | + test: { |
| 57 | + ...config.test, |
| 58 | + name: { label: 'custom', color: 'yellow' }, |
| 59 | + env: { COVERAGE_PROVIDER: 'custom' }, |
| 60 | + include: [CUSTOM_TESTS], |
| 61 | + }, |
| 62 | + }, |
| 63 | + |
| 64 | + // Test cases for browser. Browser mode itself is activated by COVERAGE_BROWSER env var. |
| 65 | + { |
| 66 | + test: { |
| 67 | + ...config.test, |
| 68 | + name: { label: 'istanbul-browser', color: 'blue' }, |
| 69 | + env: { COVERAGE_PROVIDER: 'istanbul', COVERAGE_BROWSER: 'true' }, |
| 70 | + include: [ |
| 71 | + BROWSER_TESTS, |
| 72 | + |
| 73 | + // Other non-provider-specific tests that should be run on browser mode as well |
| 74 | + '**/all.test.ts', |
| 75 | + '**/isolation.test.ts', |
| 76 | + '**/include-exclude.test.ts', |
| 77 | + '**/allow-external.test.ts', |
| 78 | + '**/ignore-hints.test.ts', |
| 79 | + '**/import-attributes.test.ts', |
| 80 | + '**/pre-transpiled-source.test.ts', |
| 81 | + '**/multi-suite.test.ts', |
| 82 | + '**/setup-files.test.ts', |
| 83 | + '**/results-snapshot.test.ts', |
| 84 | + '**/reporters.test.ts', |
| 85 | + '**/temporary-files.test.ts', |
| 86 | + '**/test-reporter-conflicts.test.ts', |
| 87 | + '**/vue.test.ts', |
| 88 | + '**/in-source.test.ts', |
| 89 | + ], |
| 90 | + }, |
| 91 | + }, |
| 92 | + { |
| 93 | + test: { |
| 94 | + ...config.test, |
| 95 | + name: { label: 'v8-browser', color: 'red' }, |
| 96 | + env: { COVERAGE_PROVIDER: 'v8', COVERAGE_BROWSER: 'true' }, |
| 97 | + include: [ |
| 98 | + BROWSER_TESTS, |
| 99 | + |
| 100 | + // Other non-provider-specific tests that should be run on browser mode as well |
| 101 | + '**/all.test.ts', |
| 102 | + '**/isolation.test.ts', |
| 103 | + '**/include-exclude.test.ts', |
| 104 | + '**/allow-external.test.ts', |
| 105 | + '**/ignore-hints.test.ts', |
| 106 | + '**/import-attributes.test.ts', |
| 107 | + '**/pre-transpiled-source.test.ts', |
| 108 | + '**/multi-suite.test.ts', |
| 109 | + '**/setup-files.test.ts', |
| 110 | + '**/results-snapshot.test.ts', |
| 111 | + '**/reporters.test.ts', |
| 112 | + '**/temporary-files.test.ts', |
| 113 | + '**/test-reporter-conflicts.test.ts', |
| 114 | + '**/vue.test.ts', |
| 115 | + '**/in-source.test.ts', |
| 116 | + ], |
| 117 | + }, |
| 118 | + }, |
| 119 | + |
| 120 | + // Test cases that aren't provider specific |
| 121 | + { |
| 122 | + test: { |
| 123 | + ...config.test, |
| 124 | + name: { label: 'unit', color: 'cyan' }, |
| 125 | + include: [UNIT_TESTS], |
| 126 | + typecheck: { |
| 127 | + enabled: true, |
| 128 | + include: ['**/test/*.test-d.ts'], |
| 129 | + tsconfig: '../../tsconfig.check.json', |
| 130 | + ignoreSourceErrors: true, |
| 131 | + }, |
| 132 | + }, |
| 133 | + }, |
| 134 | + ], |
7 | 135 | poolOptions: { |
8 | 136 | threads: { |
9 | 137 | // Tests may have side effects, e.g. writing files to disk, |
|
0 commit comments