Pascal Birchler b0030c47e1 Build/Test Tools: add new end-to-end tests for edge cases such as maintenance mode.
Sometimes errors only occur in unusual code paths such as the maintenance mode or installation screens. Due to lack of tests for these scenarios in core, such errors are usually only noticed very late. This change adds new end-to-end (e2e) tests to prevent regressions in the following areas:

- Maintenance mode (presence of a `.maintenance` file)
- Fatal error handler (simulated with an mu-plugin that causes an error)
- Installation screen (verifying full installation flow & that there are no database errors)

Thanks to these tests, an issue was already found and addressed in the default `wp_die` handler, as `wp_robots_noindex_embeds` and `wp_robots_noindex_search` used to cause PHP warnings due to `$wp_query` not existing.

In the future, these tests can be extended to also test scenarios like localized error pages via `wp_load_translations_early()`.

Fixes .

git-svn-id: https://develop.svn.wordpress.org/trunk@58430 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-18 08:18:51 +00:00
..

E2E Tests

End-To-End (E2E) tests for WordPress.

Running the tests

The e2e tests require a production-like environment to run. By default, they will assume an environment is available at http://localhost:8889, with username admin and password password.

If you don't already have an environment ready, you can set one up by following these instructions.

Then you can launch the tests by running:

npm run test:e2e

which will run the test suite using a headless browser.

If your environment has a different url, username or password to the default, you can provide the base URL, username and password like this:

WP_BASE_URL=http://mycustomurl WP_USERNAME=username WP_PASSWORD=password npm run test:e2e

DO NOT run these tests in an actual production environment, as they will delete all your content.

For debugging purposes, you might want to follow the test visually. You can do so by running the tests in an interactive mode:

npm run test:e2e -- --ui

UI Mode let's you explore, run and debug tests with a time travel experience complete with watch mode. All test files are loaded into the testing sidebar where you can expand each file and describe block to individually run, view, watch and debug each test.

You can also run a single test file separately:

npm run test:e2e tests/e2e/specs/hello.test.js

Documentation