mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 15:03:24 +02:00
[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:
parent
9a92f98f63
commit
76d163e666
@ -1,7 +1,10 @@
|
|||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
|
import { BattlerIndex } from "#enums/battler-index";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
|
import { MoveResult } from "#enums/move-result";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import { GameManager } from "#test/test-utils/game-manager";
|
import { GameManager } from "#test/test-utils/game-manager";
|
||||||
|
import i18next from "i18next";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
@ -32,12 +35,18 @@ describe("{{description}}", () => {
|
|||||||
.enemyLevel(100);
|
.enemyLevel(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Find more awesome utility functions inside `#test/test-utils`!
|
||||||
it("should do XYZ", async () => {
|
it("should do XYZ", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
|
const feebas = game.field.getPlayerPokemon();
|
||||||
|
|
||||||
game.move.use(MoveId.SPLASH);
|
game.move.use(MoveId.SPLASH);
|
||||||
|
await game.move.forceEnemyMove(MoveId.CELEBRATE);
|
||||||
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||||
await game.toEndOfTurn();
|
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"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ import { expect } from "vitest";
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup file for custom matchers.
|
* 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({
|
expect.extend({
|
@ -35,8 +35,8 @@ vi.mock(import("i18next"), async importOriginal => {
|
|||||||
const filename = req.params[0];
|
const filename = req.params[0];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const localeFiles = import.meta.glob("../public/locales/en/**/*.json", { eager: true });
|
const localeFiles = import.meta.glob("../../public/locales/en/**/*.json", { eager: true });
|
||||||
const json = localeFiles[`../public/locales/en/${filename}`] || {};
|
const json = localeFiles[`../../public/locales/en/${filename}`] || {};
|
||||||
if (import.meta.env.VITE_I18N_DEBUG === "1") {
|
if (import.meta.env.VITE_I18N_DEBUG === "1") {
|
||||||
console.log("Loaded locale", filename);
|
console.log("Loaded locale", filename);
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ export default defineConfig(({ mode }) => ({
|
|||||||
slowTestThreshold: 10_000,
|
slowTestThreshold: 10_000,
|
||||||
// TODO: Consider enabling
|
// TODO: Consider enabling
|
||||||
// expect: {requireAssertions: true},
|
// 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: {
|
sequence: {
|
||||||
sequencer: MySequencer,
|
sequencer: MySequencer,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user