| name | add-test |
| description | Use when adding tests for new or existing code in gdevelop-mcp. Tests use vitest, live in test/, and follow the safety-first priorities laid out in .claude/rules/testing.md. |
Adding a test
Checklist
Template
import { describe, it, expect, beforeEach } from "vitest";
import { thingUnderTest } from "../src/core/<topic>.js";
import { minimalValidProject } from "./fixtures.js";
describe("thingUnderTest", () => {
it("does the happy path", () => {
const result = thingUnderTest(minimalValidProject());
expect(result).toBe();
});
it("returns an error on bad input", () => {
expect(() => thingUnderTest(null as unknown as never)).toThrow();
});
});
Async tests
it("awaits things correctly", async () => {
const r = await asyncThing();
expect(r).toBeDefined();
});
it("rejects on bad input", async () => {
await expect(asyncThing()).rejects.toThrow(/error message regex/);
});
Filesystem tests
import { mkdtempSync, writeFileSync, readFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
let projectPath: string;
beforeEach(() => {
const dir = mkdtempSync(join(tmpdir(), "my-test-"));
projectPath = join(dir, "game.json");
writeFileSync(projectPath, JSON.stringify(minimalValidProject()), "utf-8");
});
When NOT to add a test
- For thin glue (the tool handler in
src/index.ts) — test the underlying
function in src/core/* instead.
- For 3rd-party behavior (don't test that
fetch works).
- For things that need a live GDevelop install or network (those are
manual / CI-tier).
See .claude/rules/testing.md for full rules.