Skip to content

Migrate wp-env test config off deprecated env/testsPort to --config file#1558

Merged
jtsternberg merged 3 commits into
developfrom
chore/cmb2-do9-wp-env-config
May 31, 2026
Merged

Migrate wp-env test config off deprecated env/testsPort to --config file#1558
jtsternberg merged 3 commits into
developfrom
chore/cmb2-do9-wp-env-config

Conversation

@jtsternberg

Copy link
Copy Markdown
Member

Why

wp-env v11 deprecated the single-file env / testsPort / testsEnvironment model. The warning only goes away with "testsEnvironment": false, which removes the auto-created tests environment (and its tests-cli container). 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 plain cli container — there is no longer a tests-cli.

Discovered while pinning ports in cmb2-g75. Closes cmb2-do9.

Changes

  • .wp-env.json → dev only: port 2622, testsEnvironment: false. Dropped testsPort + env.tests.
  • .wp-env-tests.json (new) → isolated tests env: port 2623, the cmb2-test-fields.php fixture mapping, WP_DEBUG/SCRIPT_DEBUG: false.
  • package.jsonphptests runs phpunit in the tests env's cli container via --config; added env:tests:start / :stop / :clean.
  • playwright.config.js → local webServer starts env:tests:start.
  • .github/workflows/test.ymlwp-env start --config .wp-env-tests.json.
  • CLAUDE.md + tests/playwright/README.md → documented the two-config model and the tests-clicli change.

Verification (local, Docker)

  • Both envs start with no deprecation warning (dev 2622, tests 2623 → HTTP 200).
  • npm run phptests end-to-end: 214 tests, 701 assertions, OK.
  • Playwright plugin.spec (4✓) and metabox.spec (4✓) pass against the new tests env — confirms auth + fixture mapping survived the move.

Notes

  • First CI Playwright run will do a fresh WP download for the new .wp-env-tests.json work-dir hash (cold cache) — functionally fine, just slightly slower once.
  • Legacy tests/cypress/ files still reference tests-cli, but Cypress was retired — left as-is (dead code, out of scope).

🤖 Generated with Claude Code

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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .wp-env-tests.json
Comment thread playwright.config.js Outdated
…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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json and .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-cli to cli.

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.

Comment thread tests/playwright/README.md Outdated
…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>
@jtsternberg jtsternberg merged commit 31a95d2 into develop May 31, 2026
18 checks passed
@jtsternberg jtsternberg deleted the chore/cmb2-do9-wp-env-config branch May 31, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants