Skip to content

Commit

Permalink
Automated Testing: Update e2e test npm commands (#60376)
Browse files Browse the repository at this point in the history
* Automated Testing: Update e2e test npm commands
* Update command references
* Simplify backward comp

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>
  • Loading branch information
3 people authored Apr 4, 2024
1 parent b59d363 commit 9c6d4fe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/end2end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e:playwright -- --shard=${{ matrix.part }}/${{ matrix.totalParts }}
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e -- --shard=${{ matrix.part }}/${{ matrix.totalParts }}
- name: Archive debug artifacts (screenshots, traces)
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
Expand Down
14 changes: 7 additions & 7 deletions docs/contributors/code/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ See the dedicated guide if you're working with the previous Jest + Puppeteer fra

```bash
# Run all available tests.
npm run test:e2e:playwright
npm run test:e2e

# Run in headed mode.
npm run test:e2e:playwright -- --headed
npm run test:e2e -- --headed

# Run tests with specific browsers (`chromium`, `firefox`, or `webkit`).
npm run test:e2e:playwright -- --project=webkit --project=firefox
npm run test:e2e -- --project=webkit --project=firefox

# Run a single test file.
npm run test:e2e:playwright -- <path_to_test_file> # E.g., npm run test:e2e:playwright -- site-editor/title.spec.js
npm run test:e2e -- <path_to_test_file> # E.g., npm run test:e2e -- site-editor/title.spec.js

# Debugging.
npm run test:e2e:playwright -- --debug
npm run test:e2e -- --debug
```

If you're developing in Linux, it currently requires testing Webkit browsers in headed mode. If you don't want to or can't run it with the GUI (e.g. if you don't have a graphic interface), prepend the command with [`xvfb-run`](https://manpages.ubuntu.com/manpages/xenial/man1/xvfb-run.1.html) to run it in a virtual environment.

```bash
# Run all available tests.
xvfb-run npm run test:e2e:playwright
xvfb-run npm run test:e2e

# Only run webkit tests.
xvfb-run -- npm run test:e2e:playwright -- --project=webkit
xvfb-run -- npm run test:e2e -- --project=webkit
```

## Best practices
Expand Down
5 changes: 1 addition & 4 deletions docs/contributors/code/testing-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,7 @@ However, if the change was intentional, follow these steps to update the snapsho
npm run test:unit -- --updateSnapshot --testPathPattern path/to/tests

# Update snapshot for e2e tests
npm run test:e2e -- --updateSnapshot --testPathPattern path/to/e2e-tests

# Update snapshot for Playwright
npm run test:e2e:playwright -- --update-snapshots path/to/spec
npm run test:e2e -- --update-snapshots path/to/spec
```
1. Review the diff and ensure the changes are expected and intentional.
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@
"storybook:e2e:dev": "concurrently \"npm run dev:packages\" \"storybook dev -c test/storybook-playwright/storybook -p 50241\"",
"test": "npm-run-all lint test:unit",
"test:create-block": "bash ./bin/test-create-block.sh",
"test:e2e": "wp-scripts test-e2e --config packages/e2e-tests/jest.config.js",
"test:e2e:debug": "wp-scripts --inspect-brk test-e2e --runInBand --no-cache --verbose --config packages/e2e-tests/jest.config.js --puppeteer-devtools",
"test:e2e:playwright": "wp-scripts test-playwright --config test/e2e/playwright.config.ts",
"test:e2e:playwright:debug": "wp-scripts test-playwright --config test/e2e/playwright.config.ts --ui",
"test:e2e": "wp-scripts test-playwright --config test/e2e/playwright.config.ts",
"test:e2e:debug": "wp-scripts test-playwright --config test/e2e/playwright.config.ts --ui",
"test:e2e:playwright": "npm run test:e2e",
"test:e2e:playwright:debug": "npm run test:e2e:debug",
"test:e2e:storybook": "playwright test --config test/storybook-playwright/playwright.config.ts",
"test:e2e:watch": "npm run test:e2e -- --watch",
"test:native": "cross-env NODE_ENV=test jest --config test/native/jest.config.js",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const config = defineConfig( {
* Headless webkit won't receive dataTransfer with custom types in the
* drop event on Linux. The solution is to use `xvfb-run` to run the tests.
* ```sh
* xvfb-run npm run test:e2e:playwright
* xvfb-run npm run test:e2e
* ```
* See `.github/workflows/end2end-test-playwright.yml` for advanced usages.
*/
Expand Down

0 comments on commit 9c6d4fe

Please sign in to comment.