- ๐ง Smart helper file generation for PestPHP
- ๐ซต๐ป Supports your custom test cases
- ๐งฉ Pure PHP & framework agnostic
Important
This project is currently in beta. Features are subject to change.
IntelliPest is a CLI tool that generates a helper file based on your own Pest setup.
This assists your IDE or coding agent to better understand your tests, enabling full autocompletion and error checking for compatible language servers.
Editors/IDEs and Coding Agents which can benefit from this include VS Code, Cursor, Zed and OpenCode.
For standard Pest setups with the Pest.php configuration file located in ./tests/Pest.php, you can follow these steps.
If your Pest.php is located somewhere else, see the configuration section below.
Make sure your project meets the following requirements:
- PHP 8.3+
- Pest 4.x
- Install the package via composer:
composer require --dev ace-of-aces/intellipest- Run this command to generate the helper file:
./vendor/bin/intellipest- If the command ran successfully, you should be all set! You may have to restart your LSP for it to register the helper file.
IntelliPest can be configured through flags to the intellipest command.
Specify the path to the Pest.php configuration file. Default: tests/Pest.php.
Specify the path to write the generated IDE helper file. Default: .intellipest/_pest-helper.php.
Note
You may also set the output directory via the INTELLIPEST_OUTPUT_DIR environment variable.
Don't generate helper methods for Pest's built-in expectations in the helper file.
Note
Some LSPs like Intelephense Premium support the @mixin PHPDoc tag, which is used in Pest's source code, making these helper methods redundant for those users.
Don't show the (beautiful) header and footer in the console output ๐
Watch the Pest.php configuration file and automatically regenerate the helper file when changes are detected. Checks for changes every half second.
Note
The watch process continues running until manually stopped (Ctrl+C). Syntax errors in the config file are reported but don't stop the watcher.
Don't output any console messages (useful for CI).
Currently, compatibility has only been tested with the popular Intelephense PHP LSP.
The main requirement for an LSP to benefit from IntelliPest is support for the @param-closure-this PHPDoc tag specified by PHPStan,
which enables type hinting the $this variable inside of test cases.
Note
For PHPStorm users, we recommend just using the first-party Pest plugin by JetBrains.
Exact API compatibility for minor Pest versions has not been thoroughly tested as of right now. This may improve in future releases.
Important
IntelliPest currently only supports projects using Pest 4.x
IntelliPest is currently unable to accurately reflect the dynamic Test class association of the $this variable in test cases determined by the ->in(...) method in configuration call chains.
For a Pest.php configuration with different TestCase classes for the Feature and Unit folders, like this:
pest()->extends(Tests\TestCase::class)
->extend(Illuminate\Foundation\Testing\RefreshDatabase::class)
->in('Feature');
pest()->extend(Tests\UnitTestCase::class)
->in('Unit');The resulting type hint in all test cases will always be a union of both TestCase classes, regardless of whether the test is located in Feature or Unit:
Important
It's important to be aware of this while writing tests, as suggestions from both TestCase classes will appear on the $this variable inside of tests, even though they might not be available (possibly resulting in a runtime exception when called from the wrong context).
This is due to IntelliPest's helper file approach only being able to override the @param-closure-this PHPDoc tag for Pest's global testing function declarations.
IntelliPest leverages the nikic/PHP-Parser package in order to parse your Pest.php as an AST (Abstract Syntax Tree).
This enables it to extract call chains to Pest's configuration API (namely pest(), uses(), expect()).
Based on these function calls and the arguments you pass to them (mainly TestCase classes and Traits), IntelliPest maps those to an internal data structure.
As a final step, IntelliPest takes all of this analyzed data and generates a PHP helper file with the help of templates.
Whether it's reporting or fixing bugs, contributing new features, or enhancing the documentation, your help is always appreciated. ๐๐ป
โ Read the Contribution Guidelines
- Nikita Popov, creator of PHP-Parser
- Ondrej Mirtes, creator of PHPStan
- Nuno Maduro, creator of Pest
- Ben Mewburn, creator of Intelephense
- Pushpak Chhajed for the console ASCII art inspiration
Made with โค๏ธ under the MIT License


