agentleFS
aaydin-traaydin-tr/swagger-navigator-mcp/.cursor/rules/testing-standards.mdc

swagger-navigator-mcp / rules

Cursor rule2 starsChanged 17 months agoMITView on GitHub

  • Reads credentials
  • 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 repository2 other files it gives its agents.

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, 11 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    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:

    All tests should be placed in the tests/ directory, mirroring the src/ structure

    line 9
  2. Very specific:

    Test files must use .test.ts extension

    line 10
  3. Very specific:

    Use descriptive describe and it blocks that clearly explain what is being tested

    line 11
  4. Distinctive:

    All exported functions must have comprehensive test coverage

    line 16
  5. Distinctive:

    Test both happy path and error scenarios

    line 17
  6. Very specific:

    Use typed mocks: const mockFunction = fn as jest.MockedFunction<typeof fn>

    line 50
  7. Distinctive:

    Always restore original environment variables and mocks between tests

    line 51
  8. Distinctive:

    Test integration flows by mocking at appropriate boundaries

    line 52
  9. Distinctive:

    Unit Tests: Test individual functions in isolation

    line 56
  10. Distinctive:

    Integration Tests: Test function interactions

    line 57
  11. Distinctive:

    Error Handling: Test all error paths and edge cases

    line 58
  12. Distinctive:

    Environment Variable Tests: Test env var substitution and validation

    line 59
  13. Distinctive:

    Path Resolution Tests: Test relative/absolute path handling

    line 60
  14. Distinctive:

    Use descriptive test names that explain the scenario

    line 64
  15. Distinctive:

    Follow pattern: "should [expected behavior] when [condition]"

    line 65

≈ “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
---
alwaysApply: true
---

# Testing Standards

## Test Structure

- All tests should be placed in the `tests/` directory, mirroring the `src/` structure
- Test files must use `.test.ts` extension
- Use descriptive `describe` and `it` blocks that clearly explain what is being tested

## Coverage Requirements

- Aim for 100% code coverage on utility modules like [env-substitution.ts](mdc:src/utils/env-substitution.ts)
- All exported functions must have comprehensive test coverage
- Test both happy path and error scenarios

## Test Organization

```typescript
describe("moduleName", () => {
  const originalEnv = process.env;

  beforeEach(() => {
    jest.resetModules();
    jest.clearAllMocks();
    process.env = { ...originalEnv };
  });

  afterAll(() => {
    process.env = originalEnv;
  });

  describe("functionName", () => {
    it("should handle expected behavior", () => {
      // Test implementation
    });

    it("should handle error cases", () => {
      // Error test implementation
    });
  });
});
```

## Mocking Guidelines

- Mock external dependencies (fs, yaml, etc.) using Jest mocks
- Use typed mocks: `const mockFunction = fn as jest.MockedFunction<typeof fn>`
- Always restore original environment variables and mocks between tests
- Test integration flows by mocking at appropriate boundaries

## Required Test Types

1. **Unit Tests**: Test individual functions in isolation
2. **Integration Tests**: Test function interactions
3. **Error Handling**: Test all error paths and edge cases
4. **Environment Variable Tests**: Test env var substitution and validation
5. **Path Resolution Tests**: Test relative/absolute path handling

## Test Naming Conventions

- Use descriptive test names that explain the scenario
- Follow pattern: "should [expected behavior] when [condition]"
- Group related tests using nested `describe` blocks

---

# Testing Standards

## Test Structure

- All tests should be placed in the `tests/` directory, mirroring the `src/` structure
- Test files must use `.test.ts` extension
- Use descriptive `describe` and `it` blocks that clearly explain what is being tested

## Coverage Requirements

- Aim for 100% code coverage on utility modules like [env-substitution.ts](mdc:src/utils/env-substitution.ts)
- All exported functions must have comprehensive test coverage
- Test both happy path and error scenarios

## Test Organization

```typescript
describe("moduleName", () => {
  const originalEnv = process.env;

  beforeEach(() => {
    jest.resetModules();
    jest.clearAllMocks();
    process.env = { ...originalEnv };
  });

  afterAll(() => {
    process.env = originalEnv;
  });

  describe("functionName", () => {
    it("should handle expected behavior", () => {
      // Test implementation
    });

    it("should handle error cases", () => {
      // Error test implementation
    });
  });
});
```

## Mocking Guidelines

- Mock external dependencies (fs, yaml, etc.) using Jest mocks
- Use typed mocks: `const mockFunction = fn as jest.MockedFunction<typeof fn>`
- Always restore original environment variables and mocks between tests
- Test integration flows by mocking at appropriate boundaries

## Required Test Types

1. **Unit Tests**: Test individual functions in isolation
2. **Integration Tests**: Test function interactions
3. **Error Handling**: Test all error paths and edge cases
4. **Environment Variable Tests**: Test env var substitution and validation
5. **Path Resolution Tests**: Test relative/absolute path handling

## Test Naming Conventions

- Use descriptive test names that explain the scenario
- Follow pattern: "should [expected behavior] when [condition]"
- Group related tests using nested `describe` blocks

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.