Migrate wp-env test config off deprecated env/testsPort to --config file#1558
Conversation
wp-env v11 deprecated the single-file env/testsPort/testsEnvironment model and only silences the warning with "testsEnvironment": false (which removes the auto-created tests env and its tests-cli container). The new model gives each --config file its own isolated Docker stack/port, and the WordPress PHPUnit scaffold (WP_TESTS_DIR) now ships in every container. - .wp-env.json: dev only (port 2622, testsEnvironment:false); drop testsPort + env.tests. - .wp-env-tests.json (new): isolated tests env (port 2623) with the cmb2-test-fields.php fixture mapping; used by Playwright + phptests. - package.json: phptests runs phpunit in the tests env's plain cli container (no more tests-cli); add env:tests:start/stop/clean. - playwright.config.js: local webServer starts env:tests:start. - .github/workflows/test.yml: start with --config .wp-env-tests.json. - CLAUDE.md + tests/playwright/README.md: document the two-config model. Verified locally: no deprecation warning on either env; phpunit 214 tests pass via cli container; Playwright plugin + metabox specs pass against the new tests env. Closes cmb2-do9 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the local development and testing setup to use separate configuration files (.wp-env.json and .wp-env-tests.json) in accordance with wp-env v11 deprecations, isolating the test environment on port 2623. The package scripts, Playwright configuration, and documentation have been updated to support this new workflow. Feedback suggests enabling WP_DEBUG in the test environment configuration to catch PHP warnings and notices, and modifying the Playwright web server command to prevent potential execution failures in CI environments.
…t command - .wp-env-tests.json: set WP_DEBUG=true so PHP notices/warnings/deprecations (PHP 7.4-8.x compat) are logged during test runs, with WP_DEBUG_DISPLAY=false so the output is not rendered into pages — keeping Playwright visual regression snapshots stable. Verified: with WP_DEBUG_DISPLAY off the visual suite behaves identically to WP_DEBUG=false. - playwright.config.js: drop the CI `echo` webServer branch (dead code, since CI sets SKIP_WP_SERVER=1 → webServer is undefined) and always use `npm run env:tests:start`, which is idempotent and removes the process-exits-early footgun if SKIP_WP_SERVER is ever omitted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR migrates the wp-env test setup to the wp-env v11-compatible two-config model, keeping the dev environment separate from the isolated test environment used by PHPUnit and Playwright.
Changes:
- Splits dev and test wp-env configuration into
.wp-env.jsonand.wp-env-tests.json. - Updates npm scripts, Playwright config, and CI to start/use the tests config via
--config. - Documents the new test environment workflow and the move from
tests-clitocli.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
.wp-env.json |
Limits the default wp-env config to the dev environment. |
.wp-env-tests.json |
Adds the isolated test wp-env config with port, plugin, constants, and fixture mapping. |
package.json |
Adds test-environment scripts and updates PHPUnit execution. |
playwright.config.js |
Starts the isolated tests environment for local Playwright runs. |
.github/workflows/test.yml |
Starts the tests wp-env config in CI. |
CLAUDE.md |
Documents the two-config wp-env model. |
tests/playwright/README.md |
Updates local Playwright environment instructions. |
…sentence "For local development with wp-env." was a fragment; join it to the next clause with a comma so the local Playwright instructions read cleanly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Why
wp-env v11 deprecated the single-file
env/testsPort/testsEnvironmentmodel. The warning only goes away with"testsEnvironment": false, which removes the auto-createdtestsenvironment (and itstests-clicontainer). The forward path is a separate config file passed via--config, which gets its own isolated Docker stack/port. The WordPress PHPUnit scaffold (WP_TESTS_DIR) now ships in every container, so phpunit runs in a plainclicontainer — there is no longer atests-cli.Discovered while pinning ports in cmb2-g75. Closes cmb2-do9.
Changes
.wp-env.json→ dev only: port 2622,testsEnvironment: false. DroppedtestsPort+env.tests..wp-env-tests.json(new) → isolated tests env: port 2623, thecmb2-test-fields.phpfixture mapping,WP_DEBUG/SCRIPT_DEBUG: false.package.json→phptestsruns phpunit in the tests env'sclicontainer via--config; addedenv:tests:start/:stop/:clean.playwright.config.js→ local webServer startsenv:tests:start..github/workflows/test.yml→wp-env start --config .wp-env-tests.json.CLAUDE.md+tests/playwright/README.md→ documented the two-config model and thetests-cli→clichange.Verification (local, Docker)
npm run phptestsend-to-end: 214 tests, 701 assertions, OK.plugin.spec(4✓) andmetabox.spec(4✓) pass against the new tests env — confirms auth + fixture mapping survived the move.Notes
.wp-env-tests.jsonwork-dir hash (cold cache) — functionally fine, just slightly slower once.tests/cypress/files still referencetests-cli, but Cypress was retired — left as-is (dead code, out of scope).🤖 Generated with Claude Code