Testing
Scope
This section covers frameworks, libraries, tools, and methodologies used for testing our frontend applications. This includes unit testing, integration testing, component testing, end-to-end (E2E) testing, and related utilities.
Overview
ADOPT
Proven technologies we have high confidence in; our default choices.
ASSESS
Interesting technologies requiring investigation.
Technologies Breakdown
Vitest ADOPT
An adopted framework for unit and integration testing, particularly recommended for projects using Vite due to performance benefits. Offers a Jest-compatible API. Use with RTL for component testing.
Provides a faster, modern testing experience leveraging Vite's architecture. Its Jest-compatible API simplifies adoption. Offers first-class TypeScript/ESM support. Adopted for its performance and alignment with Vite-based projects.
Jest ADOPT
An adopted framework for unit and integration testing of JavaScript/TypeScript code. Commonly used in projects not utilizing Vite, or where specific Jest features/ecosystem are preferred. Use with RTL for component testing.
Mature, feature-rich testing framework with a large ecosystem. Provides built-in assertions, mocking, and coverage. Well-understood by the team and suitable for various testing needs. Adopted alongside Vitest, choice may depend on project context.
React Testing Library (RTL) ADOPT
The standard library for writing tests for React components, used in conjunction with either Jest or Vitest as the test runner. Focus on testing components from the user's perspective.
Promotes writing maintainable, user-centric tests, increasing confidence in UI behavior. Discourages testing implementation details. Excellent integration with the React ecosystem. Adopted as the standard for React component testing.
JUnit 5 & Mockito ADOPT
This pair forms the foundation of our unit testing strategy. JUnit is the standard for writing tests, and Mockito is our go-to library for creating mock objects and isolating components under test.
REST Assured ADOPT
REST Assured is our recommended tool for writing clean and maintainable integration tests for our RESTful APIs. It provides a fluent DSL that simplifies API test automation.
Cypress TRIAL
Actively explore for End-to-End (E2E) testing and potentially component testing. Evaluate its developer experience, debugging capabilities, and performance in real-world project scenarios, comparing it with Playwright.
Offers an excellent developer experience for E2E testing with unique features like time-travel debugging. We are trialing it alongside Playwright to determine the best fit for our E2E testing needs across different projects and team preferences.
Playwright TRIAL
Actively explore for End-to-End (E2E) testing and potentially component testing. Evaluate its cross-browser capabilities, execution speed, API design, and overall developer experience compared to Cypress.
A powerful, modern E2E testing framework from Microsoft offering excellent cross-browser support and potentially faster execution. We are trialing it alongside Cypress to gain practical experience and make an informed decision on which tool (or potentially both for different use cases) to adopt more broadly.
Testcontainers TRIAL
We are actively trialing Testcontainers to improve the reliability of our integration tests. This library allows us to test against real dependencies, like a PostgreSQL database running in a Docker container, leading to more accurate test results.
Enzyme HOLD
Avoid for all new React component testing. Used in some legacy projects; prioritize migration to React Testing Library (RTL) during refactoring.
Previously popular for React component testing, Enzyme encourages testing implementation details, leading to brittle tests. React Testing Library (RTL) offers a more user-centric and maintainable approach and is now the recommended standard by the React community and our team.
PowerMock HOLD
While PowerMock can test difficult legacy code, its usage often indicates poor code design and can lead to brittle tests. We discourage its use in new code, favoring modern dependency injection and standard Mockito for creating testable applications.