-
Notifications
You must be signed in to change notification settings - Fork 952
Add wp-env support for running integration tests across all Yoast plugins #23107
Copy link
Copy link
Open
Description
Problem
Running WordPress integration tests locally requires a complex manual setup as documented on developer.yoast.com:
- Clone
WordPress/wordpress-developseparately - Build and start the environment (
npm install && npm run build:dev && npm run env:start && npm run env:install) - Expose MySQL via network aliases requiring
sudo(sudo ifconfig lo:0 10.254.254.254on Linux,sudo ifconfig lo0 alias 10.254.254.254on macOS) - Configure
WP_DEVELOP_DIRandWP_PLUGIN_DIRenvironment variables - Run
composer test-wp
This manual process:
- Blocks AI agents from running integration tests autonomously (they can't execute
sudoor configure network interfaces) - Slows down onboarding for new developers
- Requires platform-specific steps (different
ifconfigsyntax per OS)
Solution
Use @wordpress/env (wp-env) to provide a self-contained Docker-based test environment that can be started and used with a single command: composer test-wp-env.
The wp-env setup handles everything automatically:
- Starts WordPress + MySQL in Docker containers
- Mounts the plugin directory automatically
- Provides the WordPress PHPUnit test framework at
/wordpress-phpunit/ - Supports
--php,--wp,--multisite,--coverageflags - Patches
wp-tests-config.phpat runtime to fix three wp-env defaults that differ from the standardinstall-wp-tests.shsetup (WP_HOME/WP_SITEURL, WP_TESTS_DOMAIN, WP_ENVIRONMENT_TYPE)
Plugins to update
All Yoast plugins with WordPress integration tests need this setup:
- wordpress-seo (Free) — Add wp-env support for running integration tests #23106
- wordpress-seo-premium — https://github.com/Yoast/wordpress-seo-premium/pull/4937
- wpseo-news — https://github.com/Yoast/wpseo-news/pull/958
- wpseo-video — https://github.com/Yoast/wpseo-video/pull/1193
- wpseo-woocommerce — https://github.com/Yoast/wpseo-woocommerce/pull/1142
- duplicate-post — feat: add wp-env support for running integration tests duplicate-post#483
Additional considerations
- Windows support: The current implementation uses a bash script. Developers on Windows without WSL cannot run it natively. A follow-up could convert the script to PHP for cross-platform support.
- Node.js version:
@wordpress/envrequires Node >= 20.10.0. The.nvmrcneeds to be bumped from 18 to 20 in each plugin. - Documentation: Update developer.yoast.com setup guide to include the wp-env alternative.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels