betting-brain-v3 / rules
Cursor rule8 starsChanged 14 months agoMITView on GitHub
Testing conventions and patterns
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 repository27 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .cursor/rules/99-floor.mdcCursor rule
- .cursor/rules/ai-friendly-testing.mdcCursor rule
- .cursor/rules/analytics-stub-api.mdcCursor rule
- .cursor/rules/analytics-testing.mdcCursor rule
- .cursor/rules/api-patterns.mdcCursor rule
- .cursor/rules/browser-extension.mdcCursor rule
- .cursor/rules/bun-runtime.mdcCursor rule
- .cursor/rules/cache-optimization.mdcCursor rule
- .cursor/rules/ci-integration.mdcCursor rule
- .cursor/rules/ci-patterns.mdcCursor rule
- .cursor/rules/cloudflare-infrastructure.mdcCursor rule
- .cursor/rules/cloudflare-workers.mdcCursor rule
- .cursor/rules/code-searchability.mdcCursor rule
- .cursor/rules/coverage-thresholds.mdcCursor rule
- .cursor/rules/database-patterns.mdcCursor rule
- .cursor/rules/documentation.mdcCursor rule
- .cursor/rules/endpoint-routing.mdcCursor rule
- .cursor/rules/file-naming.mdcCursor rule
- .cursor/rules/mcp-integration.mdcCursor rule
- .cursor/rules/process-management.mdcCursor rule
- .cursor/rules/production-security.mdcCursor rule
- .cursor/rules/quality-standards.mdcCursor rule
- .cursor/rules/root-organization.mdcCursor rule
- .cursor/rules/security-patterns.mdcCursor rule
- .cursor/rules/testing-patterns.mdcCursor rule
- .cursor/rules/test-setup-patterns.mdcCursor rule
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
- Distinctive: line 13
Use Bun Test exclusively: - not Vitest, not Jest.
- Very specific: line 106
No backup files: Never create *.test.ts.backup files
- Distinctive: line 107
Clean imports: Use Bun Test imports only
- Distinctive: line 110
Mock external services: Never call real APIs in tests
≈ “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.
Files
---
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.
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
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.

