ts-js-testing

Guides writing and auditing plain TypeScript and JavaScript tests with Vitest, Jest, and node:test.

1|Updated Jun 2, 2026
One-click install
npx skills add https://github.com/envoydev/claude-stack --skill ts-js-testing-envoydev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ts-js-testing
Source: https://github.com/envoydev/claude-stack/tree/main/stack/skills/ts-js-testing
Command: npx skills add https://github.com/envoydev/claude-stack --skill ts-js-testing-envoydev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing meaningful tests for plain TypeScript/JavaScript code is hard: teams pick the wrong runner, over-mock modules until broken wiring ships green, misuse fake timers and env stubs, and inflate coverage with assertion-free specs. This Skill provides the conventions for writing tests worth counting and auditing suites that only look trustworthy. ## Core Features & Use Cases - Runner routing and test strategy: Detects the workspace's existing runner (Vitest by default, Jest where signaled, node:test as the zero-dependency floor) and applies role-based strategies for pure modules, boundary seams, DOM-adjacent code, Node-runtime code, and published type surfaces. - Mock-masking prevention: Requires one smoke spec that imports the real public entry and builds the object graph unmocked, so broken export maps or mis-wired factories fail a spec instead of the consumer. - Suite audit and mutation testing: The bundled references/suite-audit.md catalogs false-confidence anti-patterns (no assertions, tautological checks, missing awaits, swallowed exceptions), a red-check verification method, and StrykerJS mutation testing guidance. - Use Case: When asked to review an existing Vitest suite that reports 90% coverage, load this Skill to scan for coverage-touching sweeps and unawaited async assertions, prove each finding by temporarily breaking the guarded behavior, then run StrykerJS on critical modules to expose surviving mutants. ## Quick Start Review my TypeScript test suite for weak assertions and over-mocking, and tell me which specs would survive a mutation testing run.

Frequently Asked Questions about ts-js-testing

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

FAQPage Schema
How do I write good unit tests for TypeScript libraries?▼

Write plain input/output specs for pure modules, using table-driven test.each when the input matrix is the interesting part. Avoid mocks for pure code; inject dependencies and stub only the boundary seams you own, such as a fetch wrapper or clock.

Vitest vs Jest vs node:test: which test runner should I use?▼

Use whichever runner the workspace already runs, detected from package.json. Vitest is the default for new plain TypeScript suites, Jest only where the project already signals it, and node:test is the zero-dependency floor for small libraries.

Why does vi.stubEnv leak into other tests in Vitest?▼

vi.stubEnv is not restored per test by default because unstubEnvs defaults to false. Set unstubEnvs: true in the Vitest config or call vi.unstubAllEnvs() in a beforeEach, otherwise the stubbed value bleeds into every later test.

How do I detect tests that pass but verify nothing?▼

Scan for false-confidence patterns: specs with no assertions, expect(true) constants, tautological round-trips, missing awaits on async assertions, and swallowed exceptions. Prove each finding by temporarily breaking the promised behavior and confirming the test stays green.

What is mutation testing and when should I run StrykerJS?▼

Mutation testing with StrykerJS mutates production code and reruns the suite; surviving mutants reveal blind spots that line coverage hides. Scope it to critical modules only, keep it off the fast PR path, and stabilize flaky tests first.

When should I not use this TypeScript testing guidance?▼

Do not apply it to Angular or Ionic specs, which belong to the Angular testing skill, or to .NET tests. Browser-extension MV3 seams like mocked chrome.* APIs and Playwright persistent-context E2E belong to the browser-extension skill.