From 982bc75b8f5fb3e7fb14906309904208d0e75ccb Mon Sep 17 00:00:00 2001 From: Shelley Nason Date: Thu, 20 Feb 2025 15:39:34 -0600 Subject: [PATCH 1/3] Run tests as part of the CI build. --- .github/workflows/ci.yml | 7 ++++++- .gitignore | 3 ++- features/README.md | 10 +++++++++- package-lock.json | 6 +++--- package.json | 1 + 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 072f06d..4ddac06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ on: pull_request: jobs: - lint: + build: runs-on: ubuntu-latest permissions: contents: read @@ -19,3 +19,8 @@ jobs: run: npm ci --timing - name: Lint javascript run: npm run lint + - name: Run tests + # aa-exec applies Ubuntu's AppArmor profile for stable Chrome binaries to the Chrome for Testing binary downloaded by Puppeteer + # Without it, Puppeteer fails with error "No usable sandbox!" + # See https://pptr.dev/troubleshooting#issues-with-apparmor-on-ubuntu + run: npm run test-site-dev & sleep 20; aa-exec --profile=chrome npm run cucumber diff --git a/.gitignore b/.gitignore index 30bc162..fe03b2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/node_modules \ No newline at end of file +node_modules +output \ No newline at end of file diff --git a/features/README.md b/features/README.md index d7ca0c4..73126fe 100644 --- a/features/README.md +++ b/features/README.md @@ -24,12 +24,20 @@ Then run the tests against the test site: npm run cucumber ``` -## Running the tests with a debugger attached +### Running the tests with a debugger attached ```bash npm run cucumber:debug ``` +### Running the tests and generating a nicely formatted test report + +```bash +npm run cucumber:report +``` + +Test report should be available in `output/test-results.html`. + ## Configuring with environment variables ### Verbose mode diff --git a/package-lock.json b/package-lock.json index 6077688..0034323 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1108,9 +1108,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001651", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz", - "integrity": "sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==", + "version": "1.0.30001700", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001700.tgz", + "integrity": "sha512-2S6XIXwaE7K7erT8dY+kLQcpa5ms63XlRkMkReXjle+kf6c5g38vyMl+Z5y8dSxOFDhcFe+nxnn261PLxBSQsQ==", "dev": true, "funding": [ { diff --git a/package.json b/package.json index e9e366c..c3e2f53 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "lint": "eslint Universal-Federated-Analytics.js", "cucumber": "cucumber-js", "cucumber:debug": "VERBOSE=true node --inspect-brk node_modules/@cucumber/cucumber/bin/cucumber-js", + "cucumber:report": "cucumber-js --format \"html\":\"output/test-results.html\"", "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", "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", "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" From 40b74a2b71417edecdda4ae38563a0142bd715ae Mon Sep 17 00:00:00 2001 From: Shelley Nason Date: Thu, 26 Feb 2026 12:36:29 -0500 Subject: [PATCH 2/3] Update the README file for testing. --- features/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/README.md b/features/README.md index 73126fe..f52698b 100644 --- a/features/README.md +++ b/features/README.md @@ -15,7 +15,7 @@ the test HTML page instead of the local version as described below. Start up the test site at http://localhost:8080/: ```bash -npm run test-site +npm run test-site-dev ``` Then run the tests against the test site: From c44345e72cb147f91bbe8d9fb261923e26912265 Mon Sep 17 00:00:00 2001 From: Shelley Nason Date: Fri, 27 Feb 2026 13:57:38 -0500 Subject: [PATCH 3/3] Fix call to aa-exec in automated tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ddac06..82103b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,4 +23,4 @@ jobs: # aa-exec applies Ubuntu's AppArmor profile for stable Chrome binaries to the Chrome for Testing binary downloaded by Puppeteer # Without it, Puppeteer fails with error "No usable sandbox!" # See https://pptr.dev/troubleshooting#issues-with-apparmor-on-ubuntu - run: npm run test-site-dev & sleep 20; aa-exec --profile=chrome npm run cucumber + run: npm run test-site-dev & sleep 20; aa-exec -p chrome -- npm run cucumber