fetch() API, you can test your routes without any special test harness.
Testing Philosophy
Remix follows these testing principles:- Tests run from source - No build step required
- Use standard APIs - Just use
fetch()to test routes - Runtime-agnostic - Tests work the same across all runtimes
- Fast feedback - Unit tests run in milliseconds
Unit Testing Routes
Test routes by callingrouter.fetch() with standard Request objects:
router.test.ts
Testing with Different Methods
Test POST, PUT, DELETE requests:Testing Middleware
Test middleware in isolation:middleware.test.ts
Testing Components
Test Remix components with theflush() method:
counter.test.ts
Testing Database Queries
Use in-memory SQLite for fast database tests:Integration Testing
Test full request/response cycles:Test Utilities
Create helper utilities for common test scenarios:test-utils.ts
Running Tests
Node.js
Bun
Deno
Best Practices
- Test behavior, not implementation
- Use in-memory databases for fast tests
- Test error cases and edge cases
- Keep tests focused and isolated
- Use descriptive test names
- Mock external services
Related Documentation
Component Testing
Component API with flush() for testing
Data Table
Testing database queries