// docs / skipping-tests

Skipping Tests

During development, there may be times when you need to temporarily disable a test. Rather than commenting out the code, you may use the skip() method:

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

When running your tests, Pest will inform you about any tests that were skipped.

  WARN  Tests\Feature\HomepageTest
  - it has home

You may also provide a reason for skipping the test, which Pest will display when running your suite:

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

Sometimes you may wish to skip a test based on a given condition. In these cases, you may provide a boolean value as the first argument to the skip() method. The test will only be skipped if that value evaluates to true:

1it('has home', function () {
2 //
3})->skip($condition == true, 'temporarily unavailable');

Alternatively, you may pass a closure as the first argument to the skip() method to defer evaluation of the condition until the beforeEach() hook of your test case has run:

1it('has home', function () {
2 //
3})->skip(fn () => DB::getDriverName() !== 'mysql', 'db driver not supported');

You may also skip tests based on the environment in which they are running using the skipLocally() or skipOnCi() methods:

1it('has home', function () {
2 //
3})->skipLocally(); // or skipOnCi()

To skip a test on a particular operating system, you may make use of the skipOnWindows(), skipOnMac(), or skipOnLinux() methods:

1it('has home', function () {
2 //
3})->skipOnWindows(); // or skipOnMac() or skipOnLinux() ...

Alternatively, you may skip a test on all operating systems except one by using onlyOnWindows(), onlyOnMac(), or onlyOnLinux():

1it('has home', function() {
2 //
3})->onlyOnWindows(); // or onlyOnMac() or onlyOnLinux() ...

Sometimes you may wish to skip a test on a specific PHP version. In these cases, you may use the skipOnPhp() method:

1it('has home', function () {
2 //
3})->skipOnPhp('>=8.0.0');

The valid operators for the skipOnPhp() method are >, >=, <, and <=.

Finally, you may even invoke the skip() method within your beforeEach() hook to conveniently skip an entire test file:

1beforeEach()->skip(); // or skipOnCi(), etc...

Creating Todos

Sometimes you may wish to add a few empty tests so that you do not forget to write them later. The todo() method is helpful in this situation:

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

As your codebase expands, you may wish to improve the speed of your test suite. To help you with that, we offer detailed documentation on optimizing your suite: Optimizing Tests