/dd:ts:testingfrom dd:ts
Guides TypeScript testing with bun test: file layout, describe/test naming, arrange-act-assert pattern, fixtures, mocks, and error assertions. Use when writing or reviewing tests, setting up a test runner, organizing fixtures, mocking dependencies, or discussing test structure and coverage.
Ships in dd:ts. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The dd:ts:core rules hold in tests too: paragraphs, DRY, no any, no !.
bun test — built in, jest-compatible, no config file for the common case. It resolves the
tsconfig paths, so @/ works in tests.
import { describe, expect, mock, test } from 'bun:test'
Vitest is the fallback when a project needs browser mode. Never jest in a new project.
foo.ts and foo.test.ts side by side.src/tests/ behind a barrel, excluded from the build.src/tests/mocks/*.json, re-exported as SCREAMING_SNAKE constants.describe: the outer one names the unit, the inner one names the member.
test('should …') reads as a sentence in the runner output.test.each, not a copy of the test per input.describe('serverFiles', () => {
test('should override the L1 RPC URL', () => {
const params = { ...PARAMS, l1_provider_rpc_url: 'http://localhost:8545' }
const { env } = serverFiles(params, 'http://host.docker.internal:8545')
expect(env).toContain('l1_provider_rpc_url=http://host.docker.internal:8545\n')
})
test.each([
[75, '1m15s'],
[5, '0m05s'],
])('should format %d seconds as %s', (seconds, text) => {
expect(duration(seconds)).toBe(text)
})
})
The public surface only. A test that reads private state locks in the implementation.
Every error path — assert the class, not the message. Messages are copy; classes are the contract.
expect(() => parseServerParams('{}')).toThrow(ZodError)
await expect(runCommand('false', [])).rejects.toBeInstanceOf(CommandFailed)
Every zod schema: one valid and one invalid case. That is where untrusted data enters.
mock(() => …) for functions, spyOn(obj, 'method') for methods.beforeEach what you set up.Tests are type-checked with the same strict config as the source. No any to make a mock fit —
write a typed fixture factory. A type that is hard to build in a test tells you something about
the type.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
5 skills in this plugin
/coreThe TypeScript conventions that apply to almost every edit — code layout and blank lines, DRY, control flow, functions, types and enums, zod at boundaries, errors, async, module state, logging, classes, files and imports, comments, and naming. Use whenever writing, changing, or reviewing TypeScript, declaring types or enums, parsing external data, adding try/catch or error classes, writing async code, organizing files, barrels and imports, writing comments or TSDoc, refactoring code to be shorter, flatter or less repetitive, naming anything, or when the user asks about idiomatic TypeScript. This is the default TypeScript skill — load it first; reach for testing, tooling, or library on top of it when the task calls for them./libraryExtra TypeScript rules for a published package — the public API surface, package-prefixed names, private over/npx claudepluginhub napalmpapalam/skills --plugin ts