Skip to main content

Overview

Blueprint uses Jest for unit, integration tests and pact tests and Playwright for end-to-end (E2E) tests.

Identifying Test Files

Test files in Blueprint are identified by the .spec.ts or .spec.tsx file extensions.

Test Suite Structure

The Blueprint test suites consist of the following:

  • End-to-end (E2E) tests
  • Unit tests
  • Integration tests
  • Pact tests

End-to-End Tests

End-to-end testing differs from unit testing, as it focuses on testing the entire application workflow from start to finish to ensure that it behaves as expected. Blueprint uses Playwright to run E2E tests. It supports all modern rendering engines including Chromium, WebKit, and Firefox. For more details on Playwright configurations, refer to the Playwright documentation. These tests are located in the /src/test/playwright folder.

Running End-to-End Tests

You can run the E2E tests using the following commands inside any of the Blueprint apps. For example: apps/gb-energy-consumer-site:

  • Run all E2E tests:

    pnpm test:e2e

    or

    pnpm playwright test
  • Run E2E tests in Chromium only:

    pnpm test:e2e:chromium
  • Run E2E tests in Firefox only:

    pnpm test:e2e:firefox

Debugging End-to-End Tests

To debug the E2E tests, add the --debug flag to the run command. For example:

pnpm test:e2e --debug

Unit and Integration Tests

Unit and integration tests are located in the /src/tests folder. These test files have the .spec.ts or .spec.tsx extensions.

Running Unit and Integration Tests

You can run all unit and integration tests (excluding Playwright tests) using either of the following commands inside any of the Blueprint apps. For example: apps/gb-energy-consumer-site:

pnpm test

or

pnpm jest ./src --testPathIgnorePatterns="src/tests/(pact|playwright)"

Both commands will run all tests except for Playwright tests (E2E tests).

Pact Tests

Pact tests are a form of contract testing that ensures interactions between a consumer (such as a frontend application) and a provider (such as an API) are compatible. These tests focus on verifying that the provider meets the expectations defined by the consumer, preventing integration issues.

Running Pact Tests

You can run the Pact tests using the following command inside any of the Blueprint apps. For example: apps/gb-energy-consumer-site:

pnpm test:pact