2020-12-10 14:52:35 +01:00
# Frontend Testing With Cypress
## Setup
* Enable the [seeder api endpoint ](https://vikunja.io/docs/config-options/#testingtoken ). You'll then need to add the testingtoken in `cypress.json` or set the `CYPRESS_TEST_SECRET` environment variable.
* Basic configuration happens in the `cypress.json` file
* Overridable with [env ](https://docs.cypress.io/guides/guides/environment-variables.html#Option-3-CYPRESS )
* Override base url with `CYPRESS_BASE_URL`
## Fixtures
2021-09-26 19:49:27 +02:00
We're using the [test endpoint ](https://vikunja.io/docs/config-options/#testingtoken ) of the vikunja api to
seed the database with test data before running the tests.
2020-12-10 14:52:35 +01:00
This ensures better reproducability of tests.
## Running The Tests Locally
### Using Docker
The easiest way to run all frontend tests locally is by using the `docker-compose` file in this repository.
It uses the same configuration as the CI.
To use it, run
2021-09-26 19:49:27 +02:00
```shell
2020-12-10 14:52:35 +01:00
docker-compose up -d
```
Then, once all containers are started, run
2021-09-26 19:49:27 +02:00
```shell
2021-09-21 18:59:35 +02:00
docker-compose run cypress bash
2020-12-10 14:52:35 +01:00
```
to get a shell inside the cypress container.
In that shell you can then execute the tests with
2021-09-26 19:49:27 +02:00
```shell
2020-12-10 14:52:35 +01:00
yarn test:frontend
```
### Using The Cypress Dashboard
To open the Cypress Dashboard and run tests from there, run
2021-09-26 19:49:27 +02:00
```shell
2020-12-10 14:52:35 +01:00
yarn cypress:open
```