-
Notifications
You must be signed in to change notification settings - Fork 805
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 #17814
Conversation
E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-17814 This is an automated check which relies on |
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.
Looks solid!
I left a few comments, and questions for changes that I can not understand.
tests/e2e/lib/setup-env.js
Outdated
let filePath; | ||
|
||
try { | ||
filePath = await takeScreenshot( currentBlock, name ); |
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.
Why do we need to take screenshots on failures locally?
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.
Why not? The reports with screenshots are very helpful in debugging issues.
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 guess it depends on how one would debug issues locally.
I prefer running E2E tests in headful mode with E2E_DEBUG=true
, which will stop the execution on failure, timeout, or exception, which is quite handy, so I can poke around and see what's happened.
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.
We are getting there! Would you mind taking a look at the E2E GH actions? They are failing with this TypeError: TypeError [ERR_INVALID_OPT_VALUE_ENCODING]: The value "logs/e2e-slack.log" is invalid for option "encoding"
tests/e2e/lib/setup-env.js
Outdated
if ( captureVideo ) { | ||
video = await saveVideo( | ||
page, | ||
path.resolve( config.get( 'testOutputDir' ), `video/video_${ new Date().getTime() }.mp4` ) |
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.
Is there a way to somehow link these videos to actual tests? I guess at this moment we don't know which specific test would run, but maybe in afterAll
hook we can rename the file?
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 moved the video capture logic into jasmine reporter listeners, giving access to test names. All videos now meaningful names. I know that jasmine will be dropped at some point, but a new runner should provide the same functionality and we can move the video logic in there.
tests/e2e/lib/setup-env.js
Outdated
const userAgent = await page.evaluate( () => navigator.userAgent ); | ||
logger.info( `User agent: ${ userAgent }` ); | ||
|
||
if ( captureVideo ) { |
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.
To be honest, I don't think this belongs to setupBrowser
. Also, since setupBrowser
is being called in beforeAll
and afterEach
we end up with 28 video files.
I guess it does not directly related to the goal of this PR, but I'll still share my thoughts.
It would be nice to have a video per test, and save it only if test is failing (I don't think we successful runs as much)
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 totally agree. But also, calling setupBrowser
in an afterEach
doesn't sound right to me either.
I guess I already mentioned, the entire setup could do some refactoring, maybe combined with a test runner migration. Currently my feeling is that everything is all over the place. Probably a custom environment would make most sense.
And true, not in the scope of this PR. But I will find a better place for video handling.
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.
Solved now, see #17814 (comment)
By also moving the logic of setting user agent from setupBrowser
the method remained empty, so I removed it.
I would like to note that in this PR, tests took about 2 minutes more to complete. |
Other runs took less, but still an average of 1 minute longer: I wondered if video capture has any significant effect, but it seems it doesn't. I'll take a quick look, but I think a more in depth analysis is required here and maybe optimisations in tests/setup/teardown code would be required. |
tests/e2e/lib/page-helper.js
Outdated
/** | ||
* Internal dependencies | ||
*/ | ||
import logger from './logger'; | ||
import { execSyncShellCommand } from './utils-helper'; | ||
|
||
/** |
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.
One of the reasons for these custom methods was to log every test action, to see what's going on. You mentioned that there is DEBUG=pw:api
env variable that we can use to achieve similar behavior. I'd like to hear your take on this, and maybe how would you approach it.
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 those methods were logging actions, if/where they were used. Playwright's auto-wait introduces the risk of not using those methods in a consistent way.
I also believe the logged information was only useful in case you're debugging, otherwise it's polluting the log. In case of failure, the failing action is logged anyway, with element locator if relevant. With Playwright, if you want to debug, running the tests with DEBUG=pw:api
will give the same result, but with more information and in a consistent way.
I've added the option under the E2E_DEBUG, so there's a single debug toggle. So now, E2E_DEBUG=true
will also trigger pw:api
logging.
Also, I'm not very familiar with Winston, but I'm assuming there as way to filter pw:api log entries. Then have a different debug file with only those entries. Or have a file with everything and a clean one without those entries. There are more ideas.
Co-authored-by: Brandon Kraft <[email protected]> Co-authored-by: Brad Jorsch <[email protected]> Co-authored-by: Yaroslav Kukharuk <[email protected]>
Co-authored-by: Brandon Kraft <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Brandon Kraft <[email protected]>
Bumps [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) from 2.2.2 to 2.2.4. - [Release notes](https://github.com/TooTallNate/node-https-proxy-agent/releases) - [Commits](TooTallNate/proxy-agents@2.2.2...2.2.4) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Lazy Images: do not include js linting config in production * Update packages/lazy-images/.gitattributes Co-authored-by: Brad Jorsch <[email protected]> * Fix wrong auto-merge * Fix spacing Co-authored-by: Brad Jorsch <[email protected]>
* store: add media-source store (init) * extensions: add store * store: improve registering media source * store: add readme for media source * audio-player: move out global var from int. dep. * store/media-source: Add unit tests * store/media-source: test: Add jest-environment jsdom comment * Update extensions/store/media-source/storeDefinition.js Co-authored-by: Matthew Reishus <[email protected]> * Revert "store/media-source: test: Add jest-environment jsdom comment" This reverts commit b0dabf8. * media-source: add eslint.js file * media-source: simplify file structure. jsdoc. * store: move eslint rules to extensions folder * media-source-state: update to new structure * media-source: minor doc changes Co-authored-by: Matthew Reishus <[email protected]>
From February 2021, in order to provide feedback on pull requests, Code Scanning workflows must be configured with both `push` and `pull_request` triggers. This is because Code Scanning compares the results from a pull request against the results for the base branch to tell you only what has changed between the two. Early in the beta period we supported displaying results on pull requests for workflows with only `push` triggers, but have discontinued support as this proved to be less robust. See https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#scanning-pull-requests for more information on how best to configure your Code Scanning workflows.
- Removed empty setupBrowser
…nto test/e2e-playwright-migration # Conflicts: # .github/workflows/e2e-tests.yml # .gitignore # package.json # projects/plugins/jetpack/tests/e2e/config/default.json # projects/plugins/jetpack/tests/e2e/jest-playwright.config.js # tests/e2e/.eslintrc.js # tests/e2e/.gitignore # tests/e2e/README.md # tests/e2e/config/encrypted.enc # tests/e2e/jest.config.js # tests/e2e/lib/blocks/eventbrite.js # tests/e2e/lib/blocks/mailchimp.js # tests/e2e/lib/blocks/pinterest.js # tests/e2e/lib/blocks/simple-payments.js # tests/e2e/lib/blocks/word-ads.js # tests/e2e/lib/flows/jetpack-connect.js # tests/e2e/lib/global-teardown.js # tests/e2e/lib/logger.js # tests/e2e/lib/page-helper.js # tests/e2e/lib/pages/jetpack-connect/site-topic.js # tests/e2e/lib/pages/jetpack-connect/site-type.js # tests/e2e/lib/pages/jetpack-connect/user-type.js # tests/e2e/lib/pages/page.js # tests/e2e/lib/pages/postFrontend.js # tests/e2e/lib/pages/wp-admin/block-editor.js # tests/e2e/lib/pages/wp-admin/dashboard.js # tests/e2e/lib/pages/wp-admin/in-place-authorize.js # tests/e2e/lib/pages/wp-admin/in-place-plans.js # tests/e2e/lib/pages/wp-admin/jetpack.js # tests/e2e/lib/pages/wp-admin/login.js # tests/e2e/lib/pages/wp-admin/plugins.js # tests/e2e/lib/pages/wp-admin/sidebar.js # tests/e2e/lib/pages/wpcom/authorize.js # tests/e2e/lib/pages/wpcom/checkout.js # tests/e2e/lib/pages/wpcom/connections.js # tests/e2e/lib/pages/wpcom/login.js # tests/e2e/lib/pages/wpcom/my-plan.js # tests/e2e/lib/pages/wpcom/pick-a-plan.js # tests/e2e/lib/pages/wpcom/plans.js # tests/e2e/lib/pages/wpcom/thank-you.js # tests/e2e/lib/plan-helper.js # tests/e2e/lib/reporters/screenshot.js # tests/e2e/lib/setup-env.js # tests/e2e/lib/tunnel-manager.js # tests/e2e/lib/utils-helper.js # tests/e2e/specs/free-blocks.test.js # tests/e2e/specs/plugin-updater.test.js # tests/e2e/specs/pro-blocks.test.js # yarn.lock
Closed in favor of 18762
This is a POC for a migration of E2E tests from Puppeteer to Playwright.
This PR is replacing 17791, which was opened from a forked repo.
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 thoughDoes 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