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

Convert E2E tests from Puppeteer to Playwright #2041

Merged
merged 35 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
81da4a2
Install playwright 1.33
mikkamp Aug 1, 2023
50f8211
Add starting PlayWright configuration
mikkamp Aug 1, 2023
f50217a
Add global PlayWright setup script
mikkamp Aug 1, 2023
199a5ff
Convert getting started test
mikkamp Aug 1, 2023
a24308c
Convert setup MC step 1
mikkamp Aug 1, 2023
da443ff
Remove unused utilities
mikkamp Aug 1, 2023
73eb58d
Ignore test results in git
mikkamp Aug 1, 2023
89b8bc9
Exclude rule jest/no-done-callback in E2E js files
mikkamp Aug 1, 2023
8b0d7a0
Remove creation of ready page
mikkamp Aug 1, 2023
742aedc
Add axios as a dev dependency
mikkamp Aug 3, 2023
6b5929b
Use plugin for setting test conversion data
mikkamp Aug 3, 2023
c33748d
Setup payment gateway for purchase
mikkamp Aug 3, 2023
0bdbea3
Add price to simple product
mikkamp Aug 3, 2023
a261ef3
Convert GTag tests to PlayWright
mikkamp Aug 3, 2023
4d07484
Remove unused util functions
mikkamp Aug 3, 2023
1b7b5b2
Turn off parallel processing
mikkamp Aug 3, 2023
93c50bf
Replace e2e scripts
mikkamp Aug 3, 2023
e8d151a
Replace waitForSelector
mikkamp Aug 3, 2023
ba89d8f
Remove woocommerce/e2e packages
mikkamp Aug 3, 2023
8b5edc7
Remove puppeteer config files
mikkamp Aug 3, 2023
0551035
Update E2E testing instructions in documentation
mikkamp Aug 3, 2023
94ad50d
Remove unused puppeteer packages
mikkamp Aug 3, 2023
0687ea2
Remove unused docker init file
mikkamp Aug 3, 2023
602ab18
Fix GitHub workflow for E2E tests
mikkamp Aug 3, 2023
173066c
Install chromium browser for playwright
mikkamp Aug 3, 2023
165e370
Wait for all resources to be loaded
mikkamp Aug 3, 2023
f0ffddd
Use waitForURL after redirect
mikkamp Aug 3, 2023
b7a5447
Switch toBeEnabled
mikkamp Aug 3, 2023
1ef84e6
Add missing packages and config for jest
mikkamp Aug 3, 2023
1c7f366
Use getByRole with name
mikkamp Aug 3, 2023
2e913ab
Add wp-cli.yml to hard flush rewrite rules
mikkamp Aug 3, 2023
2a773ad
Clarify comments in playwright config
mikkamp Aug 8, 2023
3c51032
Use console warn and error
mikkamp Aug 8, 2023
e7891a3
Add some function descriptions
mikkamp Aug 8, 2023
3bb245b
Merge develop into e2e/playwright-tests
mikkamp Aug 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@ module.exports = {
'import/no-duplicates': 'off',
'no-duplicate-imports': 'warn',
},
overrides: [
{
files: [ 'tests/e2e/**/*.js' ],
rules: {
'jest/no-done-callback': [ 'off' ],
},
},
],
};
25 changes: 9 additions & 16 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ jobs:
env:
FORCE_COLOR: 2
steps:
# Needed for Ubuntu 20.04.
- name: Kill mono to free 8084
run: |
sudo killall mono

- name: Checkout repository
uses: actions/checkout@v3

Expand All @@ -45,22 +40,20 @@ jobs:
npm run build
echo "::endgroup::"

- name: Start docker container
run: |
npm run docker:up
sleep 10
- name: Start wp-env container
run: npm run wp-env:up

- name: Download and install Chromium browser.
run: npx playwright install chromium

- name: Run tests
env:
WC_E2E_SCREENSHOTS: 1
run: |
npm run test:e2e
run: npm run test:e2e

- name: Archive e2e test screenshots
- name: Archive e2e failure screenshots
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: e2e-screenshots
path: tests/e2e/screenshots
path: tests/e2e/test-results/report/**/*.png
if-no-files-found: ignore
retention-days: 5
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ languages/*
coverage
tests/php-coverage
.phpunit.result.cache
tests/e2e/test-results.json
tests/e2e/test-results

# Directories/files that may appear in your environment
.DS_Store
Expand Down
4 changes: 4 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"plugins": [
"https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip",
"https://github.com/WP-API/Basic-Auth/archive/master.zip",
"./tests/e2e/bin/test-data.php",
"."
],
"mappings": {
"wp-cli.yml": "./tests/e2e/config/wp-cli.yml"
},
"lifecycleScripts": {
"afterStart": "./tests/e2e/bin/test-env-setup.sh",
"afterClean": "./tests/e2e/bin/test-env-setup.sh"
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,14 @@ The tests will execute and you'll be presented with a summary.

## E2E Testing

E2E testing uses [@woocommerce/e2e-environment](https://www.npmjs.com/package/@woocommerce/e2e-environment) which requires [Docker](https://www.docker.com/).
E2E testing uses [wp-env](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/) which requires [Docker](https://www.docker.com/).

Make sure Docker is running in your machine, and run the following:

`npm run docker:up` - This will automatically download and run WordPress in a Docker container. You can access it at http://localhost:8084 (Username: admin, Password: password).
`npm run wp-env:up` - This will automatically download and run WordPress in a Docker container. You can access it at http://localhost:8889 (Username: admin, Password: password).

To install the PlayWright browser locally you can run:
`npx playwright install chromium`

Run E2E testing:

Expand All @@ -152,10 +155,6 @@ To remove the Docker container and images (this will **delete everything** in th

:warning: Currently, the E2E testing on GitHub Actions is only run automatically after opening a PR with `release/*` branches or pushing changes to `release/*` branches. To run it manually, please visit [here](../../actions/workflows/e2e-tests.yml) and follow [this instruction](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow?tool=webui) to do so.

### Linux Troubleshooting

If you encounter problems starting your `test:e2e`, like `No usable sandbox!` or `UnhandledPromiseRejectionWarning: Error: Page crashed!`, you may try disabling the Chromium sandbox by adding `--no-sandbox` to `launch.args` in [`/tests/e2e/config/jest-puppeteer.config.js#L7`](https://github.com/woocommerce/google-listings-and-ads/blob/develop/tests/e2e/config/jest-puppeteer.config.js#L7).

## Docs

- [Usage Tracking](./src/Tracking/README.md)
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ module.exports = {
timeFormat: 'g:i a',
},
},
timers: 'fake',
};