Playwright Skip a Test

You can use the skip() method in Playwright to skip a test. You can use this method with one or more tests in your spec file.

Table of Contents

  1. Skip a Test
  2. Unconditionally Skip a Test
  3. Video Tutorial

Skip a Test

Here is the syntax to skip a test.

test.skip(title, testFunction)

The test will never run if you will link the skip() method with it. For example:

test('Test 1', async({page})=>{  
    console.log("Test 1 Executed");

test.skip('Test 2', async({page})=>{
    console.log("Test 2 Executed");

test('Test 3', async({page})=>{  
    console.log("Test 3 Executed");

Test 2 will be skipped in the above code, and the remaining two tests will be executed.

Also, in the report, Test 2 will be listed under skipped section, and the remaining two test cases in the passed section.

Playwright Skip a Test

You can .skip() method with multiple tests; Playwright will not restrict you. However, if you want to skip group of tests, better you use skip() with the describe.

Unconditionally Skip a Test

Instead of linking the skip() method with your test, you can also use the test.skip() statement inside your test method body. It will unconditionally skip a test. The test is immediately terminated when you call the test.skip().

test('Test 2', async({page})=>{
    console.log("Test 2 Executed");

However, it makes more sense to skip the test based on conditions. You can use this statement inside your if block or give a condition as an argument in the skip() method.

Fri, 02/03/2023 - 07:19
Ashwin possesses over five years of experience in the Quality Assurance industry and is currently serving as a Technical Lead at iVagus. His expertise encompasses a broad range of technologies, including Cypress, Rest Assured, Selenium, Cucumber, JavaScript and TypeScript.

Video Tutorial: Skip a Test in Playwright