Skip to main content
PC Fix includes a comprehensive testing suite covering unit tests, integration tests, and end-to-end tests. This guide covers running tests, writing new tests, and integrating testing into your development workflow.

Testing Stack

PC Fix uses modern testing tools:
  • Vitest: Fast unit and integration tests for both frontend and backend
  • Playwright: End-to-end browser testing
  • Supertest: HTTP integration testing for API endpoints
  • Testing Library: React component testing utilities
All packages include test scripts. Run tests from the monorepo root or individual packages.

Running Tests

Quick Start

Run tests across the entire monorepo:

Test Modes

Backend Testing (API)

Unit Tests Example

src/modules/auth/auth.service.test.ts

Integration Tests Example

src/modules/products/products.routes.test.ts

Frontend Testing (Web)

Component Tests Example

src/components/store/ProductCard.test.tsx

Store Tests Example

src/stores/cartStore.test.ts

End-to-End Testing (Playwright)

E2E Test Example

tests/e2e/checkout.spec.ts

Playwright Configuration

playwright.config.ts

Test Coverage

Generate coverage reports:
Coverage reports are generated in coverage/ directories.
Aim for at least 80% code coverage for critical paths like authentication, payment processing, and inventory management.

CI/CD Integration

Add tests to your CI pipeline:
.github/workflows/test.yml

Best Practices

1

Write Tests First (TDD)

Write failing tests before implementing features:
2

Test User Workflows

Focus on user-facing functionality, not implementation details:
3

Use Realistic Test Data

Use realistic data that matches production patterns:
4

Clean Up Test Data

Always clean up after tests:

Troubleshooting

Increase test timeout:
Use separate test database:
Install browsers:
Ensure mocks are defined before imports:

Next Steps

Backend Architecture

Understand the API structure

Frontend Architecture

Learn about React components

CI/CD

View CI/CD pipelines

Contributing

Contribute to the project