Skip to content

Test documentation and bash script error handling #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ See the `docker-compose.override.yml` playwright entry and the version imported

### Dev mode

This project includes a test script that handles building assets, running
Playwright tests, and stops and starts the node container. This script tests the
*built* files.

```bash
./scripts/test {TEST-PATH}
```

TEST-PATH is optional, and is the specific test file or directory to run like
`admin`/`client`/`template` or a specific file, e.g. `admin-app.spec.js`. If
TEST-PATH is omitted, all tests will run.

To run tests locally, there are a few options.

To run from the developer machine:
Expand Down
24 changes: 24 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# -o errexit: Exit immediately if a command exits with a non-zero status.
# -o errtrace: Ensures that the ERR trap is also triggered when the error occurs inside a function or a subshell. (https://stackoverflow.com/questions/25378845/what-does-set-o-errtrace-do-in-a-shell-script)
# -o noclobber: Prevents accidentally overwriting files with output redirection.
# -o nounset: This command will cause the shell to exit if a variable is accessed before it is set.
# -o pipefail: Ensures that a pipeline return the exit status of the command that first fails.
set -o errexit -o errtrace -o noclobber -o nounset -o pipefail

TEST_PATH="${1:-}"

# Stop node container to avoid build conflicts.
docker compose stop node
# Build assets.
docker compose run --rm node npm run build

# Run tests (with or without a test path)
if [[ -n "$TEST_PATH" ]]; then
docker compose run --rm playwright npx playwright test "$TEST_PATH"
else
docker compose run --rm playwright npx playwright test
fi
# Restart node container.
docker compose start node
8 changes: 0 additions & 8 deletions scripts/test.sh

This file was deleted.

Loading