testing
Vitest testing guide. Use when writing or updating tests, fixing failing tests, improving coverage, debugging test issues, or setting up mocks.
npx skills add lobehub/lobehub --skill testing --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# LobeHub Testing Guide ## Quick Reference **Commands:** ```bash # Run specific test file bunx vitest run --silent='passed-only' '[file-path]' # Database package (client-db, PGlite — default, skips BM25/pg_search) cd packages/database && bunx vitest run --silent='passed-only' '[file]' # Database package (server-db, Postgres — BM25/pgvector parity, what CI measures coverage in) cd packages/database && TEST_SERVER_DB=1 bunx vitest run --silent='passed-only' '[file]' ``` **Never run** `bun run test` - it runs all 3000+ tests (\~10 minutes). > **Database models/repositories:** every new file under `packages/database/src/models/**` > or `src/repositories/**` ships with a sibling `__tests__/<name>.test.ts` in the same PR. > Use the real DB via `getTestDB()` (integration style), guard BM25/full-text-search blocks > with `describe.skipIf(!isServerDB)`, and always test user-isolation. See > `references/db-model-test.md` for setup, schema gotchas, and the client-vs-server-db split. ## Test Categories | Category | Location | Config | | -------- | --------------------------- | ------------------------------- | | Webapp | `src/**/*.test.ts(x)` | `vitest.config.ts` | | Packages | `packages/*/**/
- Quick Reference
- Test Categories
- Core Principles
- Basic Test Structure
- Mock Patterns
- Detailed Guides
- Fixing Failing Tests — Optimize or Delete?
- Keep & Fix (update test data/assertions)
- Delete (over-specified, low value)
- Decision Checklist
- When Writing New Tests
- Common Issues
Run specific test file bunx vitest run --silent='passed-only' '[file-path]' Database package (client-db, PGlite — default, skips BM25/pg_search) cd packages/database && bunx vitest run --silent='passed-only' '[file]' Database package (server-db, Postgres — BM25/pgvector parity, what CI measures coverage in) cd packages/database && TEST_SERVER_DB=1 bunx vitest run --silent='passed-only' '[file]'
What does the testing skill do?
Vitest testing guide. Use when writing or updating tests, fixing failing tests, improving coverage, debugging test issues, or setting up mocks.
How do I install it?
Run `npx skills add lobehub/lobehub --skill testing --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From lobehub/lobehub, a repository with 81,252 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.