What to unit test
Unit tests are best for pure functions — logic that does not depend on the platform client. Extract this logic from your route handlers and test it in isolation.server/src/lib/posts.ts
server/src/lib/posts.test.ts
Set up Vitest
server/package.json
server/vitest.config.ts
Integration testing against a deployed environment
For routes that depend on the database, auth, or storage, deploy and test with HTTP requests against your project URL.Test with curl
Test with a fetch script
scripts/test-deployed.ts
Testing checklist before deploys
Before relying on a deploy, verify:- All new routes return the expected status codes
- Protected routes return
401without a session cookie - Public routes return data without a session cookie
- Webhook routes accept requests without auth
- Error cases return consistent error shapes
- Database reads and writes work as expected
- File uploads and presigned URL flows work end to end
Public staging environments are coming soon. Today, integration testing happens against the current deployed project environment, so prefer
edgespark deploy --dry-run before a real deploy and keep deployed test changes small.See also
Error handling
Patterns for consistent error responses in your routes.
Deploy and test loop
The iterative workflow for dry runs, deploys, and deployed integration testing.