From 0d8ff442ce1a370eddc86dcf265255e8be9bb171 Mon Sep 17 00:00:00 2001 From: kawa Date: Mon, 5 Oct 2026 09:53:03 +0200 Subject: [PATCH] =?UTF-8?q?Load=20the=20atlas=20and=20Pok=C3=A9dex=20test?= =?UTF-8?q?=20data=20only=20when=20the=20suite=20runs=20(#66)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit describe.skipIf still runs the describe body to collect tests, so the ROM and PRET reads at describe level failed the synthetic CI job without a ROM (runs 123–133). The reads now happen in beforeAll, as in the other ROM suites. Co-Authored-By: Claude Opus 5.5 --- tests/atlas.test.ts | 12 +++++++++--- tests/pokedex.test.ts | 26 +++++++++++++++----------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/tests/atlas.test.ts b/tests/atlas.test.ts index 3dca815..aa96935 100644 --- a/tests/atlas.test.ts +++ b/tests/atlas.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it } from "vitest"; +import { beforeAll, describe, expect, it } from "vitest"; import { existsSync, readFileSync } from "node:fs"; import { CrystalAssets } from "../src/game/rom/assets"; import { GameWorld } from "../src/game/world/world"; @@ -22,7 +22,10 @@ const NEW_BARK_TOWN = "24:4", describe.skipIf(!existsSync(romPath) || !existsSync(`${pret}/data/maps/landmarks.asm`))( "the atlas data against the pinned PRET source", () => { - const assets = new CrystalAssets(new Uint8Array(readFileSync(romPath))); + let assets!: CrystalAssets; + beforeAll(() => { + assets = new CrystalAssets(new Uint8Array(readFileSync(romPath))); + }); const read = (path: string) => readFileSync(`${pret}/${path}`, "utf8"); // const_def counts from 0, or from the value given. const constants = (path: string, prefix: string) => { @@ -59,7 +62,10 @@ describe.skipIf(!existsSync(romPath) || !existsSync(`${pret}/data/maps/landmarks ); describe.skipIf(!existsSync(romPath))("the region atlas", () => { - const assets = new CrystalAssets(new Uint8Array(readFileSync(romPath))); + let assets!: CrystalAssets; + beforeAll(() => { + assets = new CrystalAssets(new Uint8Array(readFileSync(romPath))); + }); function fixture(visited: number[]) { const world = new GameWorld(assets, () => new Date("2026-09-25T12:00:00"), () => 0x42); world.state.party = [ diff --git a/tests/pokedex.test.ts b/tests/pokedex.test.ts index 5c2a20c..d20aaa9 100644 --- a/tests/pokedex.test.ts +++ b/tests/pokedex.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it } from "vitest"; +import { beforeAll, describe, expect, it } from "vitest"; import { existsSync, readFileSync } from "node:fs"; import { CrystalAssets } from "../src/game/rom/assets"; import { dexHeight, dexWeight } from "../src/game/rom/pokedex"; @@ -39,8 +39,10 @@ describe("the Pokédex number formats", () => { }); describe.skipIf(!existsSync(romPath))("the Pokédex data", () => { - const assets = new CrystalAssets(new Uint8Array(readFileSync(romPath))); - const dex = assets.pokedex; + let dex!: CrystalAssets["pokedex"]; + beforeAll(() => { + dex = new CrystalAssets(new Uint8Array(readFileSync(romPath))).pokedex; + }); it("reads its strings and the New mode order", () => { expect(dex.dexString("String_SEEN")).toBe("SEEN"); @@ -76,15 +78,17 @@ describe.skipIf(!existsSync(romPath))("the Pokédex data", () => { describe.skipIf(!existsSync(romPath) || !existsSync(`${pret}/data/pokemon/dex_order_new.asm`))( "the Pokédex data against the pinned PRET source", () => { - const assets = new CrystalAssets(new Uint8Array(readFileSync(romPath))); - const dex = assets.pokedex; const read = (path: string) => readFileSync(`${pret}/${path}`, "utf8"); - // constants/pokemon_constants.asm numbers species from 1. - const species = new Map( - [...read("constants/pokemon_constants.asm").matchAll(/^\s+const (\w+)/gm)].map( - ([, name], index) => [name, index + 1], - ), - ); + let dex!: CrystalAssets["pokedex"], species!: Map; + beforeAll(() => { + dex = new CrystalAssets(new Uint8Array(readFileSync(romPath))).pokedex; + // constants/pokemon_constants.asm numbers species from 1. + species = new Map( + [...read("constants/pokemon_constants.asm").matchAll(/^\s+const (\w+)/gm)].map( + ([, name], index) => [name, index + 1], + ), + ); + }); it("matches NewPokedexOrder", () => { const order = [...read("data/pokemon/dex_order_new.asm").matchAll(/^\s+db (\w+)/gm)].map(