You can run a single test in Playwright using multiple ways. A few of them are mentioned below.
Table of Content
- Execute the Test using Only Keyword
- Execute the Test with the Title
- Execute the Test using Line Number
- 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
Comments