GE
gen-test
Generate a Jest test file for a source module, with testcontainers setup for integration tests
Install
mkdir -p .claude/skills/gen-test && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14500" && unzip -o skill.zip -d .claude/skills/gen-test && rm skill.zipInstalls to .claude/skills/gen-test
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Generate a Jest test file for a source module, with testcontainers setup for integration tests94 charsno explicit “when” trigger
About this skill
Generate Test File
Generate a Jest test file for a given source module in this project.
Workflow
- Ask which source file to generate tests for (if not specified)
- Read the source file to understand exports, interfaces, and dependencies
- Determine test type:
- Unit test: For pure logic, utilities, interfaces — mock external dependencies
- Integration test: For provider implementations (rabbitmq, gcp-pubsub, azure-servicebus, nats-jetstream) — use testcontainers
Conventions
- Test files live alongside source:
src/foo.ts→src/foo.spec.ts - Use
ts-jestpreset withtestEnvironment: "node" - Integration tests use
testcontainersfor Docker-based services - Integration test files should have long timeouts (120-180s) via
--testTimeout - Follow existing test patterns in the codebase (read a few
.spec.tsfiles first) - Import order follows Prettier config: node builtins → third-party → @stackbox-dev → relative
Integration Test Template
For provider tests that need Docker containers:
import { GenericContainer, StartedTestContainer } from "testcontainers";
describe("ProviderName", () => {
let container: StartedTestContainer;
beforeAll(async () => {
container = await new GenericContainer("image:tag")
.withExposedPorts(PORT)
.start();
}, 60_000);
afterAll(async () => {
await container?.stop();
});
// tests here
});
Unit Test Template
import { functionUnderTest } from "./module";
describe("moduleName", () => {
it("should do X when Y", () => {
// arrange, act, assert
});
});