In this article, we will be seeing playwright annotations. Annotations can be conditional, which means they can be applied to a single test or multiple tests. Multiple annotations on the same test are possible with also various settings too.
test.skip
- With this, the specified test step will be skipped.
- Use this annotation when the test step is not relevant.
test.skip('skip this test', async ({ page }) => {
//skipped
});
test.fail
- This annotation will make the test step fail and execute to confirm that this test fails.
- The playwright complains if the test does not fail.
test('login', async ({ page }) => {
test.fail();
});
test.fixme
- When the test is slow or crashes, use fixme to let know that this is a failed step.
test.fixme('test to fix', async ({ page }) => {
// ...
});
test.slow
- This annotation is used to classify the test as sluggish and exceeds the test timeout.
test('slow', async ({ page }) => {
test.slow();
});
test.only
- This will only run the particular specified test step.
test.only('this test alone', async ({ page }) => {
// only this test.
});
- Log in to post comments