- Home
- Skills
- Cameronapak
- Bknd Skills
- Bknd Testing
bknd-testing_skill
2
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill cameronapak/bknd-skills --skill bknd-testing- SKILL.md14.4 KB
Overview
This skill provides practical guidance and helpers for testing Bknd applications. It focuses on fast, isolated tests using in-memory databases, test helpers, factories, and common test patterns for unit, integration, and auth flows. It also covers mocking external calls and configuring CI to run tests reliably.
How this skill works
The skill describes how to create an isolated test app with an in-memory SQLite connection and helper modules that build and tear down the app per test. It explains patterns for mutator/repo-based entity tests, HTTP integration tests using a local server, SDK-based testing, auth flows, mocking fetch and drivers, and reusable data factories. It includes CI and local runner commands for Bun and Vitest.
When to use it
- Writing unit tests for entity operations and relationships
- Building integration tests for HTTP endpoints or SDK clients
- Setting up CI pipelines to run automated tests
- Testing authentication flows and drivers (email, external APIs)
- Creating test helpers, factories, and isolated databases for reliability
Best practices
- Use an in-memory database per test to avoid shared state and flakiness
- Always await cleanup and server stop to avoid resource leaks
- Seed only the data needed per test; keep tests independent
- Mock external network calls and drivers to make tests deterministic
- Use factories to produce consistent test data and reduce duplication
Example use cases
- Unit test CRUD operations for posts and comments using mutators and repos
- Integration test REST endpoints by starting a local server against :memory: DB
- Verify auth workflows: register, login, token issuance and failure cases
- Mock external fetch responses inside tasks and flows to simulate APIs
- Run tests in CI with Bun test runner and pre-commit hooks to prevent regressions
FAQ
Bun's built-in test runner is recommended for speed and native SQLite support; Vitest is an alternative if you prefer Jest-like APIs.
How do I avoid tests interfering with each other?
Create a fresh in-memory database per test and call cleanup after each test to close connections and reset state.
Should I mock external services?
Yes. Mock fetch and external drivers during unit tests to make behavior deterministic and keep tests fast.