testing_skill

This skill helps you write type-safe TypeScript tests, configure ts-jest and Vitest, and create typed mocks and type-checking test utilities.
  • Python

1

GitHub Stars

1

Bundled Files

3 weeks ago

Catalog Refreshed

2 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstart where the catalogue uses aiagentskills.

npx veilstart add skill pluginagentmarketplace/custom-plugin-typescript --skill testing

  • SKILL.md1.2 KB

Overview

This skill teaches practical TypeScript testing strategies focused on type-safe test setup, typed mocking, and validating type definitions at compile time. It covers configuration for popular test runners, patterns for reusable test utilities, and techniques to keep tests both robust and type-correct. You will learn to combine runtime assertions with compile-time type checks to surface regressions early.

How this skill works

The skill inspects common test configurations (Jest, Vitest, ts-node) and shows how to wire TypeScript path aliases and coverage while preserving types. It demonstrates typed mock creation using utilities like jest.Mocked and vi.fn(), and introduces compile-time type tests with tools such as tsd and expect-type. Practical patterns include builders, fixtures, and custom matchers that maintain type safety across unit, integration, and E2E tests.

When to use it

  • When setting up Jest or Vitest for a TypeScript project and needing correct source maps and path alias resolution
  • When you want mocks and spies to preserve and enforce original function types
  • When you need to assert library or public API types at compile time to prevent breaking changes
  • When building reusable, type-safe test utilities and fixtures across a codebase
  • When adding type-aware integration or E2E tests that rely on request/response typings

Best practices

  • Prefer compile-time type tests (tsd, expect-type) for public API and type-level assertions
  • Use typed mock helpers (jest.Mocked, Partial<T> patterns, typed vi.fn()) to avoid mismatches
  • Keep test utilities generic and narrowly typed to maximize reuse without sacrificing safety
  • Combine lightweight runtime assertions with type tests to catch both behavioral and typing regressions
  • Configure test runners to preserve TypeScript paths and sourcemaps for clear error traces

Example use cases

  • Validating a library's exported types with tsd to prevent accidental signature changes
  • Building a typed factory/builder for creating consistent test data across unit and integration tests
  • Creating jest.Mocked versions of complex services to assert calls and types in unit tests
  • Configuring Vitest with ts-node and path aliases for fast, type-safe local testing
  • Writing E2E API tests that verify both HTTP responses and their TypeScript response types

FAQ

Yes. Run tsd or expect-type checks as a separate CI job to fail builds when public types change unexpectedly.

Should mocks be fully typed or is Partial<T> enough?

Use full jest.Mocked<T> for call/return type safety; Partial<T> is fine for simple stubs but can hide typing issues.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
testing skill by pluginagentmarketplace/custom-plugin-typescript | VeilStrat