Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Pest Plugin Type Coverage Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

This plugin adds type coverage analysis to Pest tests, helping you measure how thoroughly your codebase is type-checked. To get started:

  1. Install via Composer: composer require --dev pest/pest-plugin-type-coverage
  2. Run pest --type-coverage (or pest --coverage --type-coverage if also collecting runtime coverage)
  3. First-time users will see a simple console report showing lines typed vs total lines, optionally with thresholds enforced via config

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.

Implementation Patterns

  • CI Integration: Add 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.
  • Local Development Workflow: Run pest --type-coverage --watch (if supported) during refactoring to catch regressions in typing as you change signatures.
  • Threshold Configuration: Create a 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),
    ])
    
  • Gradual Adoption: Run 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.

Gotchas and Tips

  • Misleading Coverage Report: The plugin only counts lines covered by tests and type-checked. It does not analyze untested code — this is test-driven type coverage, not full static analysis.
  • No Custom Rules: Unlike Psalm/PHPStan, this plugin does not allow defining rule levels or ignoring specific violations — it’s purely about coverage metrics.
  • 🚫 Fails Silently on Uncovered Code: Files/tests with no runtime execution won’t influence type coverage. Always pair with --coverage if you want all uncovered types flagged.
  • Tip: Use --formatter=json to export results for dashboards or historical tracking (e.g., via CI artifacts).
  • Tip: Combine with phpstan.neon exclusions to ensure only relevant files are analyzed (e.g., skip migrations, fixtures).
  • ⚠️ Low Stars, High Utility?: Though low in stars and maturity (per README-only state), it fills a niche: bridging runtime test coverage with static typing awareness in Pest-based workflows — especially valuable in mixed PHP 7/8 codebases.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport