You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Guidelines: Add actions for Import, Export and Revisions of guidelines. ([76155](https://github.com/WordPress/gutenberg/pull/76155))
92
90
- Rename route and use the right `Notice` component. ([76427](https://github.com/WordPress/gutenberg/pull/76427))
93
91
94
92
#### Block Editor
@@ -275,11 +273,6 @@ high loading priority. ([76302](https://github.com/WordPress/gutenberg/pull/7630
275
273
- Sync some post list changes with Extensible Site Editor. ([76243](https://github.com/WordPress/gutenberg/pull/76243))
276
274
277
275
278
-
279
-
#### Content Guidelines
280
-
- Add UX for site, copy, image, and additional guidelines. ([75420](https://github.com/WordPress/gutenberg/pull/75420))
281
-
282
-
283
276
### Documentation
284
277
285
278
- Add Client-Side Navigation documentation to manifest and table of contents.
@@ -391,7 +384,6 @@ The following PRs were merged by first-time contributors:
391
384
392
385
393
386
- @apermo: Fix: Use add_filter() for get_block_type_variations hook. ([76297](https://github.com/WordPress/gutenberg/pull/76297))
394
-
- @aswasif007: Content Guidelines: Add UX for site, copy, image, and additional guidelines. ([75420](https://github.com/WordPress/gutenberg/pull/75420))
395
387
- @chubes4: API Fetch: Respect caller-provided Content-Type in httpV1 middleware. ([76285](https://github.com/WordPress/gutenberg/pull/76285))
396
388
- @iamchughmayank: Guidelines: Add actions for Import, Export and Revisions of guidelines. ([76155](https://github.com/WordPress/gutenberg/pull/76155))
397
389
- @kannan-ravi: Add word-break property to visually hidden styles to prevent screen reader issues. ([75539](https://github.com/WordPress/gutenberg/pull/75539))
@@ -407,6 +399,8 @@ The following contributors merged PRs in this release:
Copy file name to clipboardExpand all lines: docs/contributors/code/e2e/README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,9 @@ It's slow to set states manually before or after tests, especially when they're
79
79
80
80
### Avoid global variables
81
81
82
-
Previously in our Jest + Puppeteer E2E tests, `page` and `browser` are exposed as global variables. This makes it harder to work with when we have multiple pages/tabs in the same test, or if we want to run multiple tests in parallel. `@playwright/test` has the concept of [fixtures](https://playwright.dev/docs/test-fixtures) which allows us to inject `page`, `browser`, and other parameters into the tests.
82
+
In the previous E2E setup, `page` and `browser` were global variables, which made working with multiple pages or parallel tests harder.
83
+
84
+
`@playwright/test` uses fixtures to inject `page`, `browser`, and other parameters into tests.
Copy file name to clipboardExpand all lines: docs/contributors/code/testing-overview.md
+3-37Lines changed: 3 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -506,9 +506,7 @@ There is an ongoing effort to add integration tests to the native mobile project
506
506
507
507
## End-to-end testing
508
508
509
-
Most existing End-to-end tests currently use [Puppeteer](https://github.com/puppeteer/puppeteer) as a headless Chromium driver to run the tests in `packages/e2e-tests`, and are otherwise still run by a [Jest](https://jestjs.io/) test runner.
510
-
511
-
There's an ongoing [project](https://github.com/WordPress/gutenberg/issues/38851) to migrate them from Puppeteer to Playwright. **It's recommended to write newe2e tests in Playwright whenever possible**. The sections below mostly apply to the old Jest + Puppeteer framework. See the dedicated [guide](/docs/contributors/code/e2e/README.md) if you're writing tests with Playwright.
509
+
End-to-end tests use [Playwright](https://playwright.dev/) as the testing framework. See the dedicated [End-to-End Testing guide](/docs/contributors/code/e2e/README.md) for best practices and detailed instructions.
512
510
513
511
### Using wp-env
514
512
@@ -521,46 +519,14 @@ npm run test:e2e
521
519
or interactively
522
520
523
521
```bash
524
-
npm run test:e2e:watch
525
-
```
526
-
527
-
Sometimes it's useful to observe the browser while running tests. Then, use this command:
528
-
529
-
```bash
530
-
npm run test:e2e:watch -- --puppeteer-interactive
531
-
```
532
-
533
-
You can control the speed of execution with `--puppeteer-slowmo`:
534
-
535
-
```bash
536
-
npm run test:e2e:watch -- --puppeteer-interactive --puppeteer-slowmo=200
537
-
```
538
-
539
-
You can additionally have the devtools automatically open for interactive debugging in the browser:
540
-
541
-
```bash
542
-
npm run test:e2e:watch -- --puppeteer-devtools
543
-
```
544
-
545
-
### Using alternate environment
546
-
547
-
If using a different setup than `wp-env`, you first need to symlink the e2e test plugins to your test site, from your site's plugins directory run:
548
-
549
-
```bash
550
-
ln -s gutenberg/packages/e2e-tests/plugins/* .
551
-
```
552
-
553
-
Then to run the tests, specify the base URL, username, and passwords for your site. For example, if your test site is at `http://wp.test`, use:
554
-
555
-
```bash
556
-
WP_BASE_URL=http://wp.test npm run test:e2e -- --wordpress-username=admin --wordpress-password=password
522
+
npm run test:e2e -- --ui
557
523
```
558
524
559
525
### Scenario testing
560
526
561
527
If you find that end-to-end tests pass when run locally, but fail in GitHub Actions, you may be able to isolate a CPU- or network-bound race condition by simulating a slow CPU or network:
- What are the design decisions behind the Data Module?
10
-
-[Why is Puppeteer the tool of choice for end-to-end tests?](/docs/explanations/architecture/automated-testing.md)
10
+
-[Why is Playwright the tool of choice for end-to-end tests?](/docs/explanations/architecture/automated-testing.md)
11
11
-[What’s the difference between the different editor packages? What’s the purpose of each package?](/docs/explanations/architecture/modularity.md#whats-the-difference-between-the-different-editor-packages-whats-the-purpose-of-each-package)
12
12
-[Template and template parts flows](/docs/explanations/architecture/full-site-editing-templates.md)
## Why is Puppeteer the tool of choice for end-to-end tests?
3
+
## Why is Playwright the tool of choice for end-to-end tests?
4
4
5
-
There exists a rich ecosystem of tooling available for web-based end-to-end automated testing. Thus, it's a common question: "Why does Gutenberg use [Puppeteer](https://developers.google.com/web/tools/puppeteer/) instead of ([Cypress](https://cypress.io/), [Selenium](https://www.selenium.dev/), [Playwright](https://github.com/microsoft/playwright), etc)?". Given some historical unreliability of the build results associated with end-to-end tests, it's especially natural to weigh this question in considering whether our tools are providing more value than the effort required in maintaining them. While we should always be comfortable in reevaluating earlier decisions, there were and continue to be many reasons that Puppeteer is the best compromise of the options available for end-to-end testing.
5
+
There exists a rich ecosystem of tooling available for web-based end-to-end automated testing. Gutenberg uses [Playwright](https://playwright.dev/) as its end-to-end testing framework. The project previously used [Puppeteer](https://pptr.dev/) but has since fully migrated to Playwright. Here are the reasons Playwright was chosen:
6
6
7
-
These include:
7
+
-**Multi-browser support**. Playwright supports Chromium, Firefox, and WebKit out of the box, providing broader browser coverage compared to Puppeteer's Chrome-only approach.
8
+
-**Built-in test runner**. `@playwright/test` provides a powerful test runner with parallel execution, [fixtures](https://playwright.dev/docs/test-fixtures), and auto-waiting, reducing flakiness and improving developer experience.
9
+
-**Auto-waiting and web-first assertions**. Playwright automatically waits for elements to be actionable before performing actions, reducing the need for manual `waitFor*` calls while still surfacing legitimate performance issues that affect users.
10
+
-**Better debugging tools**. Playwright offers a [trace viewer](https://playwright.dev/docs/trace-viewer), [UI mode](https://playwright.dev/docs/test-ui-mode), and a built-in [inspector](https://playwright.dev/docs/debug#playwright-inspector) for step-by-step debugging.
11
+
-**Fixtures over global variables**. Playwright's fixture model injects `page`, `browser`, and other parameters into tests, making it easier to work with multiple pages or tabs and to run tests in parallel.
12
+
-**Page Object Model**. Playwright encourages the [Page Object Model](https://playwright.dev/docs/pom) pattern for reusable utility functions, improving test readability and maintainability.
8
13
9
-
-**Interoperability with existing testing framework**. Puppeteer is "just" a tool for controlling a Chrome browser, and makes no assumptions about how it's integrated into a testing environment. While this requires some additional effort in ensuring the test environment is available, it also allows for cohesion in how it integrates with an existing setup. Gutenberg is able to consistently use Jest for both unit testing and end-to-end testing. This is contrasted with other solutions like Cypress, which provide their own testing framework and assertion library as part of an all-in-one solution.
10
-
-**An expressive but predictable API**. Puppeteer strikes a nice balance between low-level access to browser behavior, while retaining an expressive API for issuing and awaiting responses to those commands using modern JavaScript [`async` and `await` syntax](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await). This is contrasted with other solutions, which either don't support or leverage native language async functionality, don't expose direct access to the browser, or leverage custom domain-specific language syntaxes for expressing browser commands and assertions. The fact that Puppeteer largely targets the Chrome browser is non-ideal in how it does not provide full browser coverage. On the other hand, the limited set of browser targets offers more consistent results and stronger guarantees about how code is evaluated in the browser environment.
11
-
-**Surfacing bugs, not obscuring them**. Many alternative solutions offer options to automatically await settled network requests or asynchronous appearance of elements on the page. While this can serve as a convenience in accounting for unpredictable delays, it can also unknowingly cause oversight of legitimate user-facing issues. For example, if an element will only appear on the page after some network request or computation has completed, it may be easy to overlook that these delays can cause unpredictable and frustrating behavior for users ([example](https://github.com/WordPress/gutenberg/pull/11287)). Given that developers often test on high-end hardware and stable network connections, consideration of resiliency on low-end hardware or spotty network availability is not always on the forefront of one's considerations. Puppeteer forces us to acknowledge these delays with explicit `waitFor*` expressions, putting us in much greater alignment with the real-world experience of an end-user.
12
-
-**Debugging**. It's important that in that case that a test fails, there should be straight-forward means to diagnose and resolve the issue. While its offerings are rather simplistic relative to the competition, Puppeteer does expose options to run tests as "headful" (with the browser visible) and with delayed actions. Combined with the fact that it interoperates well with native language / runtime features (e.g. debugger statements or breakpoints), this provides developers with sufficient debugging access.
13
-
14
-
For more context, refer to the following resources:
-[Testing: Experiment with Puppeteer for E2E testing](https://github.com/WordPress/gutenberg/pull/5618)
18
-
- In early iterations, the contributing team opted to use Cypress for end-to-end testing. This pull request outlines problems with the approach, and proposed the initial transition to Puppeteer.
19
-
-[JavaScript Chat Summary: January 28, 2020](https://make.wordpress.org/core/2020/02/04/javascript-chat-summary-january-28-2020/)
20
-
- Playwright is a new offering created by many of the original contributors to Puppeteer. It offers increased browser coverage and improved reliability of tests. While still early in development at the time of this writing, there has been some interest in evaluating it for future use as an end-to-end testing solution.
14
+
For more details on writing end-to-end tests, see the [End-to-End Testing guide](/docs/contributors/code/e2e/README.md).
0 commit comments