I'm used to using Cucumber where I can tag my feature files with annotations like @prodSafe and run only tests with that tag on my production environment.
Is there a way I can do that with Playwright? I want to run all my tests on dev but then on production, there are tests I'd like to skip for things like deleting users, etc.
To tag a test in playwright, we just add the tag, for example @smokeDev to the test definition:
test('@smokeDev - Login to dev with valid credentials', async ({ page })
...
});
To run all tests having a tag you can use
npx playwright test --grep '@smokeDev'
This command will run all tests having @smokeDev tag.
It is also possible to pick multiple tags by simply combining them with |
For instance:
npx playwright test --grep '@smokeDev|smokeProd'
This command will run all tests having either the tag
@smokeDev or@smokeProdIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With