Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST TOOLS MATH

Playwright Skip and Only


Share

Playwright Skip and Only

test.skip() and test.only() decide which tests run.

They are useful while you work on a test, or when a test should not run in a certain browser.



Skip, Only, Fixme and Fail

Four functions change how Playwright treats a test:

FunctionEffect
test.skip()The test does not run, and is reported as skipped
test.fixme()Like skip, but marks the test as broken and waiting for a fix
test.fail()The test runs, and is expected to fail. If it passes, Playwright reports an error
test.only()Only this test (and other tests marked with only) runs

Example

tests/skip.spec.js

// @ts-check
import { test, expect } from '@playwright/test';

test('skipped test', async ({ page }) => {
  test.skip();
});

test.skip('also skipped', async ({ page }) => {
  await page.goto('https://www.w3schools.com/playwright/practice/todo.html');
});

test('not in WebKit', async ({ page, browserName }) => {
  test.skip(browserName === 'webkit', 'Not tested in WebKit yet');
  await page.goto('https://www.w3schools.com/playwright/practice/todo.html');
  await expect(page).toHaveTitle(/Todo List/);
});

test.fixme('drag todos to reorder them', async ({ page }) => {
  await page.goto('https://www.w3schools.com/playwright/practice/todo.html');
});

test('shows an error for an empty todo', async ({ page }) => {
  test.fail(true, 'The app ignores empty todos and shows no error yet');
  await page.goto('https://www.w3schools.com/playwright/practice/todo.html');
  await page.getByRole('button', { name: 'Add' }).click();
  await expect(page.getByRole('alert')).toBeVisible({ timeout: 1000 });
});

Example

npx playwright test tests/skip.spec.js --reporter=list

Output:

Running 5 tests using 5 workers

  -  1 [chromium] › tests/skip.spec.js:8:6 › also skipped
  -  2 [chromium] › tests/skip.spec.js:18:6 › drag todos to reorder them
  -  4 [chromium] › tests/skip.spec.js:4:1 › skipped test
  ok 3 [chromium] › tests/skip.spec.js:12:1 › not in WebKit (245ms)
  x  5 [chromium] › tests/skip.spec.js:22:1 › shows an error for an empty todo (1.9s)

  3 skipped
  2 passed (3.9s)

Example Explained

  • test.skip() inside a test skips it while it runs, and test.skip('name', ...) skips it before it starts
  • test.skip(condition, reason) is a conditional skip: the test only skips when the condition is true, so here it runs in Chromium and would skip in WebKit
  • test.fixme() shows up as skipped, like a todo note for your team
  • The last test checks for a feature the app does not have yet
  • It failed, as expected, so it counts as passed, and the x shows that it failed

test.only() is useful while you work on one test:

Example

test.only('starts empty', async ({ page }) => {
  // only this test runs
});

Note: Remove test.only() before you save your work to Git or share it.

If you forget it, the other tests stop running, and no error tells you.

Set forbidOnly: !!process.env.CI in the config, so a forgotten only fails the run on your CI server (a computer that runs your tests automatically).

process.env.CI is set on most CI servers, and !! turns it into true or false.

You can also use test.describe.skip(), test.describe.only() and test.describe.fixme() on a whole group.



Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.