-
Notifications
You must be signed in to change notification settings - Fork 802
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
E2E tests migration to Playwright #17791
E2E tests migration to Playwright #17791
Conversation
Functional pre-connection tests
- Grouped test output under a single output path
- Replaced 'networkidle0' and 'networkidle2' to 'networkidle - Replaced page.waitFor to page.waitForTimeout
- Save screenshots on failure
Scheduled Jetpack release: December 1, 2020. E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-17791 Thank you for the great PR description! When this PR is ready for review, please apply the |
@@ -61,5 +60,5 @@ module.exports = async function ( globalConfig ) { | |||
if ( process.env.CI ) { | |||
await processSlackLog(); | |||
} | |||
await teardown( globalConfig ); | |||
// await teardown( globalConfig ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick: Is this left here for anything in particular or missed in the cleanup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I actually forgot about this one, tests not complaining about it...
This was a call to a jest-puppeteer function and I was not sure what to replace it with, or now, even if it should be replaced at all.
Maybe @brbrr can help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it coming from jest-puppeteer
dependency that we using: https://github.com/smooth-code/jest-puppeteer#create-your-own-globalsetup-and-globalteardown
I guess we playwright counterpart does not need that (I'm not sure why tho)
tests/e2e/README.md
Outdated
@@ -53,10 +53,10 @@ You can run the e2e tests locally using this command: | |||
yarn test-e2e | |||
``` | |||
|
|||
Puppeteer runs headless by default (i.e. browser is not visible). However, sometimes it's useful to observe the browser while running tests. To see the browser window and the running tests you can pass `PUPPETEER_HEADLESS=false` as follows: | |||
Puppeteer runs headless by default (i.e. browser is not visible). However, sometimes it's useful to observe the browser while running tests. To see the browser window and the running tests you can pass `HEADLESS=false` as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are various references to Puppeteer still in the codebase and documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I left a lot of those in documentation blocks mostly. I pushed a change which replaced all except one for a piece o code that still needs to be evaluated if it should stay or go.
- Fixed locator for block editor.
], | ||
testRunner: 'jasmine2', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that this line was added basically to make tests work. But I wonder if this is an optimal solution.
From what I gathered, with playwright we have a few options for the test runner:
- jasmine2 (which is used in the current configuration)
- jest-circus
- playwright-test
Could you talk about the pros and cons of these as well? I know that circus
supports test re-run which I find really appealing. Also I wonder what benefits playwright-test
could provide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was a fix for an error thrown by jest-allure library. I don't really understand how come it wasn't failing before, with the Puppeteer suite of dependencies.
This was the only working solution I could find, based on this: zaqqaz/jest-allure#8
It's not ideal, it was the way to move forward while keeping the Allure reports.
I will look into other options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I got it. I thought the source of this error was our own usage of jasmine
. I guess we would need to move away from jest-allure
if we'd like to switch to circus
runner.
I wonder if there are alternatives to jest-allure
that would work with circus
runner.
Leaving a note that we closed this PR in favor of #17814 since this PR was created from a forked repo. |
This is a POC for a migration of E2E tests from Puppeteer to Playwright.
Changes proposed in this Pull Request:
Added dependencies:
Removed dependencies:
Configuration changes
jest-puppeteer.config.js
and addedjest-playwright.config.js
insteadJEST_PLAYWRIGHT_CONFIG
env variable injest.config.js
instead of CLI as it never changestestRunner: 'jasmine2'
injest.config.js
to fix"referenceError: jasmine is not defined"
default.js
andlocal-tests.js
are nowdefault.json
andlocal-tests.json
Code changes due to API differences
waitAndClick
andwaitAndType
with Playwright'spage.click
andpage.type
. RemovedwaitAndClick
andwaitAndType
as they are now obsoletepage.waitFor
withpage.waitForTimeout
page.setCookie()
withpage.browserContext().addCookies()
page.$x
withpage.$$(xpath='locator')
page.waitForXPath()
withpage.waitForSelector()
visible: true
andhidden: true
withstate: 'visible'
andstate: 'hidden'
page.setViewport()
withpage.setViewportSize()
networkidle0
andnetworkidle0
withnetworkidle
PUPPETEER_HEADLES
toHEADLESS
New features
CAPTURE_VIDEO
env variable. Run withCAPTURE_VIDEO=true yarn test-e2e
to capture video.Changes unrelated to migration
tests/e2e/output
. I was not able to move allure-results thoughLeft to do
DEBUG=pw:api
option. Possibly some methods in page-helper are also obsolete.Does this pull request change what data or activity we track or use?
No
Testing instructions:
All E2E tests need to pass
Proposed changelog entry for your changes:
no changelog entry needed