Skip to content
Skills Library
Programming · Testing

ts-testing

/ts-testing

Use when writing or configuring TypeScript tests and choosing between bun test and Vitest. Not for framework-specific testing (React → react-testing).

Repository
agents ↗
Licence
MIT
Last repository change
12.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
8
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 12.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when writing or configuring TypeScript tests and choosing between bun test and Vitest. Not for framework-specific testing (React → react-testing).

Original author description

Use when writing or configuring TypeScript tests and choosing between bun test and Vitest. Not for framework-specific testing (React → react-testing).

How it works

  1. Agent Workflow (MANDATORY)
  2. Overview
  3. Critical Rules
  4. Decision Guide
  5. Reference Guide
  6. Quick Start
  7. Best Practices
Original SKILL.md headings · 136 lines, 589 words
SKILL.md preview
---
name: ts-testing
description: Use when writing or configuring TypeScript tests and choosing between bun test and Vitest. Not for framework-specific testing (React → react-testing).
versions:
  bun: "1.4.2"
  vitest: "5.0.2"
user-invocable: true
references: references/choosing-runner.md, references/bun-test.md, references/vitest.md, references/common-patterns.md, references/templates/bun-setup.md, references/templates/vitest-setup.md
related-skills: solid-generic, ts-packaging
---

<objective>
This skill covers choosing between bun test (fastest cold start, zero-config TS/JSX,
experimental coverage) and Vitest (V8/Istanbul coverage, multi-worker CI scaling, browser
mode via Playwright) via a decision matrix by project shape, then configuring the chosen
runner's shared Jest-like API — describe/it/expect, lifecycle hooks, mocks, and snapshots.

It also covers coverage thresholds, deterministic test isolation, and the rule to never mix
bun:test and vitest imports in one package, or run bun test when the configured runner is
actually Vitest.

Out of scope: framework-specific testing (React components → react-expert's react-testing,
Laravel → laravel-testing) and browser E2E suites are not covered.
</objective>

# TypeScript Testing

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

## Agent Workflow (MANDATORY)

Before ANY implementation, spawn 3 agents in parallel, one `Agent` call each with a `name`:

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.

| Runner | Strength | Weakness |
|--------|----------|----------|
| `bun test` | Fastest cold start, zero-config TS/JSX, built-in; `--parallel` workers + `--shard` (1.3.13+) | Single process unless `--parallel`, experimental coverage, mock limits |
| Vitest | V8/Istanbul coverage, multi-worker CI scaling, ~Jest parity, browser mode | Needs Vite (peer dep in 5.x) + 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

| Topic | Reference | Load when |
|-------|-----------|-----------|
| Runner selection | `references/choosing-runner.md` | Deciding bun test vs Vitest |
| Bun test runner | `references/bun-test.md` | Using `bun test` |
| Vitest | `references/vitest.md` | Using Vitest |
| Shared API | `references/common-patterns.md` | Writing describe/it/mock/snapshot |

### Templates

| Template | Use Case |
|----------|----------|
| `references/templates/bun-setup.md` | bunfig.toml + first Bun tests |
| `references/templates/vitest-setup.md` | vitest.config.ts + coverage + CI |

---

## Quick Start

### Bun

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

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

```bash
bun test --coverage
```

→ See `references/templates/bun-setup.md`

### Vitest

```ts
import { test, expect } from "vitest";

test("adds 1 + 2", () => {
  expect(1 + 2).toBe(3);
});
```

```bash
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
Files in this package (8)
  • .gitkeep 1 KB
  • SKILL.md 4 KB
  • references/bun-test.md 3 KB
  • references/choosing-runner.md 3 KB
  • references/common-patterns.md 2 KB
  • references/vitest.md 4 KB
  • references/templates/bun-setup.md 2 KB
  • references/templates/vitest-setup.md 3 KB

Versions

The database has no other skills named ts-testing.

Database snapshot: 13.11.2026 · package version 811db3a3d766 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100testing-react
    Writes React/TypeScript tests using Vitest and React Testing Library. Use when "write react tests", "vitest", "component test", "hook test", "RTL", "testing library", "snapshot test", or testing React components, hooks, and utilities.
  • 85vitest
    Use for Vitest in TypeScript projects (Node, bun, React/Next.js, Effect): write, run, or debug unit/component tests, mocks, testing utilities, and coverage.
  • 90Vitest
    Expert guidance for Vitest testing framework including unit tests, integration tests, mocking, coverage, React Testing Library integration, and TypeScript testing. Use this when writing tests for Vite-based applications.
  • 100react-testing
    Test React components with RTL and Jest/Vitest. Use when writing React component tests with React Testing Library, Jest, or Vitest.
  • 96testing-bun
    Use when writing or modifying tests in a Bun project
  • 100typescript-testing
    TypeScript testing patterns with Jest/Vitest including unit tests, integration tests, mocking strategies, and coverage. Use when writing TypeScript tests.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.