Playwright Skip Test on Mobile View

Profile picture for user devraj

In Playwright, if you wish to avoid executing all tests on the mobile view, you have the option to remove the corresponding configuration. However, if you want to skip specific test or a group of tests, I recommend following the guidelines provided in the associated article.

Table of Contents

  1. Skip a Specific Test
  2. Skip Group of Tests

Skip Specific Test

Consider a specific test exist on Desktop View, not on mobile view:

test('Test 1', async ({ page, isMobile }) => {
    if(isMobile) {
        test.skip();
    }
    // Statements for other view
 })

Test will be moved to skipped section.

Skip Group of Tests

In case set of test cases are not for mobile view. You can group them using describe and add below statement in describe block.

test.describe('Login', ()=>
{
  test.skip(({ isMobile }) => isMobile == true);
})