Pest: Run Only Tests In One File

Pest is our tool of choice when it comes to testing in PHP. It is built on top of the tried and tested PHP Unit and adds a bunch of useful helpers which improve the DX. One I use often is the ->only() method, this limits which tests are run to only those tagged with ->only().

It quicky gets tedious when you want to run all the tests in one file and you have to go through each one adding ->only(). You can pass the path of the file to the pest command but there is an easier way:


Adding this is at the top of the test file is functionally the same just much quicker to add/remove.

Popular Reads


Keep up to date

Please provide your email address
Please provide your name
Please provide your name
No thanks