pestphp/pest-plugin-mutate
Pest Plugin Mutate brings mutation testing to Pest, helping you gauge test suite effectiveness by introducing small code changes and checking whether tests catch them. Ideal for strengthening coverage and confidence in your PHP applications.
composer require pestphp/pest-plugin-mutate --dev.vendor/bin/pest --mutate.mutate() inside a test file to limit scope — e.g., run only when testing a specific feature. Start with the default configuration (mutate()) and gradually add constraints like ->path('src').mutate() directly in a test file (e.g., inside Feature/ServiceTest.php) to focus on one component at a time. This gives fast feedback and keeps CI load manageable.->min(90)) and only run on changed files (->changedOnly()) in PR checks to prevent regressions without slowing down builds.->retry() when iteratively fixing escaped mutants to prioritize known-good candidates.->bail() to fail fast on low-hanging fruit (escaped or uncovered code).'default', 'arithmetic', or 'production-critical' in Pest.php, e.g.:
use Pest\Mutate\Mutators;
mutate('high-coverage')
->paths('src/Domain')
->mutators(Mutators::SET_HIGH_COVERAGE)
->min(100);
->mutators(Mutators::SET_ARITHMETIC) to mutate only arithmetic operators for shallow, fast checks — ideal for quick checks in CI or early CI stages.changedOnly() Requires Git: This option only works in git repos and compares against main by default; pass a branch name to adjust (e.g., ->changedOnly('feature/xyz')). It relies on git diff and git merge-base.--no-cache only when debugging; otherwise, cached results dramatically speed up runs — especially with ->retry().->min() with failOnZeroMutations: false: Useful in new/empty directories where 0 mutations shouldn’t break the pipeline.mutate() vs CLI Flag: Using mutate() in tests implies --mutate; omit it if you only want CLI triggers. Avoid using both simultaneously unless intentional.->extends()), it’s currently unsupported — define configs explicitly.->bail() stops on first escaped or uncovered mutant — great for CI safety, but can give incomplete reports during local exploration.ArithmeticPlusToMinus. In PHP, use constants like Mutators::ARITHMETIC_PLUS_TO_MINUS. Double-check spelling — typos silently ignore invalid mutators.How can I help you explore Laravel packages today?