Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/brendadeeznuts1111/betting-brain-v3/testing-patternsgit clone --depth 1 https://github.com/brendadeeznuts1111/betting-brain-v3Wrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/brendadeeznuts1111/betting-brain-v3/testing-patterns)<a href="https://agentmods.dev/rules/brendadeeznuts1111/betting-brain-v3/testing-patterns"><img src="https://agentmods.dev/badge/rules/brendadeeznuts1111/betting-brain-v3/testing-patterns.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.02968 |
| Opus 5 | $0.00000 | $0.01484 |
| Sonnet 5 | $0.00000 | $0.00594 |
| Haiku 4.5 | $0.00000 | $0.00297 |
Grade A, and why
testing-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 489 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Testing Patterns for Bun Test
🔍 Code Searchability Patterns
Find Testing Issues with ast-grep
# Find incorrect test imports (should use bun:test)
ast-grep --pattern 'import { describe, test, expect } from "vitest"' tests/
ast-grep --pattern 'import { describe, test, expect } from "@jest/globals"' tests/
sg -p 'from "vitest"' tests/
sg -p 'from "@jest/globals"' tests/
# Find missing process cleanup
ast-grep --pattern 'Bun.spawn($$$)' tests/
sg -p 'Bun.spawn' tests/
# Find missing afterEach cleanup
ast-grep --pattern 'afterEach($$$)' tests/
sg -p 'afterEach' tests/
# Find test files without proper structure
ast-grep --pattern 'describe($$$)' tests/
sg -p 'describe' tests/
# Find timeout issues
ast-grep --pattern 'timeout: $NUM' tests/
sg -p 'timeout:' tests/
Testing Discovery Commands
# Find all test files
find tests/ -name "*.test.ts" -o -name "*.spec.ts"
# Find test patterns
sg search 'describe(' tests/
sg search 'test(' tests/
sg search 'expect(' tests/
# Find test utilities
sg search 'processManager' tests/
sg search 'createMockEnv' tests/
Test Structure
Use Proper Imports
// ✅ CORRECT - Bun test imports
import { describe, test, expect, beforeEach, afterEach, beforeAll, afterAll } from 'bun:test';
// ❌ WRONG - Don't use Vitest/Jest
import { describe, test, expect } from 'vitest';
import { describe, test, expect } from '@jest/globals';
Process Cleanup in Tests
ALWAYS cleanup spawned processes:
import processManager from '../utils/process-cleanup';
describe('My Test Suite', () => {
// Cleanup after EACH test
afterEach(async () => {
await processManager.killAll(3000);
});
// Or cleanup after ALL tests
afterAll(async () => {
await processManager.killAll(3000);
});
});
Test Timeouts
Global Timeout (bunfig.toml)
[test]
timeout = 10000 # 10 seconds default
Per-Test Timeout
test('long running test', async () => {
// Test code
}, { timeout: 30000 }); // 30 seconds
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 5d ago First seen · 489 lines · 0 tokens per session scan A 4f9b4c4208ea
testing-patterns is a cursor rule published in the GitHub repository brendadeeznuts1111/betting-brain-v3 (8 stars, last pushed 11mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,968 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
testing-anti-patterns
Testing anti-patterns to avoid — mock 濫用、test-only production methods、不完整 mock、E2E fixture 寫死絕對日期、測試碼品質低於生產碼、測試結構契約.
test-scripts
Vitest multi-project test script 設計規範——禁止寫死 path filter 導致單檔測試靜默跳過.
verify-gate-chain
自主迴圈的驗證閘門鏈與停止條件——每個 iterate-until-green 迴圈 MUST 跑 gate chain、宣告 maxiterations、定義 escalation action.
vitest-config
Shared @repo/vitest-config factories - dual entries, Turbo package caching, Node vs Workers knobs.
front-react
Front-app Vitest - Node pool only, isolated QueryClient, no Workers pool.
testing
Vitest testing discipline - trust boundaries, no weakening source to pass tests.