Testing
Run unit, component, browser, integration, and documentation checks in the Puzzle monorepo.
Puzzle uses several test runners depending on the package and the type of behavior being tested.
The repository includes:
- Vitest for unit and component tests.
- Node's test runner for several server-side packages.
- Playwright-backed browser tests through Vitest.
- Docker Compose for MongoDB integration tests.
Install dependencies
From the repository root:
bun installRun the repository test command
The root test script builds the packages first, runs package test scripts, runs the project generator tests, and runs the UI browser tests.
bun run vitestThis is the broadest standard test command in the repository.
Package-specific tests
UI components
Run unit and component tests:
bun run --filter "@puzzle-ui/ui" vitestRun only unit tests:
bun run --filter "@puzzle-ui/ui" test:unitRun only component tests:
bun run --filter "@puzzle-ui/ui" test:componentRun browser tests:
bun run --filter "@puzzle-ui/ui" test:browserPieces
bun run --filter "@puzzle-ui/pieces" vitest
bun run --filter "@puzzle-ui/pieces" test:browserProject generator
bun run --filter "@puzzle-ui/create" testFullstack authentication
Run server-side and unit tests:
bun run --filter "@puzzle-ui/fullstack" testRun browser tests:
bun run --filter "@puzzle-ui/fullstack" test:browserAuthentication and storage
Several backend packages use Node's built-in test runner.
bun run --filter "@puzzle-ui/auth" test
bun run --filter "@puzzle-ui/session" test
bun run --filter "@puzzle-ui/storage" test
bun run --filter "@puzzle-ui/storage-d1" testMongoDB integration tests
The MongoDB storage adapter uses a dedicated test runner.
bun run --filter "@puzzle-ui/storage-mongodb" testDocker with Compose must be available. The test script starts its MongoDB test environment and cleans up the container and volume when it finishes.
Type checking
Run type checks for all packages and the documentation site:
bun run typecheckRun the documentation site's type check independently:
bun run --filter "@puzzle-ui/site" typecheckBuild checks
Build all packages:
bun run buildBuild the documentation site:
bun run --filter "@puzzle-ui/site" buildThe site build also validates its MDX pages and documentation examples.
Browser test requirements
Browser tests require the Playwright Chromium browser to be installed.
If a browser test fails before reaching the test assertions, verify the Playwright browser installation and the local browser dependencies first.
Recommended workflow
For a component change:
- Run the component's unit tests.
- Run its component tests.
- Run its browser tests if keyboard, pointer, focus, or other browser behavior changed.
- Run the package type check.
- Build the package.
For a documentation change:
- Verify all imports and links.
- Run the site type check.
- Build the documentation site.
For changes affecting shared packages or public APIs, run the broader repository checks.