mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 16:10:07 +00:00
7e9ab58a16
Vitest 5 resolves only with coverage-v8 and coverage-istanbul of the same version, and jest-dom 8 is the first release whose matcher types merge with its Assertion. The sharded CI jobs read and write the blob reports under .vitest/blob, where 5 puts them, and clearMocks stays off as in 4.
56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
import react from '@vitejs/plugin-react';
|
|
import { plyrSpriteAlias } from './plyrSpriteAlias.js';
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
const UI_VERSION = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version;
|
|
|
|
export default defineConfig({
|
|
define: { __TREK_UI_VERSION__: JSON.stringify(UI_VERSION) },
|
|
plugins: [react()],
|
|
test: {
|
|
alias: [plyrSpriteAlias],
|
|
root: '.',
|
|
globals: true,
|
|
// Vitest 5 clears every mock's call history before each test; keep 4's behaviour.
|
|
clearMocks: false,
|
|
environment: './tests/environment/jsdom-native-abort.ts',
|
|
include: [
|
|
'tests/**/*.test.{ts,tsx}',
|
|
'src/**/*.test.{ts,tsx}',
|
|
],
|
|
setupFiles: ['tests/setup.ts'],
|
|
testTimeout: 15000,
|
|
hookTimeout: 15000,
|
|
pool: 'forks',
|
|
// Console output is kept for failing tests and dropped for passing ones: a
|
|
// green run used to print ~30k lines of MSW and act() warnings. `default`
|
|
// prints one line per file and the full detail only for failures; on CI the
|
|
// github-actions reporter adds inline annotations on the PR.
|
|
silent: 'passed-only',
|
|
reporters: process.env.CI ? ['default', 'github-actions'] : ['default'],
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['lcov', 'text'],
|
|
reportsDirectory: './coverage',
|
|
include: ['src/**/*.{ts,tsx}'],
|
|
// All .d.ts, not just vite-env: declaration files carry no executable
|
|
// code, and their lcov entries can't resolve on the Sonar side (its
|
|
// **/*.d.ts exclusion removes them from analysis), which surfaced as
|
|
// "Could not resolve 2 file paths" warnings in every scan.
|
|
exclude: ['src/main.tsx', 'src/**/*.d.ts'],
|
|
// Without these the Client Tests job produced a report, uploaded it and
|
|
// passed no matter what the number was — which is how coverage drifted
|
|
// down to ~48% unnoticed. 85 across the board is the floor we do not want
|
|
// to fall through, not a target: the suite currently sits well above it.
|
|
thresholds: {
|
|
statements: 85,
|
|
branches: 85,
|
|
functions: 85,
|
|
lines: 85,
|
|
},
|
|
},
|
|
css: false,
|
|
},
|
|
});
|