Skip to content

feat: add wp-env support for running integration tests#483

Open
enricobattocchi wants to merge 1 commit intotrunkfrom
feat/wp-env-integration-tests
Open

feat: add wp-env support for running integration tests#483
enricobattocchi wants to merge 1 commit intotrunkfrom
feat/wp-env-integration-tests

Conversation

@enricobattocchi
Copy link
Copy Markdown
Member

Context

The current integration test setup requires a local MySQL server and a manual WordPress test installation (via install-wp-tests.sh). This makes it harder to run tests locally, especially for new contributors. The wordpress-seo plugin already adopted wp-env for this purpose — this PR ports the same approach to Duplicate Post.

Summary

This PR can be summarized in the following changelog entry:

  • Non-user-facing: Adds wp-env support for running WordPress integration tests via Docker.

Relevant technical choices:

  • Ported the run-wp-env-tests.sh convenience script from wordpress-seo, adapted for Duplicate Post (different plugin path, removed Yoast SEO-specific patches).
  • Set "testsEnvironment": false in .wp-env.json to avoid the deprecated env.tests configuration.
  • Added @wordpress/env as a devDependency and new composer commands: test-wp-env, coverage-wp-env, wp-env:stop.
  • The .nvmrc already specifies Node 20, which is compatible with wp-env.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  1. Ensure Docker is running.
  2. Run yarn install to install dependencies.
  3. Run composer install if not already done.
  4. Run composer test-wp-env — all 109 integration tests should pass.
  5. Run composer test-wp-env -- --filter=Post_Duplicator to verify running a specific test works.
  6. Run composer wp-env:stop to verify the environment stops cleanly.
  7. Optionally test composer test-wp-env -- --multisite for multisite mode.
  8. Optionally test composer test-wp-env -- --php=8.3 to override the PHP version.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • Development tooling only — no production code is changed.

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities
  • I have added unittests to verify the code works as intended

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label and noted the work hours.

Fixes #

Add wp-env configuration and a convenience shell script to run
WordPress integration tests inside Docker containers, removing the
need for a local MySQL/WordPress setup. Supports --multisite,
--coverage, --php and --wp version flags.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant