End to End testing guide
We use cypress for end-to-end testing.
Running cypress can be done in two ways:
- Locally: By starting docker (
docker-compose up backend client) and running cypress in
npx cypress open.
docker-compose run --rm cypress
Login as a role
It is necessary to login in almost every end to end test. In order to do this we recommend to use the cypress helper
loginAs. Here you can pass a user type, which can be found in
Interacting with elements
We wrote a usefull getter, so we don't have to work with classes or ids. First you have to add an
e2e data attribute to the HTML element:
Then you can interact with that HTML element in cypress by using:
If you cannot add the e2e attribute to the HTML element (perhaps because it is injected by a dependency), then you can do the following:
And select it as:
- Use detailed and unique
data-e2enames, so we won't use the same name in other places.
- When editing an object, please reset it afterwards in the spec. This will make the spec reusable.