testing

Guide runtime and type tests for TypeScript projects using Vitest and inferred-types.

18|Updated Apr 5, 2021
One-click install
npx skills add https://github.com/inocan-group/inferred-types --skill testing-inocan-group
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/inocan-group/inferred-types/tree/main/.claude/skills/testing
Command: npx skills add https://github.com/inocan-group/inferred-types --skill testing-inocan-group

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires simple-git, inferred-types, and includes scripts (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance and tools to ensure the highest quality of TypeScript code through effective runtime and type testing. It helps developers avoid common testing mistakes, make informed decisions on what to test, and integrate testing seamlessly into their development workflow, ultimately reducing bugs and improving code reliability.

Core Features & Use Cases

  • Dual Testing Expertise: Guides on writing both runtime tests (using Vitest) for behavior validation and type tests (using inferred-types assertions) for compile-time type correctness.
  • TDD Integration: Outlines a structured Test-Driven Development workflow for phase-based development, ensuring tests are written before implementation.
  • Common Mistake Prevention: Educates on and helps avoid frequent errors in type testing, such as separated test blocks or using runtime checks for type validation.

Quick Start

Explain how to write a type test for a new TypeScript utility that capitalizes a string literal, ensuring it correctly infers the capitalized type.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I write type tests for TypeScript to ensure compile-time correctness?

Type tests validate that your TypeScript types infer correctly at compile time using assertions from libraries like inferred-types. They catch type errors before runtime by checking generic resolution, literal type narrowing, and type inference behavior, complementing runtime tests for complete code quality coverage.

When should I use runtime tests versus type tests in TypeScript?

Use runtime tests with Vitest to validate behavior and side effects; use type tests to verify type inference and generic constraints at compile time. TDD guides this decision: write type tests for type-level contracts and runtime tests for functional requirements, ensuring both layers are tested.

How do I structure and organize TypeScript tests following TDD principles?

Organize tests by writing them before implementation, grouping runtime tests by feature and type tests by type assertion. Use test commands and CI integration to run both suites automatically, ensuring tests are maintainable, discoverable, and enforced in your development workflow.

Can I use Vitest for both runtime and type testing in TypeScript projects?

Vitest handles runtime tests effectively. Pair it with inferred-types for type testing to validate compile-time type correctness. Together they provide comprehensive coverage: Vitest tests behavior, while type assertions verify that generics and type inference work as intended.

What are common mistakes to avoid when writing type tests?

Avoid separating type assertions into isolated blocks, using runtime checks to validate types, or forgetting to export tested types. Type tests must remain adjacent to the code they validate and use proper type assertion syntax to catch inference failures at compile time, not runtime.

How do I integrate testing into CI and my development workflow?

Configure test commands in your build tooling to run both runtime and type tests automatically. Integrate into CI pipelines so tests execute on every commit, catching regressions early and enforcing quality standards before code reaches production.