Learn how to run TestDriver tests efficiently with Vitest’s powerful test runner.
Running Tests
TestDriver works with Vitest’s powerful test runner:
Run All Tests
Run Specific Tests
Watch Mode
Parallel Execution
# Run all tests once
npx vitest run
# Run in watch mode
npx vitest
# Run with coverage
npx vitest run --coverage
# Run specific file
npx vitest run login.test.js
# Run multiple files
npx vitest run login.test.js checkout.test.js
# Run tests matching pattern
npx vitest run --grep "login"
# Run tests in specific folder
npx vitest run tests/e2e/
# Watch mode - reruns on file changes
npx vitest
# Watch only changed tests
npx vitest --changed
# Watch specific file
npx vitest login.test.js
# Control concurrency
npx vitest run --maxConcurrency=5
# Run with specific thread count
npx vitest run --threads --minThreads=2 --maxThreads=8
Test Output
Understanding test output:
$ npx vitest run
✓ login.test.js (3) 23.4s
✓ user can login with valid credentials 12.3s
✓ shows error for invalid email 5.6s
✓ shows error for wrong password 5.5s
✓ checkout.test.js (2) 34.7s
✓ user can complete checkout 28.9s
✓ validates credit card format 5.8s
Test Files 2 passed (2)
Tests 5 passed (5)
Duration 58.12s
📹 Dashcam Replays:
- https://console.testdriver.ai/dashcam/abc123
- https://console.testdriver.ai/dashcam/def456
Click the Dashcam URLs to watch video replays of your tests!
Identify slow tests:
# Run with reporter showing timing
npx vitest run --reporter=verbose
# Output shows duration per test:
✓ slow-test.test.js > user can checkout (34.7s)
→ find('product') (2.1s)
→ click() (0.4s)
→ find('add to cart') (1.8s)
→ click() (0.3s)
→ find('checkout') (28.9s) ← SLOW!
→ click() (0.5s)
Optimize slow operations:
- Enable caching - First run is slow, subsequent runs are fast
- Use parallel execution - Run tests concurrently
- Check network delays - Look for slow API calls in Dashcam
- Optimize selectors - More specific = faster matching
Performance optimization guide
Vitest UI
Use Vitest UI for interactive debugging:
# Start Vitest UI
npx vitest --ui
Open http://localhost:51204 to see:
- Test file tree
- Test status and duration
- Console output
- Re-run individual tests
- Filter and search tests
Next Steps