If a Laravel project runs vendor/bin/phpunit but does not have Pest installed, one test file written in Pest style can break the whole run. We hit this in one of our own projects: a test file used it() and the suite failed before any test ran.
The symptom
PHPUnit stops with a fatal error that it() is an undefined function, or the same for test() or expect(). It names one file. Running a single test with --filter does not get around it.
Why one file breaks everything
PHPUnit loads every test file before it filters tests. A file written as
it('replays a batch', function () {
expect($result)->toBeTrue();
});
runs it() as soon as it is included. Without Pest, no such function exists, so PHP aborts during discovery. Your filter never gets a chance to apply.
Why fixing the reported file is not enough
PHPUnit reports the first failure only. After you fix that file, the next Pest-style file fails the same way. In our case the reported file was one of eight. The project required phpunit/phpunit and did not install or bootstrap Pest, yet eight files used Pest globals.
Audit the whole folder first
Search for the globals before you fix anything:
grep -rlE '^\s*(it|test|expect|describe|beforeEach|uses)\(' tests/
Review the list. Every file in it either needs converting, or the project needs Pest.
Choose one runner
- Stay on PHPUnit. Convert each file to a class that extends your base
TestCase.it('does x', fn)becomes apublic function test_does_x(): void.expect($a)->toBe($b)becomes$this->assertSame($b, $a). Pest datasets become#[DataProvider]methods. Keep every assertion, dataset and exception check, and keep the Laravel application bootstrapping. - Move to Pest. Install
pestphp/pestand the Laravel plugin and runvendor/bin/pest. Pest runs PHPUnit-style classes too, so you can migrate gradually.
The mix of both is what causes the failure. Decide which runner your CI uses and make the folder match.
Check the result
Run vendor/bin/phpunit over the full suite, not only the converted file, and compare the assertion count before and after if you have it. Keeping the count equal is a quick check that the conversion did not drop tests.