Skip to content

Commit 16f4907

Browse files
committed
wip
1 parent 41542e8 commit 16f4907

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ Pest supports a few flags alongside `--tia`:
5151
|---|---|
5252
| `--tia` | Replay if a baseline graph exists, otherwise record. |
5353
| `--tia --fresh` | Discard any existing graph and re-record from scratch. Use this after large refactors or when the graph feels stale. |
54-
| `--tia --refetch` | Force a CI baseline fetch even within the 24-hour cooldown after a previous failed fetch.
54+
| `--tia --refetch` | Force a CI baseline fetch even within the 24-hour cooldown after a previous failed fetch. |
55+
| `--tia --filtered` | Narrow PHPUnit to only the affected test files rather than loading all tests and replaying cached results for unaffected ones. |
5556

5657
## Sharing The Baseline From CI
5758

@@ -74,7 +75,7 @@ jobs:
7475
- uses: actions/checkout@v4
7576
with: { fetch-depth: 0 }
7677
- uses: shivammathur/setup-php@v2
77-
with: { php-version: '8.5', coverage: xdebug }
78+
with: { php-version: '8.4', coverage: xdebug }
7879
- run: composer install --no-interaction --prefer-dist
7980
- run: ./vendor/bin/pest --parallel --tia --coverage
8081
- name: Stage baseline for upload
@@ -97,19 +98,36 @@ Pest stores its state at `~/.pest/tia/<project-key>/`, where the project key is
9798

9899
Sharing state per remote URL means multiple worktrees of the same repository share one cache, while unrelated projects on the same machine stay isolated.
99100

101+
## Configuration
102+
103+
You can configure TIA behaviour in `tests/Pest.php` via `pest()->tia()`:
104+
105+
```php
106+
pest()->tia()
107+
->always() // run TIA on every invocation, no --tia flag needed
108+
->locally(); // restrict always() to local environments only
109+
```
110+
111+
**`always()`** activates TIA for every `pest` run without requiring the `--tia` flag. Pair it with **`locally()`** to restrict that behaviour to local machines — on CI (detected via the `--ci` flag or the `CI` environment variable) TIA is skipped automatically. An explicit `--tia` on the command line always takes effect regardless.
112+
113+
**`filtered()`** enables filtered mode, equivalent to `--tia --filtered`. In this mode Pest narrows PHPUnit to only the affected test files rather than loading the full suite and replaying cached results for unaffected tests:
114+
115+
```php
116+
pest()->tia()->filtered();
117+
```
118+
100119
## Custom Watch Patterns
101120

102121
If your project has a directory layout that doesn't match the framework defaults, you can register custom watch patterns in `tests/Pest.php`:
103122

104123
```php
105124
pest()->tia()->watch([
106-
'config/billing/**/*.php' => ['tests/Feature/Billing'],
107-
108-
//
125+
'config/billing/**/*.php' => 'tests/Feature/Billing',
126+
'public/build/**/*' => 'tests/Browser',
109127
]);
110128
```
111129

112-
Each glob maps to a list of test directories; whenever a matching file changes, every test under those directories is invalidated. Use this when you have specific test directories that genuinely depend on a file Pest can't see otherwise.
130+
Each glob maps to a single test directory. Whenever a matching file changes, every test under that directory is invalidated. Duplicate glob keys overwrite the built-in defaults, so you can redirect a pattern to a narrower directory.
113131

114132
---
115133

0 commit comments

Comments
 (0)