Skipping Tests

Overview

During development, you may want to temporarily turn off a test. Rather than commenting it out, you can use the skip method.

This is the equivalent of markTestSkipped in PHPUnit.

1it('has home', function () {
2 // ..
3})->skip();

Of course, you can also mention the reason for skipping this test:

1it('has home', function () {
2 // ..
3})->skip('Home page not available');

Also, you may want to skip a test depending on a condition:

1it('has home', function () {
2 // ..
3})->skip(true === true, 'Home page not available');

And it also works with higher order tests:

1it('works with higher order testing')
2 ->assertTrue(true)
3 ->skip();

Running a single test

If you’d like to run a single test to debug a problem, just use the following syntax:

1it('has home', function () {
2 // ..
3})->only();

Please be aware that ->only() requires all tests to be written with Pest test functions to work correctly.

Incomplete tests

If you’d like to remind yourself to come back and write a test later, just omit the closure expression to define a pending test:

1it('has home');

Behind the scenes, Pest will mark this test as incomplete.


Next section: Datasets →