Skip to content
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

Run browser tests in a Docker container #821

Closed
wants to merge 10 commits into from
18 changes: 18 additions & 0 deletions .github/workflows/browser-tests.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Browser tests

on:
push:
branches: [ main ]
pull_request:

jobs:
browser-tests:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/[email protected]
- run: cp .env.development.prod .env
- run: sudo chown -R 1000:1000 ${GITHUB_WORKSPACE}
- run: docker compose run ui npm install
- run: docker compose --profile browser-tests up -d --wait
- run: docker compose exec -it ui npm run test:e2e
1 change: 0 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ jobs:
- run: npm run build --if-present
- run: npm run lint -- --no-fix
- run: npm run test:unit
- run: npm run test:e2e
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,13 @@ Backend api mocks live in `/src/backend/mocks/default_handlers.js`.
**Note**
Firefox blocks service workers as long as we use `localhost` for local development. The only solution is to use
chrom(ium) for now.

### Running browser tests

```sh
rm -r node_modules
docker compose run ui npm install
docker compose --profile browser-tests up -d
docker compose exec -it ui npm run test:e2e
docker compose --profile browser-tests down
```
19 changes: 18 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version: '3.3'

services:
ui:
env_file:
Expand All @@ -8,6 +9,22 @@ services:
working_dir: /home/node/app
volumes:
- ./:/home/node/app
command: npm run serve -- --port 8081
command: npm run serve -- --port 8081 --host ui
ports:
- 8081:8081
healthcheck:
test: curl --fail http://ui:8081 || exit 1
interval: 5s
start_period: 0s

selenium-firefox:
profiles: [browser-tests]
image: selenium/standalone-firefox:4.21.0
shm_size: 2gb
ports:
- 4444:4444
- 7900:7900
healthcheck:
test: curl --fail http://selenium-firefox:4444 || exit 1
interval: 5s
start_period: 0s
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:e2e": "vue-cli-service test:e2e",
"test:e2e": "vue-cli-service test:e2e --baseUrl=http://ui:8081/",
"lint": "vue-cli-service lint"
},
"dependencies": {
Expand Down
9 changes: 8 additions & 1 deletion wdio.local.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ exports.config = {
/**
* config for local testing
*/
logLevel: 'debug',
outputDir: '',
maxInstances: 1,
services: ['geckodriver'],
hostname: 'selenium-firefox',
port: 4444,
path: '/wd/hub',
capabilities: [
{
browserName: 'firefox',
'moz:firefoxOptions': {
args: ['-headless']
},
'alwaysMatch': {
'moz:debuggerAddress': true
}
}
]
}
Loading