pokerogue/vitest.config.ts
flx-sta e17bf592c2
[Bug] Use silent mode during tests (unless debugging!) + test workflow optimization (#4154)
* add :silent to all tests

but disable it if the runner is in debug mode!

* fix: use `--silent` instead of `:silent`

Cause the previous was npm scrpt specific (whops)

* remove env and replace with logic in each call

* reduce redundancy by checking out once

* move pre-test into `needs` after `checkout`

* use cache approach in pre-test

* add node.js install step to `setup` job

* WIP: setup -> pre-test -> all other tests

with using cache

* use matrix approach for tests

* fix matrix approach for tests

* fix wrong use of env var in `run-test-template.yml`

* test: out-comment `run-tests` to see whats wrong

* test: see if this works

* let's try using matrix again...

* make `node-version` input a string

* remove `node-version` input for now

* test: without a matrix fornow

* change usage of reuseable workflow call

* fix call of matrix.project

* try using working-dir

* try setup for pre-tests

* remove `runs-on` from run-tests

* fix some identations for run-tests

* add pre-test as requirement for running tests

* use `1` instead of `'1'` to check `runner.debug`

* add `options` input. Possible fix for debug = not silent

* try again...

* not as an ENV but inside

* move 2nd ${{ !runner.debug && '--silent' }} check into test-template

* fix printing `false` instead of empty-string on runner-debug check

* try a yml array approach

* test running with file include path

* make `project` always `main` for now

* remove all extra vitest workspaces

* adopt `shards` workflow in vitest

* fix workflow reference in tests.yml

* add missing `$` in test-shard-template.yml`

* chore: fix vitest.config.ts after merge

man.. cant trust these machines

* make `project` a variable. try to use inputs on job names

* adjust `test-shard-template` job name
2024-09-10 22:13:42 +01:00

43 lines
1.0 KiB
TypeScript

import { defineProject } from "vitest/config";
import { defaultConfig } from "./vite.config";
export default defineProject(({ mode }) => ({
...defaultConfig,
test: {
setupFiles: ["./src/test/fontFace.setup.ts", "./src/test/vitest.setup.ts"],
server: {
deps: {
inline: ["vitest-canvas-mock"],
//@ts-ignore
optimizer: {
web: {
include: ["vitest-canvas-mock"],
},
},
},
},
environment: "jsdom" as const,
environmentOptions: {
jsdom: {
resources: "usable",
},
},
threads: false,
trace: true,
restoreMocks: true,
watch: false,
coverage: {
provider: "istanbul" as const,
reportsDirectory: "coverage" as const,
reporters: ["text-summary", "html"],
},
name: "main",
include: ["./src/test/**/*.{test,spec}.ts"],
exclude: ["./src/test/pre.test.ts"],
},
esbuild: {
pure: mode === "production" ? ["console.log"] : [],
keepNames: true,
},
}));