To run the E2E tests you will to install playwright using the following command:
npx playwright install
Note
You also need to use Node.js 18 or later, along with Docker and Docker.
Create the testing instance using the following command:
npm run wp-env start
This will create a WordPress instance. The port is 8889
and the user is admin
and the password is password
(the same values used by wp-env
testing instance).
Note
Read more about wp-env
here
For the headless mode, use the following command:
npm run test:e2e:playwright
For debug mode (which will open the browser along with Playwright Editor), use the following command:
npm run test:e2e:playwright:debug
Note
When writing a test, using the debug mode is recommended since it will allow you to see the browser and the test in action.
Resources:
- Playwright Documentation
- https://github.com/WordPress/gutenberg/blob/trunk/packages/e2e-test-utils-playwright/README.md
- https://developer.wordpress.org/block-editor/contributors/code/testing-overview/
To see more examples of E2E tests, check the Gutenberg repository: https://github.com/WordPress/gutenberg/tree/trunk/test/e2e
Note
If you are out of ideas on who to test, check the Gutenberg repository. It has a lot of examples of E2E tests that you can use as a reference.