agentleFS
dodoguardaidodoguardai/dodoguard/test/CLAUDE.md

dodoguard / test

CLAUDE.md202 starsChanged 3 months agoMITView on GitHub

What this is: Jest-based test suite for core functionality (Vitest is used in frontend/ for the web app). ALWAYS use both flags: Mock cleanup is mandatory: Test entire objects, not individual fields: Mock minimally - Only mock external dependencies (APIs, databases), not code under test. Tests mirror src/ structure: Every provider needs: See test/providers/openai.test.ts for reference patterns. See .cursor/rules/jest.mdc for comprehensive Jest guidelines.

The file

We split this CLAUDE.md into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    Use .only() or .skip() in committed code

    line 19
  2. Distinctive:

    Run watch mode in CI

    line 20
  3. Distinctive:

    Mock minimally: - Only mock external dependencies (APIs, databases), not code under test.

    line 43
  4. Very specific:

    Run from project root: npm test

    line 67

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md 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
CLAUDE.md

Test Suite

What this is: Jest-based test suite for core functionality (Vitest is used in frontend/ for the web app).

Critical Test Requirements

ALWAYS use both flags:

npm test -- --coverage --randomize
  • --coverage - Required to track test coverage
  • --randomize - Critical - Ensures tests don't depend on execution order

NEVER:

  • Increase test timeouts - fix the slow test instead
  • Use .only() or .skip() in committed code
  • Run watch mode in CI

Project-Specific Testing Rules

Mock cleanup is mandatory:

afterEach(() => {
  jest.resetAllMocks(); // Prevents test pollution
});

Test entire objects, not individual fields:

// ✅ Good
expect(result).toEqual({ id: 1, name: 'test', active: true });

// ❌ Avoid
expect(result.id).toEqual(1);
expect(result.name).toEqual('test');

Mock minimally - Only mock external dependencies (APIs, databases), not code under test.

Directory Structure

Tests mirror src/ structure:

  • test/providers/ → src/providers/
  • test/redteam/ → src/redteam/
  • etc.

Provider Testing Pattern

Every provider needs:

  1. Success case (normal API response)
  2. Error cases (4xx, 5xx, rate limits)
  3. Configuration validation
  4. Token usage tracking

See test/providers/openai.test.ts for reference patterns.

Key Differences from Frontend Tests

  • This uses Jest (not Vitest)
  • Run from project root: npm test
  • Uses @jest/globals imports
  • Different config: jest.config.ts (not Vitest)

More Details

See .cursor/rules/jest.mdc for comprehensive Jest guidelines.

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.