agentleFS
brendadeeznuts1111brendadeeznuts1111/betting-brain-v3/.cursor/rules/testing.mdc

betting-brain-v3 / rules

Cursor rule8 starsChanged 14 months agoMITView on GitHub

Testing conventions and patterns

The file

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

4 rules. About 0 are common, 3 are distinctive, and 1 is 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.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use Bun Test exclusively: - not Vitest, not Jest.

    line 13
  2. Very specific:

    No backup files: Never create *.test.ts.backup files

    line 106
  3. Distinctive:

    Clean imports: Use Bun Test imports only

    line 107
  4. Distinctive:

    Mock external services: Never call real APIs in tests

    line 110

≈ “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
---
version: "1.0.0"
globs: "*.test.ts,*.test.tsx,*_test.ts,*.spec.ts"
description: "Testing conventions and patterns"
lastUpdated: "2025-10-08"
dependencies: ["quality-standards", "testing-patterns", "bun-runtime"]
---

# Testing Rules

## Test Runner: Bun Test

**Use Bun Test exclusively** - not Vitest, not Jest.

### Test File Structure
```typescript
import { describe, test, expect, beforeEach, afterEach } from "bun:test";

describe("Component/Feature Name", () => {
  beforeEach(() => {
    // Setup
  });

  test("should do something specific", () => {
    // Arrange
    const input = "test";
    
    // Act
    const result = myFunction(input);
    
    // Assert
    expect(result).toBe("expected");
  });
});
```

## File Organization

```
tests/
├── unit/                # Unit tests (9 files)
│   ├── clv.test.ts
│   ├── exposure.test.ts
│   ├── sharp.test.ts
│   └── ...
├── integration/         # Integration tests (8 files)
│   ├── integration.test.ts
│   ├── queue-integration.test.ts
│   └── ...
├── e2e/                 # End-to-end tests
├── mocks/               # Shared test mocks
│   ├── data.ts
│   └── env.ts
├── setup/               # Test configuration
└── utils/               # Test utilities
```

## File Naming

**Bun Test discovers files matching these patterns:**
- `*.test.{ts,tsx}`
- `*_test.{ts,tsx}`
- `*.spec.{ts,tsx}`
- `*_spec.{ts,tsx}`

**Preferred:** `*.test.ts` (e.g., `clv.test.ts`)

## Running Tests

```bash
# All tests
bun test

# Single file
bun test tests/unit/clv.test.ts

# With coverage
bun test --coverage

# Watch mode
bun test --watch

# Specific pattern
bun test --test-name-pattern "CLV"
```

## Mock Environment

See [tests/mocks/env.ts](mdc:tests/mocks/env.ts) for Cloudflare Workers environment mocks.

```typescript
import { createMockEnv } from "../mocks/env";

test("should use mocked environment", () => {
  const env = createMockEnv();
  // Use env.ANALYTICS, env.KV, etc.
});
```

## Test Data

See [tests/mocks/data.ts](mdc:tests/mocks/data.ts) for shared test fixtures.

## Important Patterns

1. **No backup files:** Never create `*.test.ts.backup` files
2. **Clean imports:** Use Bun Test imports only
3. **Type safety:** Leverage [src/types/api.ts](mdc:src/types/api.ts)
4. **Fail fast:** Tests should fail fast on errors
5. **Mock external services:** Never call real APIs in tests

## Status

- ✅ 249/249 tests passing
- ⚠️ 89 TypeScript errors (non-blocking, mostly test files)
- Target: < 20s for integration tests (currently 99s)

See [docs/TESTING_STATUS.md](mdc:docs/TESTING_STATUS.md) for current test health.

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.