Repository navigation
feat(test): fail Playwright runs on PHP errors in debug.log - #35
Open
Hug0-Drelon wants to merge 1 commit into
Open
Hug0-Drelon wants to merge 1 commit into
Hug0-Drelon wants to merge 1 commit into
Conversation
Keep REST JSON valid with WP_DEBUG_DISPLAY off, and surface Notice/Warning/Deprecated/Fatal lines from wp-content/debug.log on the exported test fixtures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Fail Playwright tests when WordPress writes a PHP Notice, Warning, Deprecated, Parse error, or Fatal error to
wp-content/debug.log, without printing those errors into REST or HTML bodies.Why?
Consumers (polylang-wc, Polylang Pro) use
requestUtils.rest()from@wordpress/e2e-test-utils-playwright, whichJSON.parse()s the body. WithWP_DEBUG_DISPLAYtrue, a notice becomesSyntaxError: Unexpected token 'N'and hides the real PHP message.@wordpress/e2e-test-utils-playwrightdoes not inspect PHP notices ordebug.log(only browser console warnings). This package is the right place to fail on log lines while keeping REST parseable.How?
debug.logfromnpx wp-env [--config=…] status --jsonusing the consumerwpCliCommand/WP_ENV_CLI_COMMAND(tests-cli→tests-WordPress, otherwiseWordPress).globalSetuptruncates or skips existing log output, wrapsrequestUtils.rest(), then fails if matching PHP lines were appended during setup REST work.testauto fixtures: worker ignores leftover lines; each test fails on new matching lines before and after (coversbeforeAll); worker teardown coversafterAll.[date] PHP Notice|Warning|Deprecated|Parse error|Fatal error:. Ignore othererror_log()noise.SyntaxError, throw: REST<path>returned non-JSON; a PHP notice was likely printed into the response; see debug.log. Then the original message.Consumers should set
WP_DEBUG/WP_DEBUG_LOG/WP_DEBUG_DISPLAY: falsein the committed wp-env config CI actually starts, importtest/expectfrom this package, and bump the package (polylang-wc first).Test plan
npm run lint:jsandnpm run buildpasstestandexpect(node -esmoke in CI)WP_DEBUG_DISPLAYfalse,requestUtils.rest()still returns parseable JSON__()too early during a sample test fails with the PHP message fromdebug.logNotice:gets the wrapped non-JSON error message