1.7 KiB
1.7 KiB
| id | title |
|---|---|
| test-annotations | Annotations |
Sadly, tests do not always pass. Luckily, Playwright Test supports test annotations to deal with failures, flakiness and tests that are not yet ready.
// example.spec.js
const { test, expect } = require('@playwright/test');
test('some feature', async ({ page, browserName }) => {
test.skip(browserName !== 'webkit', 'This feature is iOS-only');
// Test goes here.
});
test('another feature', async ({ page }) => {
test.fail(true, 'Broken, need to fix!');
// Test goes here.
});
// example.spec.ts
import { test, expect } from '@playwright/test';
test('some feature', async ({ page, browserName }) => {
test.skip(browserName !== 'webkit', 'This feature is iOS-only');
// Test goes here.
});
test('broken feature', async ({ page }) => {
test.fail();
// Test goes here.
});
Annotations apply when the condition is truthy, or always when no condition is passed, and may include a description. Annotations may depend on test fixtures. There could be multiple annotations on the same test, possibly in different configurations.
Available annotations:
skipmarks the test as irrelevant. Playwright Test does not run such a test. Use this annotation when the test is not applicable in some configuration.failmarks the test as failing. Playwright Test will run this test and ensure it does indeed fail. If the test does not fail, Playwright Test will complain.fixmemarks the test as failing. Playwright Test will not run this test, as opposite to thefailannotation. Usefixmewhen running the test is slow or crashy.slowmarks the test as slow and triples the test timeout.