Bun Test Runner

Bun Test Runner is a skill for Claude Code, Codex from PramodDutta/qaskills. It costs 44 tokens per session (4,261 once invoked), scanned A, original, MIT.

A guide to Bun's built-in test runner, which runs JavaScript and TypeScript tests and includes mocking, snapshots, coverage reports, and lifecycle hooks.

In plain words
What is it for?
Use it to write and run tests, mock code, create snapshots, measure coverage, test DOM code with happy-dom, or migrate existing tests.
Why use it?
It reduces the need for separate testing packages and helps move projects from Jest or Vitest to Bun's test system.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/pramoddutta/qaskills/bun-testing
Any agent
npx skills add PramodDutta/qaskills --skill bun-testing
Clone the repo
git clone --depth 1 https://github.com/PramodDutta/qaskills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for Bun Test Runner

README.md
[![agentmods](https://agentmods.dev/badge/skills/pramoddutta/qaskills/bun-testing.svg)](https://agentmods.dev/skills/pramoddutta/qaskills/bun-testing)
Your own site
<a href="https://agentmods.dev/skills/pramoddutta/qaskills/bun-testing"><img src="https://agentmods.dev/badge/skills/pramoddutta/qaskills/bun-testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,261 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00044 $0.04261
Opus 5 $0.00022 $0.02131
Sonnet 5 $0.00009 $0.00852
Haiku 4.5 $0.00004 $0.00426

Measured yesterday against content hash be873137df9d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

Bun Test Runner scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

seed-skills/bun-testing/SKILL.md · 538 lines

How it starts

The opening of the file, as written. The whole thing — 538 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Bun Test Runner Skill

You are an expert in Bun's built-in test runner. When the user asks you to write tests using Bun, migrate from Jest or Vitest to Bun test, configure code coverage, or optimize test execution speed, follow these detailed instructions.

Core Principles

  1. Zero-config test runner -- Bun's test runner works out of the box with no configuration files. Tests are discovered automatically by filename patterns.
  2. Jest-compatible API -- Bun test provides a Jest-compatible API with describe, it, expect, and lifecycle hooks. Migration from Jest is straightforward.
  3. Native TypeScript support -- Bun executes TypeScript directly without transpilation. No ts-jest or tsconfig paths configuration needed.
  4. Built-in mocking -- Use bun:test's mock, spyOn, and module mocking capabilities without installing separate packages.
  5. Snapshot testing -- Bun supports snapshot testing with toMatchSnapshot() and inline snapshots, compatible with Jest snapshot format.
  6. Code coverage -- Generate code coverage reports with --coverage flag. No additional tools like c8 or istanbul needed.
  7. Parallel by default -- Bun runs test files in parallel by default. Design tests to be independent for correct parallel execution.

Project Structure

src/
  utils/
    math.ts
    math.test.ts
    string.ts
    string.test.ts
  services/
    user-service.ts
    user-service.test.ts
    api-client.ts
    api-client.test.ts
  db/
    queries.ts
    queries.test.ts
  __snapshots__/
    .gitkeep
bunfig.toml
package.json

Bun Configuration

# bunfig.toml
[test]
# Test file patterns
root = "./src"

# Coverage configuration
coverage = true
coverageReporter = ["text", "lcov"]
coverageThreshold = { line = 80, function = 80, statement = 80 }

# Preload scripts
preload = ["./test-setup.ts"]

# Timeout per test (ms)
timeout = 5000

# Bail after N failures (0 = no bail)
bail = 0

Basic Test Patterns

// src/utils/math.test.ts
import { describe, it, expect, beforeEach, afterEach } from 'bun:test';
import { add, multiply, divide, fibonacci, isPrime } from './math';

describe('Math Utilities', () => {
  describe('add', () => {
    it('should add two positive numbers', () => {
      expect(add(2, 3)).toBe(5);
    });

    it('should handle negative numbers', () => {
      expect(add(-1, -2)).toBe(-3);
      expect(add(-1, 5)).toBe(4);
    });

    it('should handle zero', () => {
      expect(add(0, 0)).toBe(0);
      expect(add(5, 0)).toBe(5);
    });

    it('should handle floating point', () => {
      expect(add(0.1, 0.2)).toBeCloseTo(0.3);
    });
  });

  describe('divide', () => {
    it('should divide two numbers', () => {
      expect(divide(10, 2)).toBe(5);
    });

    it('should throw on division by zero', () => {
      expect(() => divide(10, 0)).toThrow('Division by zero');
    });

    it('should handle decimal results', () => {
      expect(divide(1, 3)).toBeCloseTo(0.333, 2);
    });
  });

  describe('fibonacci', () => {
    it('should return correct values for small inputs', () => {
      expect(fibonacci(0)).toBe(0);
      expect(fibonacci(1)).toBe(1);
      expect(fibonacci(2)).toBe(1);
      expect(fibonacci(10)).toBe(55);
    });

    it('should throw for negative inputs', () => {
      expect(() => fibonacci(-1)).toThrow();
    });
  });

  describe('isPrime', () => {
    it.each([2, 3, 5, 7, 11, 13])('should identify %d as prime', (n) => {
      expect(isPrime(n)).toBe(true);
    });

    it.each([0, 1, 4, 6, 8, 9, 10])('should identify %d as not prime', (n) => {
      expect(isPrime(n)).toBe(false);
    });
  });
});

Read the full file on GitHub · 538 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 538 lines · 44 tokens per session scan A be873137df9d

Subscribe to this mod's changes

Bun Test Runner is a skill published in the GitHub repository PramodDutta/qaskills (214 stars, last pushed 5d ago), licensed MIT. It adds 44 tokens to every session and 4,261 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.