Playwright Run Only One Test

You can run a single test in Playwright using multiple ways. A few of them are mentioned below.

Table of Content

  1. Execute the Test using Only Keyword
  2. Execute the Test with the Title 
  3. Execute the Test using Line Number
  4. Video Tutorial

Execute the Test using Only Keyword

Append .only to test.

test.only('verify page URL', async ({page})=>{
})

Execute the Test with the Title 

You can use -g or --grep to execute the Test using regular expression for the title of the Test.

npx playwright test -g "title of the test"

You can give a complete title, partial title, or regular expression in double or single quotes.

Execute the Test using Line Number

Give the line number where your Test starts.

npx playwright test my-test-spec.js:25

Note: Make sure you are not using only in your test file while executing with title or line number, otherwise it will return 0 tests executed.

Mon, 10/17/2022 - 20:14
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: Playwright Run Only Single Test

Tags

Comments