Skip to content

Latest commit

 

History

History
34 lines (21 loc) · 2.04 KB

TESTING.md

File metadata and controls

34 lines (21 loc) · 2.04 KB

Component Testing Guidelines

Purpose and Scope

This document outlines the testing strategy and guidelines for component tests within the project. Component tests are essential for ensuring the reliability and stability of the UI components, helping to catch regressions and errors early in the development process.

Writing New Component Tests

When contributing new component tests, please follow these guidelines:

  • Isolate the Component: Ensure the component is tested in isolation, mocking any external dependencies if necessary.
  • Test the Interface, Not the Implementation: Focus on testing the behavior visible to the user, not the internal implementation details.
  • Cover All Use Cases: Include tests for all the component's use cases, including rendering with different props and user interactions.
  • Use Descriptive Test Names: Test names should clearly describe what they are testing and the expected outcome.
  • Arrange-Act-Assert Pattern: Structure your tests with setup ('Arrange'), execution ('Act'), and verification ('Assert') steps.

Common Assertions and Testing Patterns

Here are some common assertions and patterns used in our component tests:

  • Rendering: Verify that the component renders correctly with various props.
  • User Interaction: Simulate user interactions (e.g., clicks, typing) and verify the component behaves as expected.
  • Event Handling: Ensure that the component correctly handles events and calls the appropriate callback functions.
  • Conditional Rendering: Test the component's behavior when conditional rendering logic is involved.

For more detailed examples, refer to the existing component tests in the components directory.

Tools and Libraries

We use Cypress for our component testing. Refer to the Cypress documentation for more details on writing tests using Cypress.

Continuous Integration

All component tests are automatically run as part of the Continuous Integration (CI) pipeline on every pull request. Ensure your tests pass locally before submitting your pull request.