Skip to content
Agentmart
Submit a tool

writing-tests-typescript

Instructions for writing TypeScript tests (Jest), including typed mocks and testing patterns.

Skill by agent-ix

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/agent-ix-writing-tests-typescript

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Instructions for writing TypeScript tests (Jest), including typed mocks and testing patterns.

Use cases: testing, writing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/writing-tests-typescript

What's inside

Skill name
writing-tests-typescript
Description
Instructions for writing TypeScript tests (Jest), including typed mocks and testing patterns.
License
MIT
Instructions
128 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Writing TypeScript Tests

If this plugin is not initialized or an Agent IX command fails, read [the dev-tools setup guide](https://github.com/agent-ix/dev-tools/blob/main/setup.md) for its prerequisites and local diagnosis.

This skill provides guidelines and patterns for writing TypeScript tests using `jest`, compliant with the Agent-IX Golden Path.

**Source Spec**: Derived from `typescript-lib-cookiecutter` and `nodejs-lib` patterns.

## Core Rules

1.  **Test Runner**: Use `jest`.
2.  **Location**: Tests are typically located in a `tests/` directory or alongside source files as `*.test.ts` or `*.spec.ts`.
3.  **Naming**: Use descriptive names for `describe` blocks and `test`/`it` functions.
4.  **Formatting**: Follow `prettier` and `eslint` rules.
5.  **Traceability**: A test that asserts acceptance criteria carries a `Trace:` line in its
    JSDoc (or a `// Trace:` comment) listing the criterion ids, comma separated
    (`Trace: FR-001-AC-2, FR-001-AC-3`). `quire matrix` computes the Test Matrix from these
    tags; ids in `Description` or `Criteria` bind nothing. Do not add rows to `spec/tests.md`.

## Basic Structure

```typescript
import { sum } from '../src/math';

/**
 * Tests for the Math module functions.
 */
describe('Math module', () => {
  /**
   * Description:
   *     Verifies that the sum function correctly adds two numbers.
   *
   * Assumptions:
   *     - Inputs are numbers
   *
   * Criteria:
   *     - Result is the arithmetic sum of inputs
   *
   * Trace: FR-001-AC-1
   */
  it('adds two numbers correctly', () => {
    expect(sum(1, 2)).toBe(3);
  });
});
```

## Mocking

Use `jest.mock` for module mocking. Use `jest.spyOn` for method spying.

### Pattern: Mocking a Module

```typescript
import { performAction } from '../src/action';
import { api } from '../src/api';

jest.mock('../src/api');

/**
 * Tests for the Action module.
 */
describe('Action', () => {
    /**
     * Description:
     *     Verifies that performAction makes a POST request to the API.
     *
     * Assumptions:
     *     - api.post is a jest mock
     *
     * Criteria:
     *     - api.post is called exactly once
     */
    it('calls the api', async () => {
        (api.post as jest.Mock).mockResolvedValue({ data: 'ok' });
        
        await performAction();
        
        expect(api.post).toHaveBeenCalled();
    });
});
```

### Pattern: Typed Mocks (Better)

Use `jest.Mocked<T>` for better type safety.

```typescript
import { api } from '../src/api';
jest.mock('../src/api');

const mockedApi = api as jest.Mocked<typeof api>;

// usage
mockedApi.post.mockResolvedValue(...)
```

## Async Testing

Always await promises.

```typescript
/**
 * Description:
 *     Verifies that data is fetched successfully.
 *
 * Assumptions:
 *     - fetchData resolves with data
 *
 * Criteria:
 *     - Returned data is defined
 */
it('fetches data', async () => {
    const data = await fetchData();
    expect(data).toBeDefined();
});
```

## Setup and Teardown

From agent-ix/dev-tools, MIT.

More from agent-ix/dev-tools

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Oct 4, 2026 (24 days ago)
Last release
Oct 22, 2026 (7 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from agent-ix

Cite this page

writing-tests-typescript skill. Agent Mart. https://agentmart.dev/skills/agent-ix-writing-tests-typescript (last updated 2026-10-24)