testing-bun
Skill311 starsChanged 9 days agoApache-2.0View on GitHub
CRITICAL - Invoke BEFORE writing ANY test code. Use when creating new tests, adding test cases, modifying or removing existing tests, writing `it()` or `describe()` blocks, touching any `*.test.ts` or `*.spec.ts` file, or running the mutation-testing kill matrix. Enforces no try-catch in positive tests, no early returns, no test skipping, and that every test catches something no other test catches.
- Reads credentials
2 other projects use a version of this; 2 new projects in the last 4 weeks, against 0 the 4 before.
Adopted by
Surging: 2 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Most recently taken up by
- obsessiondb/rudelword for word, first seen Nov 30, 2026
- opalinehq/cliword for word, first seen Nov 29, 2026
Other versions2 projects use a version of this.
Word for word · 2
- obsessiondb/rudel★ 311100% same
- opalinehq/cli★ 311100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/skills/clickhouse-architecture-advisor/AGENTS.mdAGENTS.md
- .claude/skills/clickhouse-best-practices/AGENTS.mdAGENTS.md
- api-testingSkill
- clickhouse-architecture-advisorSkill
- clickhouse-best-practicesSkill
- clickhouse-js-node-codingSkill
- clickhouse-js-node-troubleshootingSkill
- clickhouse-querySkill
- code-architectureSkill
- environment-variablesSkill
- library-docsSkill
- opaline-designSkill
- pr-creationSkill
- typescript-standardsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 6 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Use bun:test imports (describe, test, expect, etc.)
- Very specific: line 11
Use Bun test runner, typically via workspace scripts (bun run test)
- Distinctive: line 12
Do not introduce Vitest or Jest in this repo
- Distinctive: line 17
Never mock services, DB clients, or external APIs: If a test would need a mock, write the integration test instead.
- Very specific: line 80
Never use skip, skipIf, guard return, or branching that bypasses e2e execution when env vars are absent
- Very specific: line 119
Prefer plain test(...) blocks with explicit setup
- Very specific: line 120
Use package-level scripts (bun test src) for focused runs when needed
- Distinctive: line 123
Keep a test only if it catches something no other test catches.
- Very specific: line 132
Every mutant (swapped arithmetic, comparison, equality and logical operators, flipped booleans, negated conditions, changed literals, …
- Distinctive: line 135
Remove the tests under Removable together, then rerun: the killed count must not drop.
- Very specific: line 138
Test names must be static string literals, unique in their file.
- Distinctive: line 142
When adding new env vars for tests, update:
- Very specific: line 145
Run local e2e/integration suites with bun run test:integration
- Distinctive: line 146
Treat missing vars as a hard failure, not a skip path
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill 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
Testing Standards (Bun)
Framework
- Use
bun:testimports (describe,test,expect, etc.) - Use Bun test runner, typically via workspace scripts (
bun run test) - Do not introduce Vitest or Jest in this repo
- For local e2e/integration runs, provide required env vars through the shell or
.env
Test Strategy
- Default to API integration tests against real infrastructure (real Postgres, real ClickHouse). Call a real endpoint, let data flow through the API into the DB, then verify by calling another endpoint. This is "e2e" from the API perspective only — frontend is out of scope here.
- Never mock services, DB clients, or external APIs. If a test would need a mock, write the integration test instead.
- Unit tests are reserved for pure logical utilities (parsers, formatters, pure functions). A service that "needs" a unit test is a smell — prefer the integration path above.
Critical Rules
1. No Try/Catch in Positive Tests
// Bad - Hides real errors
test('creates user', async () => {
try {
const user = await createUser(input)
expect(user.id).toBeDefined()
} catch (error) {
console.error(error)
}
})
// Good - Let test framework handle errors
test('creates user', async () => {
const user = await createUser(input)
expect(user.id).toBeDefined()
})
// Good - Only for testing expected failures
test('rejects invalid input', async () => {
await expect(createUser(invalid)).rejects.toThrow('Invalid email')
})2. No Early Returns in Tests
// Bad - Silently skips test
test('calls API', async () => {
if (!hasCredentials) return
await callApi()
})
// Good - Fail when preconditions missing
test('calls API', async () => {
expect(hasCredentials).toBe(true)
await callApi()
})3. No Hidden Skips for Missing Env Vars
// Bad
describe.skipIf(!process.env.CLICKHOUSE_URL)('integration', () => {})
// Bad
if (!process.env.CLICKHOUSE_URL) {
test.skip('requires CLICKHOUSE_URL', () => {})
}
// Good - Let tests fail if env not configured
describe('integration', () => {
const url = process.env.CLICKHOUSE_URL
expect(url).toBeTruthy()
})4. E2E Policy (Mandatory)
- E2E tests must never be conditional on env availability
- Never use
skip,skipIf, guardreturn, or branching that bypasses e2e execution when env vars are absent - Missing required env vars must cause test failure immediately
- Local e2e execution must provide the required vars through the shell or
.env
# Required local command for env-dependent suites
bun run test:integration5. Prefer Inline Setup Over beforeEach
// Bad - Unnecessary beforeEach
describe('Tests', () => {
let queryBuilder: QueryBuilder
beforeEach(() => {
queryBuilder = new QueryBuilder(schema)
})
})
// Good - Inline initialization
describe('Tests', () => {
const queryBuilder = new QueryBuilder(schema)
})
// Good - Use beforeEach only for async cleanup
beforeEach(async () => {
await client.query('DELETE FROM test_table')
})Best Practices
Use assert() for Type Narrowing
// Good - Provides type narrowing
assert(checkoutRecord)Keep Tests Deterministic and Isolated
- Prefer plain
test(...)blocks with explicit setup - Use package-level scripts (
bun test src) for focused runs when needed
Every Test Earns Its Place (Kill Matrix)
Keep a test only if it catches something no other test catches. Prove it with the mutation-testing kill matrix before adding tests to a module, and when trimming its suite:
bun run test:kill-matrix apps/desktop/server/src/services/analysis/find-cursor.ts
# Several modules, explicit test files, options, extra `bun test` flags after --
bun run test:kill-matrix <module.ts>... [--test <file.test.ts>]... [--jobs <n>] [--timeout-ms <n>] [--json <out.json>] [-- <bun test flags>]- Paths are relative to the repo root. Without
--test, each module's sibling<name>.test.tsis used. - Every mutant (swapped arithmetic, comparison, equality and logical operators, flipped booleans, negated conditions, changed literals, removed statements,
return undefined) runs against every test alone (bun test <file> --test-name-pattern '^<name>$'), so the matrix records exactly which tests kill it. A run past the time limit counts as a kill. - Mutants reach the tests through a
bun test --preloadhook; no file on disk is written, so an interrupted run leaves nothing behind. - The report lists the matrix, kills and unique kills per test, Tests that kill no unique mutant, Removable together, and the survived mutants.
- Remove the tests under Removable together, then rerun: the killed count must not drop. Not every test without a unique kill can go: two tests that catch the same mutant both lack a unique kill, but one of them must stay.
- The matrix only knows the modules you pass. Before removing a test that also exercises other modules, pass those too (
<a.ts> <b.ts> --test <file.test.ts>): it may be their only killer. The git cursor test infind-cursor.test.tskills nothing unique infind-cursor.tsbut 9 mutants ofpackages/api-routes/src/analysis.ts. - A survived mutant is behaviour no test checks. Add a test only if that behaviour matters; some mutants change nothing observable.
- Test names must be static string literals, unique in their file.
test.eachandtest.ifcannot be attributed and are refused. - Cost is one
bun testprocess per mutant and test (find-cursor: 107 mutants × 5 tests in about 25 s with 5 jobs). Run it on unit-tested modules, not integration suites.
Environment Variables
When adding new env vars for tests, update:
- Package's
turbo.json→passThroughEnvarray .github/workflows/ci.yml→envsection- Run local e2e/integration suites with
bun run test:integration - Treat missing vars as a hard failure, not a skip path
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.

