Lorcana Test Generation
Use this skill for test syntax and coverage. The full card lifecycle remains
owned by lorcana-cards.
Required Context
- Read
memory/schema.md. - Read the Guardrails and Promoted Rules in
memory/bank.md. - Read the current card definition, printed text, and active sibling test.
- Use
lorcana-find-cardwithrequireActiveTest: trueto find a small set of current examples.
Load references/harness-reference.md only
for the sections needed by the test:
- Imports, fixture fields, mock cards, and harness choice
- Player actions, pending effects, bag triggers, and queries
- Matcher signatures
- Common patterns, pitfalls, and blocker-test placement
Workflow
- Translate each printed behavior clause into an observable test claim.
- Use
LorcanaMultiplayerTestEnginefor gameplay, choices, triggers, songs, locations, durations, and cross-turn behavior. - Use
LorcanaTestEngineonly for a narrow model or keyword check that needs no gameplay flow. - Keep setup minimal and deterministic. Set
deck: []when hidden draws must not occur; setisDrying: falsewhen a fixture character must act. - Prefer semantic player-handle methods and matchers over raw state access.
- Cover the positive behavior and every rules-relevant negative, timing, target, ownership, optional, or duration branch.
- If the engine cannot express the printed behavior, add a minimal engine or
simulator repro and fix the owning primitive. Do not replace behavior
coverage with metadata or
missingImplementationassertions. - Run the targeted test file before any broader gate.
Minimal Shape
import { describe, expect, it } from "bun:test";
import {
LorcanaMultiplayerTestEngine,
PLAYER_ONE,
} from "@tcg/lorcana-engine/testing";
import { cardUnderTest } from "./card-under-test";
describe("Card Name - Version", () => {
it("resolves the printed behavior", () => {
const testEngine = LorcanaMultiplayerTestEngine.createWithFixture({
hand: [cardUnderTest],
inkwell: cardUnderTest.cost,
deck: [],
});
expect(testEngine.asPlayerOne().playCard(cardUnderTest)).toBeSuccessfulCommand();
expect(testEngine.getLore(PLAYER_ONE)).toBe(1);
});
});
Use real cards when identity matters and mock cards for generic targets or
engine primitives. Import test APIs from bun:test and helpers from
@tcg/lorcana-engine/testing.
Boundaries
- Keep card tests beside card definitions.
- Engine tests use mock cards;
@tcg/lorcana-enginemust not import@tcg/lorcana-cards. - Engine plus real-card interactions belong in the simulator test layer.
- Do not copy skipped, TODO, metadata-only, or legacy-commented tests as current syntax.
- Preserve the original behavior claim when migrating a legacy regression.
Verification
From submodules/lorcana:
bun test <path-to-card.test.ts>
Run related package checks only after the targeted test passes. Follow the canonical memory update protocol after substantive reusable discoveries.