Skip to content

Commit

Permalink
Merge pull request #147 from adhocteam/dcloud/docker-tests-changes-pe…
Browse files Browse the repository at this point in the history
…r-feedback

Document bin/run-tests, make sure frontend tests run in frontend instance
  • Loading branch information
dcloud committed Feb 4, 2021
2 parents ba18d84 + d29a75d commit c6f62d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ docker exec test-backend bash -c "yarn db:seed;"
docker exec test-backend bash -c "yarn test:ci"

# Test frontend
docker exec test-backend bash -c "yarn --cwd frontend run test:ci"
docker exec test-frontend bash -c "yarn --cwd frontend run test:ci"

# Cleanup
docker-compose \
Expand Down
6 changes: 6 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ When writing tests that create database records, it might also help to use a `tr

## Testing in Docker

### Using `./bin/run-tests`

To simplify running tests in Docker, there is a bash script, `./bin/run-tests` that will run the appropriate commands to start `test-` variations of the services used in tests. You should be able to run tests using that command while your development Docker environment is running. The script uses a separate `docker-compose.test.yml` which does not create a user-accessible network and cleans up after itself once tests have run.

### Running tests in your development Docker environment

When running tests in Docker, be aware that there are tests that will modify/delete database records. For tests to run, the 'db' service needs to exist and `db:migrate` and `db:seed` need to have been run (to create the tables and populate certain records).

In the `docker-compose.yml` configuration, the database is set up to persist to a volume, "dbdata", so database records will persist between runs of the 'db' service, unless you remove that volume explicitly (e.g. `docker volume rm` or `docker-compose down --volumes`).
Expand Down

0 comments on commit c6f62d6

Please sign in to comment.