typescript-testing

typescript-testing is a cursor rule for Cursor from adonai-labs/agent-runway. It costs 0 tokens per session (660 once invoked), scanned A, original, MIT.

A set of rules for testing TypeScript applications with tools such as Vitest or Jest. It explains how to test behaviour, errors, mocks, integrations, and coverage.

In plain words
What is it for?
Use it when setting up or reviewing TypeScript unit tests, mocks, integration tests, test containers, and testing configuration.
Why use it?
It helps developers write focused tests that catch broken business rules and failure cases without coupling tests to internal implementation details.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

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 rules/adonai-labs/agent-runway/typescript-testing
Clone the repo
git clone --depth 1 https://github.com/adonai-labs/agent-runway

Made for: Cursor.

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 typescript-testing

README.md
[![agentmods](https://agentmods.dev/badge/rules/adonai-labs/agent-runway/typescript-testing.svg)](https://agentmods.dev/rules/adonai-labs/agent-runway/typescript-testing)
Your own site
<a href="https://agentmods.dev/rules/adonai-labs/agent-runway/typescript-testing"><img src="https://agentmods.dev/badge/rules/adonai-labs/agent-runway/typescript-testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 660 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.1 $0.00000 $0.00660
Opus 5 $0.00000 $0.00330
Sonnet 5 $0.00000 $0.00132
Haiku 4.5 $0.00000 $0.00066

Measured 2d ago against content hash fc36d585742c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

typescript-testing 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 2d 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.

src/stacks/typescript/typescript-testing.mdc · 73 lines

How it starts

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

TypeScript Testing Guidelines

Applied when working with TypeScript test files and testing configuration. Australian English spelling throughout.


Test Framework

  • Prefer Vitest for new projects — native ESM, fast watch mode, compatible Jest API, first-class TypeScript
  • Use Jest only if the project already has it configured; do not migrate mid-project for its own sake
  • Enable globals: true to avoid importing describe, it, expect in every file

What to Test

  • Test behaviour and outcomes, not implementation details or internal method calls
  • Business rules and domain logic deserve the most thorough test coverage
  • Test every error path explicitly: invalid input, missing resources, downstream failures
  • Do not chase a coverage percentage — coverage is a signal, not a target

Test Structure

  • One describe per unit under test; group related scenarios within it
  • Name tests as plain English sentences describing the expected outcome
  • Keep tests small and focused — one assertion concept per test (multiple expect on the same scenario is fine)
  • Use beforeEach(() => vi.clearAllMocks()) to prevent cross-test contamination

Mocking

  • Inject dependencies via constructor or function parameter — do not patch modules directly
  • Use vi.fn() / jest.fn() for simple function mocks; vi.spyOn() for partial mocking
  • Use vi.mock('module') only for third-party modules you cannot inject (e.g. node:crypto, cloud SDKs)
  • Always clear or reset mocks in beforeEach — shared mock state between tests causes flaky failures

Integration Testing

  • Use Testcontainers for real database and infrastructure tests — avoid SQLite as a Postgres proxy
  • Start containers in beforeAll, truncate state in beforeEach, stop in afterAll
  • Run integration tests in CI only (not in watch mode) — tag with @integration or separate config file
  • Run migrations before the suite, not before each test

Coverage

  • Run coverage in CI; report on lines, branches, and functions
  • Focus coverage on domain logic and use cases; do not aim to cover generated code or index.ts barrel files
  • Exclude *.d.ts, dist/, and test helpers from coverage reports

Read the full file on GitHub · 73 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. 2d ago First seen · 73 lines · 0 tokens per session scan A fc36d585742c

Subscribe to this mod's changes

typescript-testing is a cursor rule published in the GitHub repository adonai-labs/agent-runway (2 stars, last pushed 16d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 660 tokens. 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.