How to E2E-test
The foundation-testing package is a comprehensive framework for implementing End-to-End (E2E) testing. Use it to ensure that your Genesis Web Application provides a seamless user experience by testing workflows and user interactions across various scenarios.
Define test scenarios in the tests/e2e folder to cover all the critical user journeys in your application, and all the key functionality.
- Use Playwright for browser automation.
- Use Lighthouse for performance auditing within the same test suite.
- Execute tests via your preferred test runner or CI pipeline.
Set up Playwright
Install and configure Playwright as part of your project dependencies. Follow the set-up guide provided by the foundation-testing package. You can then write and run tests using the Playwright API to simulate real-world user interactions. These include clicking buttons, filling in forms, and navigating from page to page.
Incorporate Lighthouse
Integrate Lighthouse into your E2E tests to run performance audits alongside functional tests. The insights from these reports enables you to identify and address performance issues, so that you can optimse your application for speed and user experience.
Setting up end-to-end tests
Installing dependencies
-
Install Node.js, which is required for running JavaScript- and TypeScript-based tests.
-
Install Foundation Testing. This provides utilities for testing within your project, and integrates Playwright, which has Behavior-Driven Development (BDD) tools, and enables you to use Gherkin syntax in tests.
npm install --save-dev @genesislcap/foundation-testing