pest icon indicating copy to clipboard operation
pest copied to clipboard

[Bug]: suppressed errors still pop up as errors

Open 2colours opened this issue 9 months ago • 0 comments

What Happened

In the following snippet

    it('does something not nice at all', function () {
        expect(@[1,2,3][4])->toBe(null);
    });

I would expect the test to be successful since the right value is produced and even though the over-indexing would raise a warning, it's explicitly silenced using the @ operator. (Of course this is a golfed version; in practice, silencing missing key warnings where the key really can be missing can make perfect sense.)

Confer the docs of PHPUnit:

By default, the error handler registered by PHPUnit’s test runner respects the suppression operator (@). This means that issues triggered using @trigger_error(), for example, will not be reported by the default progress and result printers.

How to Reproduce

Using the default setup of Pest, run the example test given.

Sample Repository

No response

Pest Version

3.8.2

PHP Version

8.4.6

Operation System

Linux

Notes

(Tested on WSL running Ubuntu 24.04.1 LTS - I don't think it makes a lot of difference.)

2colours avatar Apr 19 '25 22:04 2colours