typescript-testing

Designs TypeScript tests covering runtime behavior, type contracts, and package-consumer compatibility.

1|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/cjthompson/claude-code-config --skill typescript-testing-cjthompson
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript-testing
Source: https://github.com/cjthompson/claude-code-config/tree/main/plugins/typescript-development/skills/typescript-testing
Command: npx skills add https://github.com/cjthompson/claude-code-config --skill typescript-testing-cjthompson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? TypeScript projects often test only runtime behavior while leaving type contracts, narrowing, and published-package compatibility unverified, letting breaking type changes ship unnoticed. ## Core Features & Use Cases - Separate test surfaces: Distinguishes runtime unit tests, integration boundary tests, compile-time type tests, and packed-consumer tests, each verified with the right tool. - Honest type testing: Uses @ts-expect-error for negative cases, assignability checks over opaque type-equality tricks, and separate consumer tsconfig compilations when exported types change. - Use Case: After changing a discriminated union in a published library, compile a consumer fixture that exercises narrowing and exhaustiveness, then pack and install the artifact to verify public exports resolve correctly. ## Quick Start Design tests for my TypeScript library's new discriminated union API, covering runtime behavior, type narrowing, and a packed consumer fixture.

Frequently Asked Questions about typescript-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test TypeScript types at compile time?▼

Compile positive examples that must type-check alongside negative examples marked with @ts-expect-error, so the build fails if an expected error disappears. Prefer assignability checks and real API calls over opaque type-equality helpers.

What is the difference between @ts-expect-error and @ts-ignore in tests?▼

@ts-expect-error fails compilation when the expected error no longer occurs, making it a real negative test. @ts-ignore suppresses errors silently, so it cannot verify that invalid usage stays rejected.

How do I test a TypeScript package as a consumer would use it?▼

Pack and install the built artifact, then resolve its public exports from a separate consumer fixture with the supported module resolution mode. Importing package source directly bypasses the published contract and misses packaging issues.

When should I mock dependencies in TypeScript tests?▼

Mock only slow or nondeterministic boundaries, never the unit under test. For filesystem behavior, use temporary directories and real files rather than mocking the file system.

Why should I avoid snapshot tests for error messages and formatting?▼

Snapshots of incidental formatting, internal call order, emitted diagnostics, or whole platform error messages break on irrelevant changes and hide real regressions. Assert specific meaningful behavior instead.