agentsclimarketplace

Ts testing

Skill fusengine/agents/plugins/typescript-expert/skills/ts-testing

Use when writing or configuring TypeScript tests and choosing between bun test and Vitest. Covers runner selection, config, mocks, snapshots, and coverage. Do NOT use for framework-specific testing (React components → react-expert react-testing, Laravel → laravel-testing) or browser E2E suites.From its SKILL.md

Install
npx -y skills add fusengine/agents --skill ts-testing

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

3.8 KB, 855 tokens by cl100k_base, as published. Nobody here has run it

TypeScript Testing

Pick the right runner, then write tests with a shared Jest-compatible API.

Agent Workflow (MANDATORY)

Before ANY implementation, use TeamCreate to spawn 3 agents:

  1. fuse-ai-pilot:explore-codebase - Detect existing runner, config, test layout
  2. fuse-ai-pilot:research-expert - Verify latest bun test / Vitest docs via Context7/Exa
  3. mcp__context7__query-docs - Check mock, coverage, config APIs

After implementation, run fuse-ai-pilot:sniper for validation.


Overview

Both runners share a Jest-like API (describe/it/expect, lifecycle hooks, snapshots, mocks). They differ on speed, coverage maturity, and CI scaling.

RunnerStrengthWeakness
bun testFastest cold start, zero-config TS/JSX, built-inSingle process, experimental coverage, mock limits
VitestV8/Istanbul coverage, multi-worker CI scaling, ~Jest parity, browser modeNeeds Vite + config, slower cold start

Critical Rules

  1. One runner per package - Never mix bun:test and vitest imports
  2. bun run test, not bun test, when the runner is Vitest - Else Bun runs its own
  3. Explicit coverage thresholds - Fail CI below target, don't just report
  4. Deterministic tests - Isolate shared state; use --randomize (Bun) to catch order bugs
  5. Mock at boundaries - Network/FS/time, never internal implementation detail

Decision Guide

Choosing a runner?
├── Greenfield, Bun runtime, fast local TDD → bun test
├── Large suite / heavy CI parallelism → Vitest (multi-worker)
├── Migrating from Jest / need full coverage → Vitest (V8 + Istanbul)
├── Component/DOM in real browser → Vitest browser mode (Playwright)
└── Zero-dependency script or CLI → bun test

→ See references/choosing-runner.md for the full matrix


Reference Guide

Concepts

TopicReferenceLoad when
Runner selectionreferences/choosing-runner.mdDeciding bun test vs Vitest
Bun test runnerreferences/bun-test.mdUsing bun test
Vitestreferences/vitest.mdUsing Vitest
Shared APIreferences/common-patterns.mdWriting describe/it/mock/snapshot

Templates

TemplateUse Case
references/templates/bun-setup.mdbunfig.toml + first Bun tests
references/templates/vitest-setup.mdvitest.config.ts + coverage + CI

Quick Start

Bun

import { test, expect } from "bun:test";

test("2 + 2", () => {
  expect(2 + 2).toBe(4);
});
bun test --coverage

→ See references/templates/bun-setup.md

Vitest

import { test, expect } from "vitest";

test("adds 1 + 2", () => {
  expect(1 + 2).toBe(3);
});
npx vitest run --coverage

→ See references/templates/vitest-setup.md


Best Practices

DO

  • Colocate tests as *.test.ts next to source
  • Assert inside every waitFor/async block
  • Set per-test timeouts for network-bound tests

DON'T

  • Mix both runners in one package
  • Rely on test execution order
  • Ship experimental Bun coverage as the sole quality gate on huge suites

What ships with it: 7 files

13.5 KB alongside SKILL.md

Keep looking

Skills are one crate of 613,297. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.