How can I run a specific example using PEST (PHP)

1.1k Views Asked by At

Now I use ./vendor/bin/pest as explained in the docs. But that makes me run all tests. What if I only want to run one specific example? Do I need to use groups or can it be done in an easier way?

2

There are 2 best solutions below

0
On BEST ANSWER

Filtering of tests isn’t part of the Pest framework, instead that is handled by the underlying test runner. This is most commonly PHPUnit and you can find a list of the CLI options in their docs.

0
On

Append ->only() to the end of the test to run:

test('sum', function () {
  $result = sum(1, 2);
 
  expect($result)->toBe(3);
})->only();

See the docs