pokerogue/vitest.config.ts
Sirz Benjie 35e733e87a
[Test] [Refactor] [GitHub] Enable no isolate for vitest (#5566)
* Reuse global scene between tests

Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>

* Add missing each method to mockContainer

* Fix select-modifier-phase test

* Sanitize overrides before tests

Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>

* Sanitize overrides before tests

Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>

* [WIP] fix things

* Fix tests not working with --no-isolate

* Update npm tests to use no isolate

* Update test-shard-template

* Update package.json

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

---------

Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-03-28 17:30:38 -04:00

54 lines
1.4 KiB
TypeScript

import { defineProject } from "vitest/config";
import { defaultConfig } from "./vite.config";
import { BaseSequencer, type TestSpecification } from "vitest/node";
function getTestOrder(testName: string): number {
if (testName.includes("battle-scene.test.ts")) {
return 1;
}
if (testName.includes("inputs.test.ts")) {
return 2;
}
return 3;
}
export default defineProject(({ mode }) => ({
...defaultConfig,
test: {
testTimeout: 20000,
setupFiles: ["./test/fontFace.setup.ts", "./test/vitest.setup.ts"],
sequence: {
sequencer: class CustomSequencer extends BaseSequencer {
async sort(files: TestSpecification[]) {
// use default sorting at first.
files = await super.sort(files);
// Except, forcibly reorder
return files.sort((a, b) => getTestOrder(a.moduleId) - getTestOrder(b.moduleId));
}
},
},
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: ["./test/**/*.{test,spec}.ts"],
},
esbuild: {
pure: mode === "production" ? ["console.log"] : [],
keepNames: true,
},
}));