[Bug]: `--fail-on-incomplete` doesn't cause exit code to be non-zero when snapshots are missing
What Happened
--fail-on-incomplete doesn't cause exit code to be non-zero when snapshots are missing.
How to Reproduce
- Create a test with
toMatchSnapshottest('example', function () { expect('foo')->toMatchSnapshot(); }); - Delete the snapshots folder (if exists)
$ rm -rf tests/.pest/snapshots - 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 - 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
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 😅
@tangrufus my PR was closed mentioning that it is fixed in 4.x 🥳
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 !