added documentation for test changes

This commit is contained in:
Aaro Koivukangas
2024-10-24 12:13:20 +03:00
committed by Aaro Koivukangas
parent 895f5b9ec7
commit adbace59e9
+32 -15
View File
@@ -24,24 +24,41 @@ Testing:
+ `npm run check`
+ Runs `tsc` and `eslint` for frontend and backend: Use this to check for errors before committing.
+ `npm run test:api`
+ Runs all required containers and api-tests with one command inside Docker.
+ Uses `docker-compose.test.yml`
+ Runs the api-tests in a docker container
+ Requires database to be running. Can be achieved by `npm run start:anon -- db-anon` or just `npm run start:anon:api`.
+ Uses `test_data`
+ Uses `.test.env`
+ `npm run test:api:build` builds the container used to run the tests.
+ `npm run test:api:run` runs the previously built container.
+ `npm run test:e2e`
+ Runs all required containers and e2e-tests with one command inside Docker.
+ Uses `docker-compose.test.yml`
+ Runs e2e-tests inside a docker container.
+ Requires `frontend`, `backend` and `database` to be running. Can be achieved by running `npm run start:anon`.
+ Uses `test_data`
+ `npm run test:up`
+ Runs the test version of the project with anonymized test-database without tests.
+ Uses `docker-compose.test.yml`
+ Uses `test_data`
+ `npm run test:local:e2e`
+ Runs cypress-tests locally in headless mode. Requires `npm run test:up` to be running first.
+ `npm run test:local:api`
+ Runs backend api tests. Requires `db-anon` to be running first. (Note: backend doesn't need to be running.)
+ All environment variables need to be set.
+ `npm run test:e2e:local`
+ Runs cypress-tests locally (not in docker) in headless mode.
+ Requires `npm run start:anon` to be running first.
+ `npm run test:api:local`
+ Runs backend api tests locally (not in docker).
+ Requires `db-anon` to be running first. (Note: backend doesn't need to be running.)
+ Requires `.test.env`
+ `npm run cypress`
+ Opens cypress. You can run tests and see what they do.
+ Opens cypress GUI. You can run tests and see what they do.
Windows testing:
+ Both `e2e` and `api-tests` have a Windows specific command.
+ `e2e` is `npm run test:e2e:windows`
+ `api-tests` is `npm run test:api:windows`
+ For `api-tests`: inside `.test.env`, if compared to `.anon.env`, you need to change all instances of `nowdb-db-anon` to `host.docker.internal`.
+ These include `MARIADB_HOST`, `DATABASE_URL` and `LOG_DATABASE_URL`.
+ Note: these are not tested yet.
Test env-file:
+ `.test.env`
+ `api-tests` requires `.test.env` to set the correct environment variables.
+ This can be created by copying `.anon.env` and changing all instances of `nowdb-db-anon` to `localhost`.
+ These include `MARIADB_HOST`, `DATABASE_URL` and `LOG_DATABASE_URL`.
Coverage:
@@ -63,7 +80,7 @@ Run with the same image that is used in production:
Docker:
+ `npm run dev:down`
+ Stops and removes the dev container.
+ Stops and removes the dev container and it's volumes.
+ `-- --build`
+ Useful flag to force docker to rebuild the containers. Example usage for dev: `npm run dev -- --build`