Skip to content

Commit

Permalink
test(e2e): support running in headless mode (#594)
Browse files Browse the repository at this point in the history
* test(e2e): allow running in headless mode

* add required env var to env.example also

* don't need xvfb-run

* update `test:e2e` script and docs
  • Loading branch information
sidvishnoi authored Sep 13, 2024
1 parent 6d9869f commit 78ddf6b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: pnpm exec playwright install --with-deps

- name: Run Playwright tests
run: xvfb-run pnpm test:e2e:${{ matrix.project }}
run: pnpm test:e2e:${{ matrix.project }}
env:
PLAYWRIGHT_PROJECT: ${{ matrix.project }}
PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS: '1'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: pnpm exec playwright install --with-deps

- name: Run Playwright tests
run: xvfb-run pnpm test:e2e:${{ matrix.project }}
run: pnpm test:e2e:${{ matrix.project }}
env:
PLAYWRIGHT_PROJECT: ${{ matrix.project }}
PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS: '1'
Expand Down
4 changes: 3 additions & 1 deletion docs/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Run `pnpm test` to run unit tests locally. These tests are run automatically on

## End-to-end Tests

To run end-to-end tests with chromium, run `pnpm test:e2e` in terminal.
To run end-to-end tests, run `pnpm test:e2e` in terminal. To run tests with Chrome only, run `pnpm test:e2e:chrome`.

Make sure you run `pnpm build chrome` before running tests.

**Before you begin**, you need to setup some environment variables/secrets in `tests/.env`.

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"format:fix": "prettier . --write --cache --cache-location='node_modules/.cache/prettiercache' --log-level=warn",
"typecheck": "tsc --noEmit",
"test": "jest --maxWorkers=2 --passWithNoTests",
"test:e2e": "pnpm test:e2e:chrome",
"test:e2e": "playwright test",
"test:e2e:chrome": "playwright test --project=chrome",
"test:e2e:msedge": "playwright test --project=msedge",
"test:e2e:report": "playwright show-report tests/e2e/playwright-report",
"test:ci": "pnpm test -- --reporters=default --reporters=github-actions"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Used when running tests locally.
# In CI, we pass these in via the environment variables directly.
PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1

# Can replace with a localhost instance if needed. Ensure doesn't end with /
WALLET_URL_ORIGIN=https://rafiki.money
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/fixtures/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ export async function loadContext(
let context: BrowserContext | undefined;
if (browserName === 'chromium') {
context = await chromium.launchPersistentContext('', {
headless: false, // headless isn't well supported with extensions
headless: true,
channel,
args: [
`--headless=true`,
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
],
Expand Down

0 comments on commit 78ddf6b

Please sign in to comment.