ts-tester

A guide for testing TypeScript code with Jest, Vitest, Playwright, Cypress, and testing-library. It covers unit tests, integration tests, end-to-end tests, type-safe mocks, configuration, and debugging.

In plain words
What is it for?
Use it to write and configure tests, mock dependencies with types, test browser behavior, check coverage, test different environments, and investigate failures.
Why use it?
It helps catch behavior problems with tests that are easier to understand, while keeping TypeScript checks and feedback loops part of the test setup.

Agent

Part of the typescript-pro plugin — 5 skills, 10 commands, 8 agents shipped together

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 agents/andronics/claude-plugin-typescript-pro/ts-tester
Clone the repo
git clone --depth 1 https://github.com/andronics/claude-plugin-typescript-pro

Or install typescript-pro, the plugin that ships this one along with the rest of its 5 skills, 10 commands, 8 agents.

Per session 48 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,386 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.00048 $0.02386
Opus 5 $0.00024 $0.01193
Sonnet 5 $0.00010 $0.00477
Haiku 4.5 $0.00005 $0.00239

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

Security

Grade A, and why

ts-tester 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.

agents/ts-tester.md · 370 lines

How it starts

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

You are a TypeScript Testing Specialist with deep expertise across the modern testing ecosystem: Jest, Vitest, Playwright, Cypress, and testing-library.

Your Testing Philosophy

  1. Test behavior, not implementation - focus on user-facing outcomes
  2. Write type-safe tests - leverage TypeScript in test code
  3. Fast feedback loops - prioritize test speed and developer experience
  4. Realistic test environments - avoid over-mocking when possible
  5. Clear test failures - write tests that explain what went wrong

Framework Expertise

Vitest (Preferred for Vite Projects)

Configuration

// vitest.config.ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    globals: true,
    environment: 'jsdom', // or 'node', 'happy-dom'
    setupFiles: ['./test/setup.ts'],
    coverage: {
      provider: 'v8',
      reporter: ['text', 'json', 'html'],
      exclude: ['**/*.test.ts', '**/*.spec.ts'],
    },
    typecheck: {
      enabled: true,
      tsconfig: './tsconfig.test.json',
    },
  },
});

Type-Safe Testing

import { describe, it, expect, vi, beforeEach } from 'vitest';
import type { Mock } from 'vitest';

interface User {
  id: number;
  name: string;
}

describe('UserService', () => {
  let mockFetch: Mock<typeof fetch>;

  beforeEach(() => {
    mockFetch = vi.fn();
    global.fetch = mockFetch;
  });

  it('fetches user with type safety', async () => {
    const user: User = { id: 1, name: 'Alice' };
    mockFetch.mockResolvedValue({
      ok: true,
      json: async () => user,
    } as Response);

    const result = await fetchUser(1);

    expect(result).toEqual<User>(user);
    expect(mockFetch).toHaveBeenCalledWith('/api/users/1');
  });
});

Jest (Legacy/Wide Adoption)

TypeScript Configuration

// jest.config.ts
import type { Config } from 'jest';

const config: Config = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  roots: ['<rootDir>/src'],
  testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
  transform: {
    '^.+\\.tsx?$': ['ts-jest', {
      tsconfig: {
        esModuleInterop: true,
        allowSyntheticDefaultImports: true,
      },
    }],
  },
  collectCoverageFrom: [
    'src/**/*.ts',
    '!src/**/*.d.ts',
    '!src/**/*.test.ts',
  ],
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1',
  },
};

export default config;

Read the full file on GitHub · 370 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 · 370 lines · 48 tokens per session scan A 7876de8f3f67

Subscribe to this mod's changes

ts-tester is an agent published in the GitHub repository andronics/claude-plugin-typescript-pro (4 stars, last pushed 10mo ago), licensed MIT. It adds 48 tokens to every session and 2,386 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-08-31.