Playwright Run Only One Test

Profile picture for user arilio666

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.

Video Tutorial: Playwright Run Only One Test