mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
71 lines
1.7 KiB
JavaScript
71 lines
1.7 KiB
JavaScript
import { startVitest } from 'vitest/node'
|
|
|
|
/** @type {Record<string, Partial<import('vitest/config').UserConfig['test']>>[]} */
|
|
const testCases = [
|
|
{
|
|
testConfig: {
|
|
name: 'allowExternal: true',
|
|
include: ['option-tests/allow-external.test.ts'],
|
|
coverage: {
|
|
allowExternal: true,
|
|
include: ['**/src/**', '**/test-utils/fixtures/**'],
|
|
reporter: 'html',
|
|
},
|
|
},
|
|
assertionConfig: {
|
|
include: ['coverage-report-tests/allow-external.test.ts'],
|
|
env: { VITE_COVERAGE_ALLOW_EXTERNAL: true },
|
|
},
|
|
},
|
|
{
|
|
testConfig: {
|
|
name: 'allowExternal: false',
|
|
include: ['option-tests/allow-external.test.ts'],
|
|
coverage: {
|
|
allowExternal: false,
|
|
include: ['**/src/**', '**/test-utils/fixtures/**'],
|
|
reporter: 'html',
|
|
},
|
|
},
|
|
assertionConfig: {
|
|
include: ['coverage-report-tests/allow-external.test.ts'],
|
|
},
|
|
},
|
|
]
|
|
|
|
for (const provider of ['v8', 'istanbul']) {
|
|
for (const { testConfig, assertionConfig } of testCases) {
|
|
// Run test case
|
|
await startVitest('test', ['option-tests/'], {
|
|
config: false,
|
|
watch: false,
|
|
...testConfig,
|
|
name: `${provider} - ${testConfig.name}`,
|
|
coverage: {
|
|
enabled: true,
|
|
clean: true,
|
|
all: false,
|
|
provider,
|
|
...testConfig.coverage,
|
|
},
|
|
})
|
|
|
|
checkExit()
|
|
|
|
// Check generated coverage report
|
|
await startVitest('test', ['coverage-report-tests'], {
|
|
config: false,
|
|
watch: false,
|
|
...assertionConfig,
|
|
name: `${provider} - assert ${testConfig.name}`,
|
|
})
|
|
|
|
checkExit()
|
|
}
|
|
}
|
|
|
|
function checkExit() {
|
|
if (process.exitCode)
|
|
process.exit(process.exitCode)
|
|
}
|