Skip to content

Commit

Permalink
export step constructors from fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Jul 10, 2024
1 parent 10dda78 commit 941caa9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 3 additions & 1 deletion steps/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { test as base } from 'playwright-bdd';
import { test as base, createBdd } from 'playwright-bdd';

export const test = base.extend({
// add your fixtures here
});

export const { Given, When, Then } = createBdd(test);
17 changes: 7 additions & 10 deletions steps/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { expect } from '@playwright/test';
import { createBdd } from 'playwright-bdd';
import { test } from './fixtures';
import { expect } from "@playwright/test";
import { Given, When, Then } from "./fixtures";

const { Given, When, Then } = createBdd(test);

Given('I am on Playwright home page', async ({ page }) => {
await page.goto('https://playwright.dev');
Given("I am on Playwright home page", async ({ page }) => {
await page.goto("https://playwright.dev");
});

When('I click link {string}', async ({ page }, name: string) => {
await page.getByRole('link', { name }).click();
When("I click link {string}", async ({ page }, name: string) => {
await page.getByRole("link", { name }).click();
});

Then('I see in title {string}', async ({ page }, text: string) => {
Then("I see in title {string}", async ({ page }, text: string) => {
await expect(page).toHaveTitle(new RegExp(text));
});

0 comments on commit 941caa9

Please sign in to comment.