The Govie Design System uses a comprehensive, multi-layered testing strategy to ensure the stability, accessibility, and visual integrity of the HTML, React, Angular and Vue component libraries.
Unit tests are utilised to verify core logic, utility functions, and component behaviours in isolation.
- Tooling: Vitest
- Execution: Run
pnpm run testfrom the project root or within specific packages. - Configuration:
- Root-level scripts in package.json orchestrate test runs.
- React library: vitest.config.ts, setups: vitest-unit.setup.ts, vitest-storybook.setup.ts
- HTML library: vitest.config.ts, setups: vitest-unit.setup.ts, vitest-storybook.setup.ts
- Angular library: vitest.config.ts, Storybook tests only
- Vue library: vitest.config.ts, Storybook tests only
- Continuous Integration: Integrated into the primary CI pipeline.yaml within the unit tests stage.
- Reporting: Results are published in JUnit format, with code coverage reports available as pipeline artefacts.
Coverage counts the code consumers can reach through each library's published entry points. Stories, the shared Storybook metas and generated icon components are excluded. Angular also excludes the generated atoms whose gi-* components render the native element themselves instead of the core-* tag.
Storybook serves as both a documentation platform and an isolated environment for End-to-End (E2E) component testing.
- Tooling: Storybook Interaction Testing via
playfunctions. - Methodology: Within
*.stories.tsxfiles,playfunctions simulate user interactions (e.g., clicks, keyboard input) and assert DOM state changes. - Example: Refer to the Tabs component stories.
- Verification: Every story runs in headless Chromium through
@storybook/addon-vitestas part ofpnpm run test.
A dual-tool approach is utilised to detect and prevent visual regressions across various browsers and viewports.
Chromatic is a cloud-based visual testing service integrated with Storybook that captures snapshots of every component state.
- Scope: Covers both
@ogcio/design-system-htmland@ogcio/design-system-react. - Configuration:
- Pipeline: Managed via visual-regression.yaml in the
ChromaticHTMLandChromaticReactstages. - Workflow: Facilitates collaborative review of visual changes during the Pull Request process.
An automated testing suite using Playwright for generating and comparing visual snapshots in the CI environment.
- Scope: Configured for
@ogcio/design-system-reactand@ogcio/design-system-angular. - Configuration: React playwright.config.ts, Angular playwright.config.ts.
- Implementation: Tests are dynamically generated based on the Storybook metadata (React visual.spec.ts, Angular visual.spec.ts).
- Execution: Run
pnpm playwright testwithin the React or Angular package. - Pipeline: Executed in the
PlaywrightandPlaywrightAngularstages of visual-regression.yaml using a specialised Playwright Docker container. - Snapshots: Baseline images are stored in
packages/react/tests/visual.spec.ts-snapshotsandpackages/angular/e2e/visual.spec.ts-snapshots.
Use the provided Makefile targets to run visual regression tests locally. These commands build the Playwright Docker image, start Storybook, execute tests, and manage snapshots.
Prerequisites:
- Docker installed and running
Commands:
- Build the Playwright image (uses Dockerfile.playwright)
make build-visual-tests-image
- Run the visual regression tests (builds Storybook and runs Playwright in Docker)
make react-visual-tests
- Update baseline screenshots after intentional visual changes
make react-visual-update
- Run or update the Angular visual regression tests
make angular-visual-tests make angular-visual-update
To run or update only a subset of stories, append Playwright's -g flag (grep on test title) to the command inside the react-visual-tests / react-visual-update Makefile targets. The flag accepts a regex, so you can match multiple components at once:
# Run only Autocomplete stories
... test -g "Autocomplete"
# Update snapshots for Autocomplete and Select
... test --update-snapshots -g "Autocomplete|Select"This speeds up iteration when debugging a specific flaky component without re-running the full suite.
Reference: Makefile
Regression testing is fully integrated into Azure DevOps Pipelines to ensure continuous quality assurance:
- Core Pipeline (pipeline.yaml):
- Enforces linting and formatting standards (
pnpm run lint,pnpm run format:check). - Executes library builds and unit tests.
- Conducts security vulnerability scans.
- Enforces linting and formatting standards (
- Visual Regression Pipeline (visual-regression.yaml):
- Triggered by changes in the component libraries (
react,html/ds,angular), the design packages and the themes. - Automates the build of libraries and Storybook instances.
- Runs parallel Chromatic and Playwright visual suites across multiple browsers (Chromium, Firefox, Webkit) and mobile emulators (Android, iOS).
- Triggered by changes in the component libraries (
Components or specific states that are unsuitable for visual testing (e.g. those containing persistent animations, loaders, or spinners) should be excluded:
- Playwright: Apply the
skip-playwrighttag to the story. - Slow stories: For stories with
playfunctions that need extra settle time before the screenshot, apply theslowtag — the test adds an additional wait of 3 seconds before capturing.