mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-06 07:29:30 +02:00
* Added rudimentary test matchers for `toEqualArrayUnsorted` and `toHaveTypes` Might port the rest at a later date * Actually run the effing setup matchers file + fixed ls lint to not be angy * added dev dep * Update .ls-lint.yml * Update .ls-lint.yml --------- Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com>
78 lines
1.8 KiB
TypeScript
78 lines
1.8 KiB
TypeScript
import { defineProject } from "vitest/config";
|
|
import { BaseSequencer, type TestSpecification } from "vitest/node";
|
|
import { defaultConfig } from "./vite.config";
|
|
|
|
export default defineProject(({ mode }) => ({
|
|
...defaultConfig,
|
|
test: {
|
|
env: {
|
|
TZ: "UTC",
|
|
},
|
|
testTimeout: 20000,
|
|
setupFiles: ["./test/font-face.setup.ts", "./test/vitest.setup.ts", "./test/matchers.setup.ts"],
|
|
sequence: {
|
|
sequencer: MySequencer,
|
|
},
|
|
environment: "jsdom" as const,
|
|
environmentOptions: {
|
|
jsdom: {
|
|
resources: "usable",
|
|
},
|
|
},
|
|
typecheck: {
|
|
tsconfig: "tsconfig.json",
|
|
include: ["./test/types/**/*.{test,spec}{-|.}d.ts"],
|
|
},
|
|
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,
|
|
},
|
|
}));
|
|
|
|
//#region Helpers
|
|
|
|
/**
|
|
* Class for sorting test files in the desired order.
|
|
*/
|
|
class MySequencer extends BaseSequencer {
|
|
async sort(files: TestSpecification[]) {
|
|
files = await super.sort(files);
|
|
|
|
return files.sort((a, b) => {
|
|
const aTestOrder = getTestOrder(a.moduleId);
|
|
const bTestOrder = getTestOrder(b.moduleId);
|
|
return aTestOrder - bTestOrder;
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
if (testName.includes("inputs.test.ts")) {
|
|
return 2;
|
|
}
|
|
return 3;
|
|
}
|
|
|
|
//#endregion
|