-
-
Save ace-of-aces/28502ff74ec8c875e00ea30451950150 to your computer and use it in GitHub Desktop.
| <?php | |
| use Pest\Concerns\Expectable; | |
| use Pest\PendingCalls\BeforeEachCall; | |
| use Pest\PendingCalls\TestCall; | |
| use Pest\Support\HigherOrderTapProxy; | |
| use Tests\TestCase; | |
| /** | |
| * Runs the given closure before all tests in the current file. | |
| * | |
| * @param-closure-this TestCase $closure | |
| */ | |
| function beforeAll(Closure $closure): void {} | |
| /** | |
| * Runs the given closure before each test in the current file. | |
| * | |
| * @param-closure-this TestCase $closure | |
| * | |
| * @return HigherOrderTapProxy<Expectable|TestCall|TestCase>|Expectable|TestCall|TestCase|mixed | |
| * | |
| * @disregard P1075 Not all paths return a value. | |
| */ | |
| function beforeEach(?Closure $closure = null): BeforeEachCall {} | |
| /** | |
| * Adds the given closure as a test. The first argument | |
| * is the test description; the second argument is | |
| * a closure that contains the test expectations. | |
| * | |
| * @param-closure-this TestCase $closure | |
| * | |
| * @return Expectable|TestCall|TestCase|mixed | |
| * | |
| * @disregard P1075 Not all paths return a value. | |
| */ | |
| function test(?string $description = null, ?Closure $closure = null): HigherOrderTapProxy|TestCall {} | |
| /** | |
| * Adds the given closure as a test. The first argument | |
| * is the test description; the second argument is | |
| * a closure that contains the test expectations. | |
| * | |
| * @param-closure-this TestCase $closure | |
| * | |
| * @return Expectable|TestCall|TestCase|mixed | |
| * | |
| * @disregard P1075 Not all paths return a value. | |
| */ | |
| function it(string $description, ?Closure $closure = null): TestCall {} |
@johnRivs No, that doesn't work unfortunately..
Why? Intelephense can't treat it with higher priority than Pest's source declarations, because they're both located in the vendor folder.
You'll have to put it somewhere else that's outside of vendor (e.g.
.vscode/laravel-ide/_pest-ide-helper.phpor just at the project root) and then have Intelephense re-index your project.I've explained this in more detail here: laravel/vs-code-extension#532 (comment)
Now it works. Thank you!
A quick heads up for everyone currently facing this issue:
While this Gist does the job for "patching" the basic test functions, it does not cover traits, custom expectations, etc (stuff that you configure through Pest.php).
So if you're looking for a more complete solution, I've created IntelliPest, a little package that auto-generates a helper file based on your custom Pest.php configuration.
Check it out: https://github.com/ace-of-aces/intellipest
@johnRivs No, that doesn't work unfortunately..
Why? Intelephense can't treat it with higher priority than Pest's source declarations, because they're both located in the vendor folder.
You'll have to put it somewhere else that's outside of vendor (e.g.
.vscode/laravel-ide/_pest-ide-helper.phpor just at the project root) and then have Intelephense re-index your project.I've explained this in more detail here: laravel/vs-code-extension#532 (comment)