Skip to content

Latest commit

History

History
160 lines (114 loc) · 2.59 KB

File metadata and controls

160 lines (114 loc) · 2.59 KB

API

describe

Creates a scenario suite that groups related scenarios together.

describe(name: string,fn: TaskSuiteFn)

Parameters:

  • name: The name of the scenario suite
  • fn: A function containing one or more scenarios

Example:

describe("Login Flow",()=>{// Test scenarios go here});

scenario

Defines an individual scenario within a scenario suite.

scenario(name: string,fn: TaskCaseFn)

Parameters:

  • name: The name of the scenario
  • fn: An async function containing the scenario steps

Example:

scenario("How to sign up",async({ page })=>{// Scenario steps go here});

beforeAll

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");});

afterAll

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");});

beforeEach

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");});

afterEach

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");});

text

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");

screenshot

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);

highlight

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'));