diff --git a/steps/fixtures.ts b/steps/fixtures.ts index c0cab11..883c0a8 100644 --- a/steps/fixtures.ts +++ b/steps/fixtures.ts @@ -1,5 +1,6 @@ import { test as base } from 'playwright-bdd'; +import { MyFixture} from "./my-fixture"; -export const test = base.extend({ - // add your fixtures here -}); +export const test = base.extend<{ myFixture: MyFixture}>({ + myFixture: async ({ page }, use) => await use(new MyFixture(page)), +}); \ No newline at end of file diff --git a/steps/index.ts b/steps/index.ts index 344cc64..f6b8493 100644 --- a/steps/index.ts +++ b/steps/index.ts @@ -4,8 +4,9 @@ import { test } from './fixtures'; const { Given, When, Then } = createBdd(test); -Given('I am on Playwright home page', async ({ page }) => { +Given('I am on Playwright home page', async ({ page, myFixture }) => { await page.goto('https://playwright.dev'); + await myFixture.page.goto('https://playwright.dev'); }); When('I click link {string}', async ({ page }, name: string) => { diff --git a/steps/my-fixture.ts b/steps/my-fixture.ts new file mode 100644 index 0000000..22209f8 --- /dev/null +++ b/steps/my-fixture.ts @@ -0,0 +1,8 @@ +import { Page } from "@playwright/test"; + +export class MyFixture { + public page: Page; + constructor(page: Page) { + this.page = page; + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 38947dd..57c71d7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "es2021", "module": "commonjs", - "strict": true, + "strict": false, "noEmit": true, "useUnknownInCatchVariables": false, "forceConsistentCasingInFileNames": true,