For some reason I always get this error when I try to run Pest tests in PhpStorm:
/usr/local/bin/php ~/project/vendor/pestphp/pest/bin/pest --teamcity --configuration ~/project/phpunit.xml ~/project/tests/Feature/SampleTest.php
Pest 1.20.0
Pest\Exceptions\ShouldNotHappen
This should not happen - please create an new issue here: https://github.com/pestphp/pest.
- Issue: Test file not found.
- PHP version: 8.1.0RC5-dev
- Operating system: Darwin
at pestphp/pest/src/Exceptions/ShouldNotHappen.php:38
34▕ * Creates a new instance of should not happen without a specific exception.
35▕ */
36▕ public static function fromMessage(string $message): ShouldNotHappen
37▕ {
➜ 38▕ return new ShouldNotHappen(new Exception($message));
39▕ }
40▕ }
41▕
+3 vendor frames
4 tests/Feature/SampleTest.php:38
it("it validates the form", Object(Closure))
This exact command /usr/local/bin/php ~/project/vendor/pestphp/pest/bin/pest --teamcity --configuration ~/project/phpunit.xml ~/project/tests/Feature/SampleTest.php
works perfectly when I run it directly from the Terminal, but never from PhpStorm.
Here's my Pest plugin configuration in PhpStorm:
PS: all ~/ paths are replacing real absolute paths. PPS: this plugin did work last year, right after the first public release of PestPHP. I wonder what went wrong (on my side, I guess).
Okay, I found the reason behind this issue.
I added the parent folder as a project which holds two different repositories: "api" and "web".
As soon as I only opened the "api" project, the tests were able to run. In order to have both projects in one window I attached the other ("web") project to the already open folder.