#1932·pest

TIA: support affected-filtering within a scoped run (paths, --testsuite, --filter, --group)

Author: cayekpleCreated Sep 25, 2026Updated Sep 25, 2026

What happens

Since 5.0.4, --tia switches itself off for any scoped run. That means any explicit path under a testsuite directory, or any of --filter, --group, --testsuite, --exclude-group, --dirty and so on. Pest prints one line and runs every selected test at full cost:

TIA does not apply to partial runs — running the selected tests directly.

This is still the case in v5.2.1: see src/Plugins/Tia.php:477-479 ($partial = ! $isWorker && ($hasExplicitPath || $this->hasPartialSelection($arguments)); $disabled = $disabled || $partial;).

We understand this is deliberate: it keeps a partial run from writing a partial graph. But it also makes --tia unusable in the most common dev loop, which is running one module's directory while you work on it. It is equally unusable for large suites that CI runs in chunks, one --testsuite at a time.

Repro (plain PHP, no Laravel)

bash
mkdir tia-repro && cd tia-repro
composer config allow-plugins.pestphp/pest-plugin true --no-interaction
composer require pestphp/pest --dev --no-interaction
# phpunit.xml: one testsuite "Unit" -> tests/Unit, <source> includes src/
# src/Calculator.php: final class App\Calculator { public function add(int $a, int $b): int { return $a + $b; } }
# tests/Unit/CalculatorTest.php: expect((new App\Calculator)->add(2, 3))->toBe(5)
# tests/Unit/PlainTest.php: two trivial tests
# composer.json autoload psr-4 App\\ => src/ ; composer dump-autoload
git init -b main && echo vendor/ > .gitignore && git add -A && git commit -qm init

vendor/bin/pest --tia --fresh      # records the graph, 3 passed
vendor/bin/pest --tia              # 3 passed (3 replayed)            <- replay works
sed -i '' 's/$a + $b;/$a + $b + 1;/' src/Calculator.php
vendor/bin/pest --tia              # 1 failed (1 affected, 2 replayed) <- detection works
vendor/bin/pest tests/Unit --tia   # "TIA does not apply to partial runs", 3 run, 0 replayed

Proposal

When a graph exists and the run is scoped:

  1. Apply the selection first, exactly as today.
  2. Run only the selected tests the graph marks as affected, plus selected tests the graph has never seen.
  3. Replay the rest of the selection from the cached results.
  4. Keep today's behaviour of not writing the graph (resultsOnlyWrites), so a scoped run still cannot record a partial graph.

The graph already maps each recorded test to its file, so this is intersecting two sets, not building anything new. If you'd rather keep TIA whole-suite-only, then please say so in the docs and make the notice a warning. Today it reads as though TIA is running.

Why it matters at scale

Our suite has about 16,000 tests; a serial full run takes about 97 minutes. With a whole-suite graph recorded on 5.1.3, detection is correct: a token-level sabotage edit made exactly the two dependent tests fail. For the dev loop, though, one edit costs a bare --tia run 610 s, while the obvious test file on its own takes 4 s. Scoped TIA would sit between the two: it would still catch affected tests in the module being worked on, without paying for the whole estate.

We're happy to send a PR for this if the design is acceptable.