Skip to content

Commit

Permalink
Merge pull request #198 from mozex/patch-1
Browse files Browse the repository at this point in the history
Add documentation for glob patterns in ->in() method
  • Loading branch information
nunomaduro authored Jul 28, 2023
2 parents 33d49b7 + c3cc77d commit e44e185
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions configuring-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ it('has home', function () {
});
```

Additionally, Pest supports [glob patterns](https://www.php.net/manual/en/function.glob.php) in the in() method. This allows you to specify multiple directories or files with a single pattern. Glob patterns are string representations that can match various file paths, like wildcards. If you are unfamiliar with glob patterns, refer to the PHP manual [here](https://www.php.net/manual/en/function.glob.php).

```php
// tests/Pest.php
uses(Tests\TestCase::class)->in('Feature/*Job*.php');

// This will apply the Tests\TestCase to all test files in the "Feature" directory that contains "Job" in their filename.
```

Another more complex example would be using a pattern to match multiple directories in different modules while applying multiple test case classes and traits:

```php
// tests/Pest.php
uses(
DuskTestCase::class,
DatabaseMigrations::class
)->in('../Modules/*/Tests/Browser');

// This will apply the DuskTestCase class and the DatabaseMigrations trait to all test files within any module's "Browser" directory.
```

Any method that is defined as `public` or `protected` in your base test case class can be accessed within the test closure.

```php
Expand Down

0 comments on commit e44e185

Please sign in to comment.