What is spec.ts?
The spec file is a collection of test cases. Once we have done npm init playwright, we see a function @playwright/test imported. Using this test annotation, we can define the test cases.
import {test} from '@playwright/test'; Test function is what we are importing.
test('Name of the test case', 'callback function' { // playwright test steps // step 1 // step 2 ........ ........ ........ });
There are some built-in test sub-functions available that we can use with the test annotation. These help in controlling which tests to run or not.
Example:
- test.only() -- Playwright will only run this test from the specs.
- test.skip() -- Playwright will not run this test from the specs.
- test.fail() -- Playwright will validate and check if the test is failing. if not, then it will complain.
Comments
Post a Comment