-
Notifications
You must be signed in to change notification settings - Fork 5
E2E Tests
Alex Weng edited this page Mar 28, 2024
·
22 revisions
Integration E2E tests are located in the e2e-tests/
directory. These tests use Playwright to interact with UI in a desktop or mobile web browser.
This E2E test framework uses the Page Object Model for easy maintainance and reduces code duplication. Each web page of an application is represented as a class file. The fluent pattern allows functions chaining to make code more readable.
A widget class is a reusable class which represents a common page control. Examples of widgets are
- navbar.ts
- footer.ts
- textbox.ts
- radiogroup.ts
- question.ts
- Externalize strings to resource files for reuse, fast editing and localization.
- Create common reusable functions in an abstract base class to eliminate duplicated code.
- Write web element locators for keeping tests clean.
- No getter functions for web element locators because they clutter up file.
- No complex logics functions for application business logics.
- No long xpath/css selectors because they are brittle.
- AVOID writing new function which is not reusable to other tests.
- Use fixture to set up common actions such as log-in or opening a study landing page.
- Use
await test.step
to group relevant steps to make tests and logs easy to read and understand. - Use
expect
(import { expect } from '@playwright/test'
) to assert each step is working expectely. Ensures error is detected right as it occur. - UI visual screenshot test file naming convention is
*.visual.test.ts
- No xpath/css selectors
- Use
*.env.*
to set or override default environment variables - Use
global.setup.ts
to set common environment variables