typescript-tests

A guide for writing and reviewing tests for TypeScript and TSX code. Tests are checks that code behaves as expected; it covers test structure, mocks, isolated tests, user-interface queries, and snapshots.

In plain words
What is it for?
Use it to design tests, organize them with an arrange-act-assert structure, mock dependencies, test interfaces from a user's perspective, and review snapshots.
Why use it?
It helps catch bugs early and makes code changes safer without making tests unnecessarily difficult to maintain.

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/mkosir/typescript-style-guide/typescript-tests
Any agent
npx skills add mkosir/typescript-style-guide --skill typescript-tests
Clone the repo
git clone --depth 1 https://github.com/mkosir/typescript-style-guide

Made for: Claude Code, Codex.

Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,157 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.00052 $0.01157
Opus 5 $0.00026 $0.00579
Sonnet 5 $0.00010 $0.00231
Haiku 4.5 $0.00005 $0.00116

Measured 3d ago against content hash 926ef4f85ad4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

typescript-tests 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 3d ago.

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.

skills/typescript-tests/SKILL.md · 94 lines

How it starts

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

Tests

Apply the TypeScript Style Guide's testing conventions in the context of the current task.

Workflow

  1. Inspect the consuming repository's test runner, libraries, conventions, and configuration.
  2. Let explicit repository conventions take precedence over this opinionated guidance.
  3. Apply, review, or explain only the guidance relevant to the task.
  4. State important tradeoffs when testing strategy depends on risk, scope, or maintenance cost.

Boundaries

  • Keep the test runner, TypeScript, and ESLint responsible for checks they can enforce automatically.
  • Do not add or rewrite unrelated tests merely because this skill is active.

Functions

For detailed function design guidance that supports testability, use typescript-functions when it is available.

Appendix - Tests

What & How To Test

Automated tests help us write better code, make refactoring easier, and catch bugs earlier in the process.
Consider the trade-offs of what and how to test to gain confidence that the application is working as intended, while ensuring that writing and maintaining tests doesn't slow the team down.

✅ Do:

  • Keep tests short, explicit, and pleasant to work with. A test's intent should be immediately visible.
  • Strive to follow the AAA pattern to maintain clean, organized, and understandable unit tests.
    • Arrange - Setup preconditions or the initial state necessary for the test case. Create necessary objects and define input values.
    • Act - Perform the action you want to unit test (invoke a method, triggering an event etc.). Strive for minimal number of actions.
    • Assert - Validate the outcome against expectations. Strive for minimal number of asserts.
      The rule "unit tests should fail for exactly one reason" doesn't always need to apply, but tests with many assertions can indicate a code smell.
  • As mentioned in function conventions, try to keep functions pure and impure ones small and focused.
    This makes them easy to test by passing arguments and observing return values, since we will rarely need to mock dependencies.
  • Strive to write tests based on how a user interacts with your app, meaning test business logic.
    E.g. for a specific user role or permission, given some input, we receive the expected output from the process.
  • Make tests as isolated as possible so they don't depend on execution order and can run independently with their own local storage, session storage, data, cookies etc. Test isolation speeds up the test run, improves reproducibility, makes debugging easier and prevents cascading test failures.
  • Tests should be resilient to changes.
    • Black box testing - Always test only publicly exposed behavior. Don't write fragile tests based on how the implementation works internally.
    • Query HTML elements based on attributes that are unlikely to change. Order of priority must be followed as specified in Testing Library - role, label, placeholder, text contents, display value, alt text, title, test ID.
    • If testing with a database, make sure you control the data. If tests are run against a staging environment, make sure it doesn't change.

Read the full file on GitHub · 94 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. 3d ago First seen · 94 lines · 52 tokens per session scan A 926ef4f85ad4

Subscribe to this mod's changes

typescript-tests is a skill published in the GitHub repository mkosir/typescript-style-guide (784 stars, last pushed 6d ago), licensed MIT. It adds 52 tokens to every session and 1,157 once invoked, about $0.0003 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-08-30.

Related

Other skills, from other repositories

pest-testing

Use this skill for Pest PHP testing in Laravel projects only. Trigger whenever any test is being written, edited, fixed, or refactored — including fixing tests that broke after a code change, adding assertions, converting PHPUnit to Pest, adding datasets, and TDD workflows. Always activate when the user asks how to…

coollabsio/coolify · 171 tokens

convert-internal-package-to-typescript

Convert a legacy internal Ghost workspace package from JavaScript or CommonJS to the repository's TypeScript and ESM golden path while preserving file history and runtime compatibility. Use when modernizing an existing or newly migrated private package, including staged lib-to-src moves, JS-to-TS renames, consumer…

TryGhost/Ghost · 75 tokens

xberg-typescript-toolchain

Work on Xberg TypeScript or JavaScript packages with the repository's actual poly, pnpm, npm, Vitest, napi-rs, wasm-pack, and integration-package boundaries. Load for TS/JS tooling or package changes, not Rust-only binding generation.

xberg-io/xberg · 60 tokens

test-bridge

Bridge Server (TypeScript) のテスト実行・型チェック・テスト記述ガイド.

K9i-0/ccpocket · 25 tokens

typescript-testing

Applies repository-aware TypeScript test design, behavior evidence, isolation, and mock-boundary criteria. Use when writing or reviewing unit tests.

shinpr/ai-coding-project-boilerplate · 31 tokens

phoenix-client-development

Development guide for the @arizeai/phoenix-client TypeScript SDK — run and resume experiments, manage OpenTelemetry tracer providers with stack-based attach/detach, and write vitest unit and integration tests. Use when adding features to phoenix-client, debugging experiment lifecycle or provider cleanup, modifying…

Arize-ai/phoenix · 85 tokens