pestphp/pest-plugin-type-coverage
Pest Plugin Type Coverage adds type coverage reporting to your Pest test suite, helping you spot untyped or partially typed code paths. Install alongside Pest to track type coverage metrics and improve type safety over time.
This plugin adds type coverage analysis to Pest tests, helping you measure how thoroughly your codebase is type-checked. To get started:
composer require --dev pest/pest-plugin-type-coveragepest --type-coverage (or pest --coverage --type-coverage if also collecting runtime coverage)The plugin is designed for developers already using Pest — it does not replace Pest but enhances test runs with static analysis insights. You’ll want to run it early in CI or locally to enforce typing standards alongside runtime coverage.
pest --type-coverage --fail-threshold=80 to your CI pipeline to fail builds if type coverage drops below a target (e.g., 80%). Use --no-interaction in non-interactive environments.pest --type-coverage --watch (if supported) during refactoring to catch regressions in typing as you change signatures.phpunit.xml or pest.php config entry to set a default failure threshold and ignore paths:
//pest.php
->plugins([
Pest\TypeCoverage::plugin()
->ignorePaths(['tests/', 'vendor/'])
->failThreshold(95),
])
pest --type-coverage on specific files (e.g., pest --type-coverage tests/Feature/AuthTest.php) to verify new or refactored code before broadening scope.The plugin integrates with phpstan/psalm ecosystem data—no additional setup needed if your project already uses those tools.
--coverage if you want all uncovered types flagged.--formatter=json to export results for dashboards or historical tracking (e.g., via CI artifacts).phpstan.neon exclusions to ensure only relevant files are analyzed (e.g., skip migrations, fixtures).How can I help you explore Laravel packages today?