Skip to content

Latest commit

 

History

History
80 lines (49 loc) · 3.29 KB

File metadata and controls

80 lines (49 loc) · 3.29 KB

E2E Testing README

This document provides instructions on how to use the run.sh and update-snapshots.sh scripts located in the docker directory as well as give some hints how to write tests (ongoing process).

Prerequisites

  • Docker installed on your machine
  • Necessary permissions to execute shell scripts
  • Built Storybook static bundles for the packages you test (see below)

The Docker scripts use the official Playwright image, enable pnpm via corepack (version from the root packageManager field), and run a full workspace pnpm install inside the container (same as CI). E2e tests import source from packages/react, so installing only the e2e package is not enough.

Docker installs use a separate pnpm store at e2e/.pnpm-store and Linux dependencies at node_modules.e2e in the repo root (gitignored). pnpm also creates small node_modules.e2e stubs next to workspace packages that link into the root tree; those are gitignored via **/node_modules.e2e. Do not symlink root node_modules.e2e — pnpm 11 fails with ENOTDIR if that path is a symlink.

Configuration is Docker-only via pnpm_config_* environment variables in e2e/docker/lib.sh and does not affect your host pnpm store or node_modules. The first run may take several minutes; later runs skip pnpm install when the lockfile has not changed.

To reset the Docker dependency cache: rm -rf e2e/.pnpm-store node_modules.e2e

Host pnpm install uses node_modules. Docker e2e uses node_modules.e2e at the repo root (Linux).

Usage

Before running the tests build the corresponding Storybooks which the tests are ran against.

Running Tests

To run all the end-to-end tests, use the run.sh script:

cd docker
./run.sh

If you wish to run only certain package's tests (core for example):

cd docker
./run.sh core

Or if you want to run only a certain component's tests (react button for example):

cd docker
./run.sh react button

These scripts run the Docker container, executing the tests inside the container.

Updating Snapshots

If you need to update the snapshots, use the update-snapshots.sh script:

cd docker
./update-snapshots.sh

If you with to be more precise, use same targetting manner as in running the tests (for example update only core tag reference images):

cd docker
./update-snapshots.sh core tag

This script will update the snapshot files used in the tests.

Writing tests

  • To be implemented....

Notes

  • Do not run the scripts in package.json locally since the screenshots will most likely differ from the ones created in CI and will cause the tests to fail.

  • If you need to update Playwright version in the project, you need to match the versions in package.json's devDependencies and the docker scripts (used Docker images).

    • And be EXTRA careful with it since the used Playwright Docker image might have different version of Ubuntu than what's running in CI (Github actions). So make sure that the GA workflow (.github/workflows/e2e-test.yml) has the same Ubuntu version than what the Playwright Docker image has! This is why the GA-workflow doesn't have ubuntu-latest because it will start failing eventually due to version-mismatch.

For further assistance, refer to the project documentation or contact the development team.