pest icon indicating copy to clipboard operation
pest copied to clipboard

[Bug]: `--fail-on-incomplete` doesn't cause exit code to be non-zero when snapshots are missing

Open tangrufus opened this issue 1 year ago • 1 comments

What Happened

--fail-on-incomplete doesn't cause exit code to be non-zero when snapshots are missing.

How to Reproduce

  1. Create a test with toMatchSnapshot
    test('example', function () {
        expect('foo')->toMatchSnapshot();
    });
    
  2. Delete the snapshots folder (if exists)
    $ rm -rf tests/.pest/snapshots
    
  3. Run the tests
    $ ./vendor/bin/pest --fail-on-incomplete
    
       WARN  Tests\Feature\ExampleTest
      … example → Snapshot created at [tests/.pest/snapshots/Feature/ExampleTest/example.snap]                                                                                                                   0.01s
      ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       INCOMPLETE  Tests\Feature\ExampleTest > example
      Snapshot created at [tests/.pest/snapshots/Feature/ExampleTest/example.snap]
    
    
      Tests:    1 incomplete (0 assertions)
      Duration: 0.07s
    
  4. Check the exit code
    $ echo $?
    0
    

Sample Repository

https://github.com/tangrufus/pest-fail-on-incomplete

Pest Version

3.7.1

PHP Version

8.4.1

Operation System

macOS

Notes

In the above example, exit code is 0 even with all of the --fail-on-xxx flags.

$ ./vendor/bin/pest --fail-on-empty-test-suite --fail-on-warning --fail-on-risky --fail-on-deprecation --fail-on-phpunit-deprecation --fail-on-notice --fail-on-skipped --fail-on-incomplete

tangrufus avatar Dec 14 '24 00:12 tangrufus

We ran into the same issue surprisingly. I took the liberty to open a PR which proposes a fix and also includes a test case for this scenario. Hopefully this gets fixed soon 😅

mdeboer avatar Jan 29 '25 16:01 mdeboer

@tangrufus my PR was closed mentioning that it is fixed in 4.x 🥳

mdeboer avatar Aug 21 '25 09:08 mdeboer

Updated the sample repo to pest v4.0.4. I can confirm the exit code is non-zero as expected.

Thank you @mdeboer and @nunomaduro !

tangrufus avatar Aug 30 '25 17:08 tangrufus