Skip to content

Latest commit

 

History

History
81 lines (61 loc) · 1.83 KB

skipping-tests.md

File metadata and controls

81 lines (61 loc) · 1.83 KB
title description
Skipping Tests
Skipping Tests

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.

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

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

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

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

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

You may use a callable for the condition, which has access to the underlying test case:

it('has home', function () {
    // ..
})->skip(fn() => DB::getDriverName() !== 'mysql', 'Only runs when using mysql');

And it also works with higher order tests:

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

Running a single test

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

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

Please be aware that ->only() requires all tests to be written with Pest test functions to work correctly. Furthermore, it will be ignored if the --ci option is added to the cli command

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:

it('has home');

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


Next section: Datasets →