Skip to content

Commit 4622669

Browse files
authored
Run tests as part of the CI build. (#164)
1 parent 39d150f commit 4622669

5 files changed

Lines changed: 22 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
pull_request:
44

55
jobs:
6-
lint:
6+
build:
77
runs-on: ubuntu-latest
88
permissions:
99
contents: read
@@ -19,3 +19,8 @@ jobs:
1919
run: npm ci --timing
2020
- name: Lint javascript
2121
run: npm run lint
22+
- name: Run tests
23+
# aa-exec applies Ubuntu's AppArmor profile for stable Chrome binaries to the Chrome for Testing binary downloaded by Puppeteer
24+
# Without it, Puppeteer fails with error "No usable sandbox!"
25+
# See https://pptr.dev/troubleshooting#issues-with-apparmor-on-ubuntu
26+
run: npm run test-site-dev & sleep 20; aa-exec -p chrome -- npm run cucumber

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/node_modules
1+
node_modules
2+
output

features/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ the test HTML page instead of the local version as described below.
1515
Start up the test site at http://localhost:8080/:
1616

1717
```bash
18-
npm run test-site
18+
npm run test-site-dev
1919
```
2020

2121
Then run the tests against the test site:
@@ -24,12 +24,20 @@ Then run the tests against the test site:
2424
npm run cucumber
2525
```
2626

27-
## Running the tests with a debugger attached
27+
### Running the tests with a debugger attached
2828

2929
```bash
3030
npm run cucumber:debug
3131
```
3232

33+
### Running the tests and generating a nicely formatted test report
34+
35+
```bash
36+
npm run cucumber:report
37+
```
38+
39+
Test report should be available in `output/test-results.html`.
40+
3341
## Configuring with environment variables
3442

3543
### Verbose mode

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint": "eslint Universal-Federated-Analytics.js",
1010
"cucumber": "cucumber-js",
1111
"cucumber:debug": "VERBOSE=true node --inspect-brk node_modules/@cucumber/cucumber/bin/cucumber-js",
12+
"cucumber:report": "cucumber-js --format \"html\":\"output/test-results.html\"",
1213
"test-site-dev": "docker build --no-cache --build-arg DAP_ENV='dev' -t dap-test-site-dev . && docker run --rm -p 8080:80 --name dap-test-site-dev dap-test-site-dev",
1314
"test-site-stg": "docker build --no-cache --build-arg DAP_ENV='stg' -t dap-test-site-stg . && docker run --rm -p 8080:80 --name dap-test-site-stg dap-test-site-stg",
1415
"test-site-prd": "docker build --no-cache --build-arg DAP_ENV='prd' -t dap-test-site-prd . && docker run --rm -p 8080:80 --name dap-test-site-prd dap-test-site-prd"

0 commit comments

Comments
 (0)