Skip to content
Skills Library
Programming · Testing

writing-tests

/writing-tests

Writes focused unit and integration tests for fn(args, deps) code with explicit deps mocks and clear arrange-act-assert. Use this skill when authoring or refactoring test files for TypeScript functions and modules. Do not use when/for TDD process discipline alone (use tdd-workflow) or load testing (use performance-testing).

Licence
MIT
Last repository change
30.07.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
4
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 30.07.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

Writes focused unit and integration tests for fn(args, deps) code with explicit deps mocks and clear arrange-act-assert. Use this skill when authoring or refactoring test files for TypeScript functions and modules. Do not use when/for TDD process discipline alone (use tdd-workflow) or load testing (use performance-testing).

Original author description

Writes focused unit and integration tests for fn(args, deps) code with explicit deps mocks and clear arrange-act-assert. Use this skill when authoring or refactoring test files for TypeScript functions and modules. Do not use when/for TDD process discipline alone (use tdd-workflow) or load testing (use performance-testing).

How it works

  1. Critical rules
  2. Workflow
  3. Resources
  4. Validation
  5. Constraints
Original SKILL.md headings · 46 lines, 369 words
SKILL.md preview
---
name: writing-tests
description: >-
  Writes focused unit and integration tests for fn(args, deps) code with
  explicit deps mocks and clear arrange-act-assert. Use this skill when
  authoring or refactoring test files for TypeScript functions and modules. Do
  not use when/for TDD process discipline alone (use tdd-workflow) or load
  testing (use performance-testing).
version: 1.2.0
libraries: ["vitest", "vitest-mock-extended"]
---

# Writing Tests

## Critical rules

- **Names describe outcomes, not actions:** `[outcome] when [condition]` — e.g. `returns empty array when input is null`, not `test null input`.
- **Assertions match the title.** If the name claims "different IDs", assert the IDs differ — not just length.
- **Assert specific values**, not `toBeDefined()` / `toBeTruthy()`. Specific assertions catch specific bugs.
- **One concept per test.** If you need "and" in the name, split.
- **Bugs cluster.** One bug → test related inputs, same pattern elsewhere, same assumption, same type.
- Assert **behavior** (Results, returned values), not implementation (`toHaveBeenCalledWith` for SQL shape).
- No `vi.mock()` for app logic — `mock<DepsType>()` from vitest-mock-extended.
- Before WRONG/CORRECT examples or edge-case checklists, read the matching resource below.

## Workflow

1. Name the test as a specification: reading names alone should describe the function.
2. Structure Arrange → Act → Assert. Keep one reason to fail.
3. For `Result<T, E>`: assert `result.ok` and the exact `error` or `value`.
4. Cover relevant edge cases (numbers, strings, collections, dates, null/undefined, domain constraints). Before expanding coverage, read [references/edge-cases.md](references/edge-cases.md).
5. On a bug fix: add the failing case, then neighbors (null→undefined→empty; same boundary elsewhere).
6. Prefer observable outcomes over internal call assertions so refactors don't break tests.

Adapted from [BugMagnet](https://github.com/gojko/bugmagnet-ai-assistant) (Gojko Adzic), aligned with `fn(args, deps)` and Result patterns.

## Resources

- [references/examples.md](references/examples.md) — naming, assertions, Result tests, AAA, complete getUser suite. Read when drafting or reviewing a test.
- [references/edge-cases.md](references/edge-cases.md) — type and domain checklists. Read when expanding coverage.
- [references/rationalizations.md](references/rationalizations.md) — excuse→reality and red flags. Read when tempted to weaken a test.

## Validation

- [ ] Names use `[outcome] when [condition]`
- [ ] Each assertion verifies the title's claim with specific values
- [ ] One concept per test (no "and" in the name)
- [ ] Result tests assert `ok` and exact error/value
- [ ] Relevant edge cases covered; bug fixes spawned cluster tests
- [ ] Behavior asserted, not brittle internal calls; deps via `mock<DepsType>()`

## Constraints

- Layer choice (unit vs integration vs e2e) is `testing-strategy`, not this skill.
- Red-green-refactor discipline is `tdd-workflow` (this skill is RED-phase craft).
- Adjacent: `result-types`, `validation-boundary`, `fn-args-deps`, `design-principles` (hard-to-test often means design smell).
Files in this package (4)
  • SKILL.md 3 KB
  • references/edge-cases.md 1 KB
  • references/examples.md 4 KB
  • references/rationalizations.md 1 KB

Versions

RepositoryScoreLicence
This page · jagreehal/jagreehal-claude-skills100MIT
alexandermattturner/agent-sanitizer100Apache-2.0
andymai/brepjs100Apache-2.0
hotovo/aider-desk100Apache-2.0
jungvonmatt/agent-toolkit100MIT
it-bens/ai-tools100MIT
caarlos0/dotfiles100MIT
tosun-si/bigtesty100MIT
mcp-use/mcp-use100MIT

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

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100testing-strategy
    Chooses test pyramid layers, what to mock, and where tests live for fn(args, deps) systems. Use this skill when deciding unit vs integration vs e2e coverage or structuring a test approach for a feature. Do not use when/for the red-green-refactor loop itself (use tdd-workflow) or…
  • 86unit-test
    Writes isolated unit tests for a named file using Arrange-Act-Assert. Use when user requests unit tests, test coverage, or missing test cases for a file.
  • 100typescript-testing
    TypeScript testing patterns with Jest/Vitest including unit tests, integration tests, mocking strategies, and coverage. Use when writing TypeScript tests.
  • 100testing
    Design effective tests and decide what to test: unit vs integration, edge cases, the arrange-act-assert shape, and writing the minimal failing test for a bug. Use when users want tests for code, ask what cases to cover, want to improve coverage meaningfully, or practice TDD.…
  • 100testing-patterns
    Plan, write, and maintain automated tests in any language, with worked examples in Python and JavaScript/TypeScript. Use this skill whenever the user wants to write or plan tests, apply TDD (red-green-refactor), structure unit tests with arrange-act-assert and given-when-then…
  • 100javascript-testing-patterns
    Implement comprehensive testing strategies using Jest, Vitest, and Testing Library for unit tests, integration tests, and end-to-end testing with mocking, fixtures, and test-driven development. Use when writing JavaScript/TypeScript tests, setting up test infrastructure, or…

Feedback and reports

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