Creates a scenario suite that groups related scenarios together.
describe(name: string,fn: TaskSuiteFn)Parameters:
name: The name of the scenario suitefn: A function containing one or more scenarios
Example:
describe("Login Flow",()=>{// Test scenarios go here});Defines an individual scenario within a scenario suite.
scenario(name: string,fn: TaskCaseFn)Parameters:
name: The name of the scenariofn: An async function containing the scenario steps
Example:
scenario("How to sign up",async({ page })=>{// Scenario steps go here});Defines a hook that runs before all scenarios in a scenario suite.
beforeAll(fn: HookFn)Parameters:
fn: An async function containing the hook steps
Example:
beforeAll(async()=>{console.log("before all");});Defines a hook that runs after all scenarios in a scenario suite.
afterAll(fn: HookFn)Parameters:
fn: An async function containing the hook steps
Example:
afterAll(async()=>{console.log("after all");});Defines a hook that runs before each scenario in a scenario suite.
beforeEach(fn: HookFn)Parameters:
fn: An async function containing the hook steps
Example:
beforeEach(async()=>{console.log("before each");});Defines a hook that runs after each scenario in a scenario suite.
afterEach(fn: HookFn)Parameters:
fn: An async function containing the hook steps
Example:
afterEach(async()=>{console.log("after each");});Adds text content to the documentation output.
text(value: string)Parameters:
value: The text content to add to the documentation
Example:
text("This section demonstrates the login functionality");Captures a screenshot of the current page state and adds it to the documentation.
screenshot(page: Page)Parameters:
page: The Playwright Page object to capture
Example:
awaitscreenshot(page);Highlights an element on the page by adding a red border around it. Useful for emphasizing specific elements in documentation screenshots.
highlight(locator: Locator)Parameters:
locator: A Playwright Locator object pointing to the element to highlight
Example:
awaithighlight(page.locator('.login-button'));