[Test] Moved test setup code to its own folder (#6297)

* Made default boilerplate show off some test utils

* Moved all the setup files into their own folder

* fixed relative path bug

* Update i18n.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
Bertie690 2025-09-10 15:13:48 -04:00 committed by GitHub
parent 9a92f98f63
commit 76d163e666
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 5 deletions

View File

@ -1,7 +1,10 @@
import { AbilityId } from "#enums/ability-id";
import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id";
import { GameManager } from "#test/test-utils/game-manager";
import i18next from "i18next";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -32,12 +35,18 @@ describe("{{description}}", () => {
.enemyLevel(100);
});
// Find more awesome utility functions inside `#test/test-utils`!
it("should do XYZ", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const feebas = game.field.getPlayerPokemon();
game.move.use(MoveId.SPLASH);
await game.move.forceEnemyMove(MoveId.CELEBRATE);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toEndOfTurn();
expect(true).toBe(true);
expect(feebas).toHaveUsedMove({ move: MoveId.SPLASH, result: MoveResult.SUCCESS });
expect(game.textInterceptor.logs).toContain(i18next.t("moveTriggers:splash"));
});
});

View File

@ -21,7 +21,7 @@ import { expect } from "vitest";
/*
* Setup file for custom matchers.
* Make sure to define the call signatures in `test/@types/vitest.d.ts` too!
* Make sure to define the call signatures in `#test/@types/vitest.d.ts` too!
*/
expect.extend({

View File

@ -35,8 +35,8 @@ vi.mock(import("i18next"), async importOriginal => {
const filename = req.params[0];
try {
const localeFiles = import.meta.glob("../public/locales/en/**/*.json", { eager: true });
const json = localeFiles[`../public/locales/en/${filename}`] || {};
const localeFiles = import.meta.glob("../../public/locales/en/**/*.json", { eager: true });
const json = localeFiles[`../../public/locales/en/${filename}`] || {};
if (import.meta.env.VITE_I18N_DEBUG === "1") {
console.log("Loaded locale", filename);
}

View File

@ -15,7 +15,7 @@ export default defineConfig(({ mode }) => ({
slowTestThreshold: 10_000,
// TODO: Consider enabling
// expect: {requireAssertions: true},
setupFiles: ["./test/font-face.setup.ts", "./test/vitest.setup.ts", "./test/matchers.setup.ts"],
setupFiles: ["./test/setup/font-face.setup.ts", "./test/setup/vitest.setup.ts", "./test/setup/matchers.setup.ts"],
sequence: {
sequencer: MySequencer,
},