question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update E2E to fail on PHP errors/warnings/notices

See original GitHub issue

Feature Description

Our E2E tests are intentionally set up to fail if a console log is made unexpectedly. The same has not been true however for PHP log entries which are just as valuable to catch.

Luckily, setting up debug logging in WP has been supported for a very long time, we only need to configure our E2E environment to do this and then to listen for changes during tests. This sounds somewhat complicated, but it isn’t.

Docker already exposes container logs via its API (along with everything else that can be done via the command line) which can be consumed as a stream in our Node E2E Jest process. Then we only need to add a dedicated container for tailing the WP debug.log file which will be essentially piped to the log for that container, so we can subscribe specifically to this one log. Then we just need to handle the stream and data from it in Jest as part of normal setup/teardown.

See my POC branch here https://github.com/google/site-kit-wp/compare/poc/e2e-docker-logs


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • PHP errors of any kind (fatal/warning/notice/deprecation) raised during an E2E test should cause that test to fail similar to an unexpected console log on the client
    • The only difference here is that PHP errors should never be expected, so we don’t need to add support for allowing them as we have in JS
  • The specific errors that were raised should be exposed in the test failure
  • Errors raised in one test should not cause other tests to fail

Implementation Brief

Test Coverage

  • No additional tests to be added, the changes here will expand the coverage to include observation of the debug

Visual Regression Changes

  • N/A

QA Brief

  • Create a new Pull Request in the “Ready for review” state so the E2E tests run in CI.
  • Make a change to one of the PHP files used in E2E that causes a PHP error to be raised (e.g. trigger_error( 'Hello debug.log!' );)
  • Ensure that E2E tests that cause errors to be raised fail accordingly and others that do not raise errors in the same run do not fail

Changelog entry

  • N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
FlicHolliscommented, Jun 1, 2022

Hi @aaemnnosttv just adding your comment here that this may be blocked until we raise the minimum version of WP that we require. I will remove this from the sprint until we have a further update.

1reaction
FlicHolliscommented, Jan 31, 2022

Hi @aaemnnosttv Moving this back to EB as this has not been added to Sprint 68

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Display All PHP Errors: For Basic and Advanced Use
The parameter for the error reporting function will be “E_WARNING | E_NOTICE” to display warnings and notifications. As bitwise operators, the  ...
Read more >
How to Turn on PHP Error Reporting? Display all Errors and ...
In this tutorial, learn how to enable PHP Error Reporting to display all warnings. We also dive into creating an error log file...
Read more >
error_reporting - Manual - PHP
If you are using the PHP development server, run from the command line via `php -S servername:port`, every single error/notice/warning will be reported...
Read more >
Display All PHP Errors: Basic & Advanced Usage
To show warnings and notices, the parameter for the error reporting function will be “E_WARNING | E_NOTICE”. The error_reporting function ...
Read more >
PHP Errors On (.user.ini file error reporting, display PHP errors)
PHP is a pain to debug because syntax errors can cause entire page to die and you might not find out until you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found