Skip to main content
CharleOS uses a comprehensive testing strategy with Vitest for unit tests and Cypress for E2E tests. This ensures code quality and prevents regressions.

Testing Stack

Unit Tests

Vitest - Fast unit testing for utilities and business logic
  • Tests in __tests__/
  • Run with npm run test
  • Coverage reports included

E2E Tests

Cypress - Browser automation for critical user flows
  • Tests in cypress/e2e/
  • Run with npm run test:e2e
  • Dedicated test users for isolation

Test Coverage

What We Test

Unit Tests (__tests__/):
  • Business logic (billing calculations, time utilities)
  • Data transformations
  • Helper functions
  • Type utilities
E2E Tests (cypress/e2e/):
  • Authentication flows
  • Critical user journeys (create task, approve quote)
  • Client portal functionality
  • Role-based access control
What We Don’t Test:
  • UI styling/layout
  • Third-party libraries
  • Database migrations
  • Simple CRUD operations

Running Tests

Unit Tests

E2E Tests

Unit Test Examples

Testing Utilities

Testing Date Utilities

E2E Test Examples

Authentication Flow

Test Configuration

Vitest Config

Cypress Config

CI/CD Integration

Tests run automatically on every pull request:

Best Practices

Focus on behavior, not internal details:
Unit tests should run in milliseconds:
  • No database calls in unit tests
  • Mock external dependencies
  • Use in-memory data
Don’t just test the happy path:

Debugging Tests

Vitest

Cypress

Coverage Reports

Coverage Thresholds:
  • Statements: 60%
  • Branches: 50%
  • Functions: 60%
  • Lines: 60%

Unit Tests

Writing unit tests with Vitest

E2E Tests

Writing E2E tests with Cypress

CI/CD

Automated testing in CI