mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-27 10:42:25 +02:00
Configure test file sorter to place specific files earlier
This commit is contained in:
parent
b27f91390f
commit
46e5c8ab8b
@ -1,11 +1,51 @@
|
|||||||
import { defineProject } from "vitest/config";
|
import { defineProject } from "vitest/config";
|
||||||
import { defaultConfig } from "./vite.config";
|
import { defaultConfig } from "./vite.config";
|
||||||
|
import { BaseSequencer } from "vitest/node";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper function for sorting test files in a desired order.
|
||||||
|
*
|
||||||
|
* A lower number means that a test file must be run earlier,
|
||||||
|
* or else it breaks due to running tests with `--no-isolate.`
|
||||||
|
*/
|
||||||
|
function getTestOrder(testName: string): number {
|
||||||
|
if (testName.includes("battle_scene.test.ts")) {
|
||||||
|
return 1;
|
||||||
|
} else if (testName.includes("inputs.test.ts")) {
|
||||||
|
return 2;
|
||||||
|
} else {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default defineProject(({ mode }) => ({
|
export default defineProject(({ mode }) => ({
|
||||||
...defaultConfig,
|
...defaultConfig,
|
||||||
test: {
|
test: {
|
||||||
testTimeout: 20000,
|
testTimeout: 20000,
|
||||||
setupFiles: ["./test/fontFace.setup.ts", "./test/vitest.setup.ts"],
|
setupFiles: ["./test/fontFace.setup.ts", "./test/vitest.setup.ts"],
|
||||||
|
server: {
|
||||||
|
deps: {
|
||||||
|
inline: ["vitest-canvas-mock"],
|
||||||
|
optimizer: {
|
||||||
|
web: {
|
||||||
|
include: ["vitest-canvas-mock"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sequence: {
|
||||||
|
sequencer: class Seqencer extends BaseSequencer {
|
||||||
|
async sort(files: [any, string][]) {
|
||||||
|
files = await super.sort(files);
|
||||||
|
|
||||||
|
// Sort files so that `inputs.test.ts` gets run first; otherwise, `inputs.test.ts` randomly breaks
|
||||||
|
return files.sort((a, b) => {
|
||||||
|
return getTestOrder(a[1]) - getTestOrder(b[1]);
|
||||||
|
b;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
environment: "jsdom" as const,
|
environment: "jsdom" as const,
|
||||||
environmentOptions: {
|
environmentOptions: {
|
||||||
jsdom: {
|
jsdom: {
|
||||||
|
Loading…
Reference in New Issue
Block a user