agentleFS
pr-pmpr-pm/prpm/.cursor/rules/testing-patterns.mdc

prpm / rules

Cursor rule122 starsChanged 9 months agoMITView on GitHub

Testing patterns and best practices for PRPM codebase with Vitest

The file

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

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Clear Assertions: Use descriptive expect messages

    line 68
  2. Distinctive:

    Mock External Services: Don't hit real APIs in tests

    line 69
  3. Distinctive:

    Performance: Keep unit tests under 100ms each

    line 71

≈ “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-patterns.mdc
---
alwaysApply: true
description: Testing patterns and best practices for PRPM codebase with Vitest
---

# PRPM Testing Patterns

Expert guidance for testing the Prompt Package Manager codebase.

## Testing Philosophy

### Test Pyramid
- **70% Unit Tests**: Format converters, parsers, utilities
- **20% Integration Tests**: API routes, database operations, CLI commands
- **10% E2E Tests**: Full workflows (install, publish, search)

### Coverage Goals
- **Format Converters**: 100% coverage (critical path)
- **CLI Commands**: 90% coverage
- **API Routes**: 85% coverage
- **Utilities**: 90% coverage

## Key Testing Patterns

### Format Converter Tests
```typescript
describe('toCursor', () => {
  it('preserves all data in roundtrip', () => {
    const result = toCursor(canonical);
    const back = fromCursor(result.content);
    expect(back).toEqual(canonical);
  });
  
  it('flags lossy conversions', () => {
    const result = toCursor(canonicalWithClaudeSpecific);
    expect(result.lossyConversion).toBe(true);
    expect(result.qualityScore).toBeLessThan(100);
  });
});
```

### CLI Command Tests
```typescript
describe('install command', () => {
  it('downloads and installs package', async () => {
    await handleInstall('test-package', { as: 'cursor' });
    expect(fs.existsSync('.cursor/rules/test-package.md')).toBe(true);
  });
});
```

### Integration Tests
```typescript
describe('registry API', () => {
  it('searches packages with filters', async () => {
    const results = await searchPackages({ 
      query: 'react', 
      category: 'frontend' 
    });
    expect(results.length).toBeGreaterThan(0);
  });
});
```

## Best Practices

1. **Test Isolation**: Each test should be independent
2. **Clear Assertions**: Use descriptive expect messages
3. **Mock External Services**: Don't hit real APIs in tests
4. **Test Edge Cases**: Empty inputs, null values, large datasets
5. **Performance**: Keep unit tests under 100ms each

## Running Tests

```bash
# All tests
npm run test

# Watch mode
npm run test:watch

# Coverage
npm run test:coverage

# Specific file
npm run test -- to-cursor.test.ts
```

Remember: High test coverage ensures PRPM stays reliable as critical infrastructure.

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.