agentleFS
tableautableau/tableau-mcp/.cursor/rules/testing.mdc

tableau-mcp / rules

Cursor rule347 starsChanged 6 months agoApache-2.0View on GitHub

Testing standards — Vitest framework, test organization, mocking patterns

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository6 other files it gives its agents.

The file

We split this testing.mdc into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Test files: *.test.ts (co-located with source for unit tests)

    line 48
  2. Distinctive:

    Test names: describe the behavior being verified

    line 49
  3. Distinctive:

    Use real code whenever possible — mocks only when unavoidable

    line 53
  4. Distinctive:

    When mocking Tableau API responses, use realistic data shapes

    line 55
  5. Distinctive:

    Never mock the code under test — mock its dependencies

    line 56
  6. Very specific:

    All unit tests pass: npm test

    line 77
  7. Very specific:

    No TypeScript errors: npx tsc --noEmit

    line 78
  8. Very specific:

    No lint errors: npx eslint src/

    line 79

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
testing.mdc
---
description: Testing standards — Vitest framework, test organization, mocking patterns
globs:
  - "**/*.test.ts"
  - "tests/**/*.ts"
  - "vitest.config*.ts"
---

# Testing Standards

## Framework: Vitest
This project uses Vitest. NOT jest, NOT mocha.

## Test Configs
| Config | Command | Directory | Purpose |
|--------|---------|-----------|---------|
| `vitest.config.ts` | `npm test` | `src/` | Unit tests |
| `vitest.config.e2e.ts` | `npm run test:e2e` | `tests/e2e/` | End-to-end (stdio client) |
| `vitest.config.eval.ts` | `npm run test:eval` | `tests/eval/` | AI agent evaluation |
| `vitest.config.oauth.embedded.ts` | `npm run test:oauth:embedded` | `tests/oauth/embedded-authz/` | OAuth flows |

Coverage: `npm run coverage` (v8 provider, cobertura reporter)

## Unit Test Setup
`src/testSetup.ts` automatically:
- Mocks `Server` class
- Mocks `RestApi` class
- Stubs environment variables

Unit tests live alongside source: `src/tools/myTool/myTool.test.ts`

## E2E Test Pattern
Tests use `StdioClientTransport` spawning `node build/index.js`:
```typescript
import { callTool, getClient, listTools } from './client';

describe('my-tool', () => {
  it('returns expected data', async () => {
    const result = await callTool('my-tool', { param: 'value' });
    expect(result).toBeDefined();
  });
});
```

Helpers in `tests/e2e/client.ts`: `callTool()`, `listTools()`, `getClient()`

## Test Naming
- Test files: `*.test.ts` (co-located with source for unit tests)
- Test names: describe the behavior being verified
- One behavior per test — if "and" appears in the name, split it

## Mocking Rules
- Use real code whenever possible — mocks only when unavoidable
- `src/testSetup.ts` provides standard mocks for Server and RestApi
- When mocking Tableau API responses, use realistic data shapes
- Never mock the code under test — mock its dependencies

## Running Tests
```bash
# Unit tests (fast, run these constantly)
npm test

# Single file
npx vitest run src/tools/myTool/myTool.test.ts

# Watch mode
npx vitest src/tools/myTool/myTool.test.ts

# E2E (requires build first)
npm run build && npm run test:e2e

# Coverage report
npm run coverage
```

## Before Marking Work Complete
- All unit tests pass: `npm test`
- No TypeScript errors: `npx tsc --noEmit`
- No lint errors: `npx eslint src/`
- New code has test coverage

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.