# Fix Tests

> Systematic workflow for diagnosing and fixing failing tests. Use when the user reports failing tests or asks to fix test failures.

- **Type:** Skill
- **Install:** `agentstack add skill-girijashankarj-cursor-handbook-fix-tests`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [girijashankarj](https://agentstack.voostack.com/s/girijashankarj)
- **Installs:** 0
- **Category:** [Developer Tools](https://agentstack.voostack.com/c/developer-tools)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [girijashankarj](https://github.com/girijashankarj)
- **Source:** https://github.com/girijashankarj/cursor-handbook/tree/main/.cursor/skills/testing/fix-tests

## Install

```sh
agentstack add skill-girijashankarj-cursor-handbook-fix-tests
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Skill: Fix Failing Tests

## Trigger
When the user reports failing tests or asks to fix test failures.

## Prerequisites
- [ ] Test command works: `{{CONFIG.testing.testCommand}}`
- [ ] Failing test file path or error output available
- [ ] Type check passes or run first: `{{CONFIG.testing.typeCheckCommand}}`

## Steps

### Step 1: Identify Failing Tests
- [ ] Run the test suite: `{{CONFIG.testing.testCommand}}`
- [ ] List all failing tests with error messages
- [ ] Categorize by failure type (assertion, timeout, mock, type)

### Step 2: Analyze Each Failure
For each failing test:
- [ ] Read the error message carefully
- [ ] Check if it's a test issue or a code issue
- [ ] Look at recent changes to the tested code
- [ ] Check if mocks are correctly set up

### Step 3: Common Fix Patterns

#### Mock Issues
- Mock not returning expected value → Update mock return
- Mock not being called → Check import path
- Mock state leaking → Add `beforeEach` reset

#### Assertion Issues
- Expected value changed → Update test or fix code
- Async not awaited → Add `await` or use `waitFor`
- Wrong matcher → Use correct Jest matcher

#### Type Issues
- Interface changed → Update test data
- New required field → Add to test factories
- Return type changed → Update assertions

### Step 4: Fix Tests
- [ ] Fix one test at a time
- [ ] Run just that test to verify: `{{CONFIG.testing.testCommand}} -- --testPathPattern={test-file}`
- [ ] Ensure fix doesn't break other tests

### Step 5: Verify
- [ ] Run full affected test suite
- [ ] Check coverage hasn't dropped below {{CONFIG.testing.coverageMinimum}}%
- [ ] Run type check: `{{CONFIG.testing.typeCheckCommand}}`

## Completion Checklist
- [ ] All previously failing tests pass
- [ ] No new test failures introduced
- [ ] Coverage at or above {{CONFIG.testing.coverageMinimum}}%
- [ ] Type check passes

## If Step Fails
- **Step 1 (identify)**: Run `{{CONFIG.testing.testCommand}}` — if it hangs, run single file with `--testPathPattern=path/to/file`
- **Step 2 (analyze)**: Mock issues often from wrong import path; use `jest.mock('./path')` matching actual import
- **Step 4 (fix)**: Fix one test, run `--testPathPattern` to verify, then next. Don't fix all at once
- **Step 5 (verify)**: If coverage dropped, add test for uncovered branch. Use `@coverage-improvement` skill

## Example
Failure: "Expected 60, received undefined". Cause: mock for `calculateTotal` not returning. Fix: `mockCalculateTotal.mockReturnValue(60)` in test. Run: `npm test -- order.test.ts`.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [girijashankarj](https://github.com/girijashankarj)
- **Source:** [girijashankarj/cursor-handbook](https://github.com/girijashankarj/cursor-handbook)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-girijashankarj-cursor-handbook-fix-tests
- Seller: https://agentstack.voostack.com/s/girijashankarj
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
