Skip to content

feat(frontend): Add Jest unit testing infrastructure #6442

@talissoncosta

Description

@talissoncosta

Summary

Add Jest unit testing infrastructure to the frontend codebase to enable fast, isolated unit tests alongside the existing TestCafe E2E tests.

Motivation

The frontend currently relies on TestCafe for E2E testing, which is excellent for integration tests but can be slow and complex for testing individual utility functions and business logic. Adding Jest provides:

  • Fast feedback loop - Unit tests run in milliseconds, not minutes
  • Isolated testing - Test pure functions and utilities without browser overhead
  • Better coverage - Easier to test edge cases and error conditions
  • CI integration - Quick unit test checks on every PR

Changes

Jest Configuration

  • Add Jest with ts-jest preset for TypeScript support
  • Configure module path aliases (common/, components/, project/)
  • Set up coverage collection for common/ and web/ directories
  • Support for both __tests__/ directory pattern and *.test.ts files

CI/CD Integration

  • Add new GitHub Actions workflow (frontend-pull-request.yml)
  • Runs unit tests automatically on PRs that modify frontend code
  • Uses Node.js version from .nvmrc for consistency

Initial Test Coverage

  • Add comprehensive unit tests for featureFilterParams utility (245 lines)
    • Tests for buildUrlParams, buildApiFilterParams, getFiltersFromParams, hasActiveFilters
    • Covers archived feature filtering logic

Dependencies Added

  • jest - Test runner
  • ts-jest - TypeScript preprocessor for Jest
  • @types/jest - TypeScript definitions

Testing

cd frontend
npm run test:unit

Related


Note: This branch also includes fixes for versioned environment toggle functionality and E2E test improvements, which may be split into separate PRs if needed.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions