Cypress Tests - bcgov/PIMS GitHub Wiki
Cypress is a testing framework that we are using for End to End testing.
Read up on Cypress Best Practices before creating a test.
One of the key points here, is that we want to clean up tests before the tests happen.
For an example, look at frontend/cypress/e2e/DisposalProjects/createDraft.cy.ts
Read our Commenting Standards for Cypress Tests.
Selecting Elements:
Every test you write will include selectors for elements. To save yourself a lot of headaches, you should write selectors that are resilient to changes.
+ Use data-* attributes to provide context to your selectors and isolate them from CSS or JS changes.
Selector | Recommended | Notes |
| 🚩 Never | Worst - too generic, no context. |
| 🚩 Never | Bad. Coupled to styling. Highly subject to change. |
| | Better. But still coupled to styling or JS event listeners. |
| | Coupled to the name attribute which has HTML semantics. |
| ✅ Depends | Much better. But still coupled to text content that may change. |
| ✅ Always | Best. Isolated from all changes. |
Run npm run cypress:open
in frontend to open the cypress application window.
Run npm run cypress:e2e
in frontend to run the end to end tests in CLI.
Select E2E Testing:
Select the browser to test on:
Select the test you want to run: