.claude/skills/test/SKILL.md
Run and write Vitest tests, mock Jaypie with testkit, CI matrix
npx skillsauth add finlaysonstudio/jaypie testInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
How to run and write tests in this monorepo.
npm test # Run ALL tests across all packages (vitest run)
npm test -w packages/<name> # Run tests for a specific package
npm test -w workspaces/<name> # Run tests for a specific workspace
Never run bare vitest -- it defaults to watch mode and won't terminate. Always use npm test or vitest run.
npm run test:jaypie # packages/jaypie
npm run test:llm # packages/llm
npm run test:testkit # packages/testkit
npm run test:express # packages/express
npm run test:errors # packages/errors
# ... etc (test:<package-name> for each package)
Require API keys. Run locally or in CI when packages/llm/** changes:
npm run test:llm:client # Basic client tests
npm run test:llm:all # All LLM tests (client, document, image, joke, reasoning, structured)
npm run test:llm:joke # Individual test suite
vitest.workspace.ts at root discovers packages/*/vitest.config.{ts,js}vitest.config.ts and optional vitest.setup.tsTests live alongside source or in __tests__/ directories:
src/
├── services/
│ └── user.ts
└── __tests__/
└── user.spec.ts
# Or co-located:
src/
└── services/
├── user.ts
└── user.spec.ts
import { describe, expect, it, vi, beforeEach } from "vitest";
describe("MyFunction", () => {
beforeEach(() => {
vi.clearAllMocks();
});
it("does the expected thing", async () => {
// Arrange
const input = { key: "value" };
// Act
const result = await myFunction(input);
// Assert
expect(result).toBeDefined();
});
});
Most packages mock jaypie in their vitest.setup.ts:
// vitest.setup.ts
import { vi } from "vitest";
vi.mock("jaypie", async () => {
const { mockJaypie } = await import("@jaypie/testkit");
return mockJaypie(vi);
});
This mocks log, getSecret, sendMessage, and other Jaypie exports as vi.fn().
import { log, getSecret } from "jaypie";
it("logs the operation", async () => {
await myFunction();
expect(log.info).toHaveBeenCalledWith("message");
});
it("reads a secret", async () => {
vi.mocked(getSecret).mockResolvedValue("mock-value");
await myFunction();
expect(getSecret).toHaveBeenCalledWith("secret-name");
});
// @jaypie/logger
vi.mock("@jaypie/logger", async () => {
const { mockLogger } = await import("@jaypie/testkit");
return mockLogger(vi);
});
// @jaypie/aws
vi.mock("@jaypie/aws", async () => {
const { mockAws } = await import("@jaypie/testkit");
return mockAws(vi);
});
import { NotFoundError } from "jaypie";
it("throws NotFoundError when missing", async () => {
await expect(myFunction("bad-id")).rejects.toThrow(NotFoundError);
});
import { matchers } from "@jaypie/testkit";
expect.extend(matchers);
it("throws a Jaypie error", async () => {
await expect(myFunction()).rejects.toBeJaypieError();
});
// vitest.config.ts
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
coverage: {
reporter: ["text", "json", "html"],
},
globals: true,
setupFiles: ["./vitest.setup.ts"],
},
});
Tests often depend on built artifacts. In CI, npm run build runs before npm test. Locally, if tests fail on import errors, rebuild first:
npm run build && npm test -w packages/<name>
When adding a new export to any package, update packages/testkit to mock it -- otherwise tests across the monorepo will fail.
Tests run on Node.js 22, 24, 25 in npm-check.yml and on 22, 24 in stack deployment workflows. The continue-on-error typecheck job won't block merges but lint and test must pass.
testing
Work a GitHub issue -- validate, test, plan, implement, report
testing
Merge process -- push, CI check, PR, merge, deploy monitor, prune branches
documentation
Prepare a release by committing, versioning, updating docs and skills
development
Completion criteria -- typecheck, build, test, format must all pass