agentleFS
DXHeroesDXHeroes/mcp-devtools/.cursor/rules/testing-standards.mdc

mcp-devtools / rules

Cursor rule13 starsChanged 21 months agoMITArchived repositoryView on GitHub

Testing Standards

The file

Show its rules and text

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

15 rules. About 0 are common, 14 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Follow these standards when writing tests for MCP DevTools packages:

    line 9
  2. Very specific:

    Use descriptive describe and it blocks

    line 69
  3. Distinctive:

    Follow the Arrange-Act-Assert pattern

    line 71
  4. Distinctive:

    Keep tests focused on a single functionality

    line 72
  5. Distinctive:

    Use jest.mock() for external modules

    line 77
  6. Distinctive:

    Create dedicated mock factories for complex objects

    line 78
  7. Distinctive:

    Test happy paths and error paths

    line 84
  8. Distinctive:

    Test asynchronous behavior correctly

    line 86
  9. Distinctive:

    Use realistic test data

    line 90
  10. Distinctive:

    Create helper functions for test data generation

    line 91
  11. Distinctive:

    Avoid test data duplication

    line 92
  12. Distinctive:

    Keep test data close to tests that use it

    line 93
  13. Distinctive:

    Test return values, side effects, and exceptions

    line 97
  14. Distinctive:

    Use appropriate matchers (toEqual, toBeCalledWith, etc.)

    line 98
  15. Distinctive:

    Write custom matchers for complex assertions

    line 99

≈ “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-standards.mdc
---
description: Testing Standards
globs: packages/*/src/**/*.test.ts
alwaysApply: true
---

# Testing Standards

Follow these standards when writing tests for MCP DevTools packages:

@file packages/_/src/\*\*/_.test.ts
@file .cursor/rules/typescript-style.mdc

## Test Structure

```typescript
import {
  describe,
  it,
  expect,
  beforeEach,
  afterEach,
  jest,
} from "@jest/globals";
import { featureUnderTest } from "../path/to/feature";

describe("Feature Name", () => {
  // Setup mocks and test fixtures
  beforeEach(() => {
    // Setup code
  });

  afterEach(() => {
    // Cleanup code
    jest.resetAllMocks();
  });

  describe("Specific Functionality", () => {
    it("should behave as expected in normal conditions", async () => {
      // Arrange
      const input = {
        /* test data */
      };

      // Act
      const result = await featureUnderTest(input);

      // Assert
      expect(result).toEqual(/* expected output */);
    });

    it("should handle error cases appropriately", async () => {
      // Arrange
      const invalidInput = {
        /* invalid test data */
      };

      // Act & Assert
      await expect(featureUnderTest(invalidInput)).rejects.toThrow();
    });
  });
});
```

## Testing Guidelines

1. **Test Organization**

   - Use descriptive `describe` and `it` blocks
   - Group related tests together
   - Follow the Arrange-Act-Assert pattern
   - Keep tests focused on a single functionality

2. **Mocking**

   - Mock external dependencies
   - Use jest.mock() for external modules
   - Create dedicated mock factories for complex objects
   - Reset mocks between tests

3. **Coverage**

   - Aim for >80% code coverage
   - Test happy paths and error paths
   - Include edge cases and boundary conditions
   - Test asynchronous behavior correctly

4. **Test Data**

   - Use realistic test data
   - Create helper functions for test data generation
   - Avoid test data duplication
   - Keep test data close to tests that use it

5. **Assertions**
   - Make assertions specific and meaningful
   - Test return values, side effects, and exceptions
   - Use appropriate matchers (toEqual, toBeCalledWith, etc.)
   - Write custom matchers for complex assertions

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.