Generates unit and integration tests with support for testcontainers.

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.zip

Installs 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 tests
94 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Ask for the source file to generate tests for
  • Read the source file to understand exports and dependencies
  • Determine the appropriate test type (unit or integration)
  • Generate Jest test files for source modules
  • Set up testcontainers for integration tests
  • Follow existing test patterns and import order conventions

How it works

The skill reads a source file, determines if a unit or integration test is needed, and then generates a Jest test file following conventions, including testcontainers setup for integration tests.

Inputs & outputs

You give it
A source module file
You get back
A Jest test file (.spec.ts) for the source module, potentially with testcontainers setup

When to use gen-test

  • Generating unit tests
  • Writing containerized integration tests
  • Mocking module dependencies

About this skill

Generate Test File

Generate a Jest test file for a given source module in this project.

Workflow

  1. Ask which source file to generate tests for (if not specified)
  2. Read the source file to understand exports, interfaces, and dependencies
  3. Read an existing sibling spec first — src/file-store.gcs.spec.ts is the clearest model — and follow its shape rather than inventing a new one

Conventions

  • Test files live alongside source: src/foo.tssrc/foo.spec.ts. Provider-specific specs are suffixed: file-store.<provider>.spec.ts
  • ts-jest preset, testEnvironment: "node"
  • Cloud SDKs are mocked in unit specs — jest.mock("@google-cloud/storage") and friends. The one exception is src/file-store.minio.integration.spec.ts, which talks to a real MinIO over the S3 wire protocol; it self-skips unless MINIO_TEST_ENDPOINT is set and runs via pnpm run test:integration. No testcontainers dependency; do not add one
  • Behavioural changes to S3/MinIO paths need cases in the integration spec too — mocked tests cannot catch SDK behaviour changes (see CLAUDE.md, Testing)
  • LocalFileStore is the exception: test it against the real filesystem using fs.promises.mkdtemp under os.tmpdir(), and clean up in afterEach
  • Save and restore process.env around tests that set provider env vars
  • Import order follows the Prettier config: node builtins → third-party → relative
  • Coverage is 100% and must stay there — every branch, including error paths and || / ?? fallbacks

Reaching the provider classes

None of the FileStore implementations are exported. Get one by registering the plugin and reading the decoration:

const fastify = Fastify();
await fastify.register(FileStorePlugin, { type: "gcs" });
const store = fastify.FileStore;

The cloud SDKs are lazily require()d inside each Configure* function rather than imported at module scope. jest.mock() still intercepts those require() calls normally. If a test needs a different mock shape than one already established in the file, use jest.resetModules() and re-require("./file-store").

Unit Test Template

import Fastify from "fastify";
import FileStorePlugin, { FileStore } from "./file-store";

jest.mock("@google-cloud/storage");

describe("moduleName", () => {
  let fastify: ReturnType<typeof Fastify>;
  const ORIGINAL_ENV = process.env;

  beforeEach(() => {
    process.env = { ...ORIGINAL_ENV };
    jest.clearAllMocks();
    fastify = Fastify();
  });

  afterEach(async () => {
    process.env = ORIGINAL_ENV;
    await fastify.close();
  });

  it("should do X when Y", async () => {
    // arrange, act, assert
  });
});

When not to use it

  • When the task is not to generate a Jest test file for a source module
  • When testcontainers setup is not required for integration tests
  • When the user does not specify a source file and cannot be prompted

Limitations

  • The skill is limited to generating Jest test files
  • The skill is designed for `ts-jest` preset with `testEnvironment: "node"`
  • The skill requires Docker for testcontainers-based integration tests (implied by testcontainers usage)

How it compares

This skill automates the generation of Jest test files, including specialized setup for containerized integration tests, which is more efficient and consistent than writing tests manually.

Compared to similar skills

gen-test side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
gen-test (this skill)04moNo flagsIntermediate
testing-workflow169moReviewIntermediate
playwright-pro83moReviewIntermediate
e2e-test-developer46moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

testing-workflow

amo-tech-ai

Comprehensive testing workflow for E2E, integration, and unit tests. Use when testing applications layer-by-layer, validating user journeys, or running test suites.

1683

playwright-pro

alirezarezvani

Production-grade Playwright testing toolkit. Use when the user mentions Playwright tests, end-to-end testing, browser automation, fixing flaky tests, test migration, CI/CD testing, or test suites. Generate tests, fix flaky failures, migrate from Cypress/Selenium, sync with TestRail, run on BrowserStack. 55 templates, 3 agents, smart reporting.

828

e2e-test-developer

eclipse-che

Comprehensive E2E test development guidance for Eclipse Che / Red Hat OpenShift Dev Spaces. Use this skill when writing, modifying, or reviewing TypeScript Mocha Selenium tests, page objects, utilities, or test infrastructure. Provides code style rules, patterns, dependency injection setup, and best practices.

44

s2-lint

antvis

After modifying S2 project code, you must run lint to ensure there are no errors, avoiding issues when pushing to git.

25

testrail

alirezarezvani

Sync tests with TestRail. Use when user mentions "testrail", "test management", "test cases", "test run", "sync test cases", "push results to testrail", or "import from testrail".

13

azure-microsoft-playwright-testing-ts

microsoft

Run Playwright tests at scale using Azure Playwright Workspaces (formerly Microsoft Playwright Testing). Use when scaling browser tests across cloud-hosted browsers, integrating with CI/CD pipelines, or publishing test results to the Azure portal.

12

Search skills

Search the agent skills registry