New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

alies-dev/psalm-plugin-pest

Psalm plugin for Pest: types $this in test closures as the configured TestCase (with its traits and beforeEach() properties), resolves expectation and higher-order test chains, narrows types after expect() and accepts Pest's public API.
302 2
Install
composer require alies-dev/psalm-plugin-pest
Latest Version:0.5.0
PHP:^8.3
License:MIT
Last Updated:Nov 6, 2026
Links: GitHub  ·  Packagist
Maintainer: alies-dev

psalm-plugin-pest: makes Psalm understand Pest tests

Your Pest tests, fully typed. Bugs contained.

Latest version Downloads License

This plugin teaches Psalm how Pest really works. Keep your tests in the analysis, get real types and catch broken tests before you run them.

Install

Requires Psalm 7 and Pest 4 or 5.

composer require --dev alies-dev/psalm-plugin-pest
vendor/bin/psalm-plugin enable alies-dev/psalm-plugin-pest

That's it. Make sure tests/ is in <projectFiles> of your psalm.xml.

Before and after

uses(Tests\TestCase::class);

beforeEach(function () {
    $this->cart = new Cart();
});

it('totals the cart', function () {
    $this->actingAs(admin());       // before: TestCall::__call(), unchecked
                                    // after:  Tests\TestCase::actingAs()

    $total = $this->cart->total();  // before: TestCall, so $total is TestCall
                                    // after:  Cart from beforeEach(), int

    expect($total)->toBeString();   // after:  PestImpossibleExpectation,
});                                 //         total() returns int

Found a false positive? Open an issue with a snippet.

License

MIT, see LICENSE.

Related Packages

psalm/plugin-laravel

Psalm plugin for Laravel

6,206,297 348
heyjordanparker/mago-pest

Mago analyzer support for Pest: $this in test closures, dynamic test properties,...

13 0
odinns/phpstan-pest-this

PHPStan extensions to infer Pest closure $this type from test file mappings.

4,006 1
ianrodrigues/pest-plugin-code-quality

Method-level and class-level maintainability limits (complexity, body lines, par...

332 4
soloterm/solo

A Laravel package to run multiple commands at once, to aid in local development.

595,486 1,289
dev

Version History

Version Released PHP License
0.5.0 ^8.3 MIT
0.4.0 ^8.3 MIT
0.3.0 ^8.3 MIT
0.2.3 ^8.3 MIT
0.2.2 ^8.3 MIT
Pre-releases (2)
Version Released PHP License
1.0.0-rc.2 ^8.3 MIT
1.0.0-rc.1 ^8.3 MIT