diff --git a/test/world-ambiguos/only-steps/fixtures.ts b/test/world-ambiguos/only-steps/fixtures.ts new file mode 100644 index 00000000..22f46acd --- /dev/null +++ b/test/world-ambiguos/only-steps/fixtures.ts @@ -0,0 +1,5 @@ +import { test as base } from 'playwright-bdd'; + +export const test = base.extend<{ world1: string; world2: string }>({ + world1: async ({}, use) => use('world1'), +}); diff --git a/test/world-ambiguos/only-steps/sample.feature b/test/world-ambiguos/only-steps/sample.feature new file mode 100644 index 00000000..be52ac5c --- /dev/null +++ b/test/world-ambiguos/only-steps/sample.feature @@ -0,0 +1,5 @@ +Feature: feature + + Scenario: scenario + Given step with world1 + Given step with world2 diff --git a/test/world-ambiguos/only-steps/steps1.ts b/test/world-ambiguos/only-steps/steps1.ts new file mode 100644 index 00000000..7dcc5734 --- /dev/null +++ b/test/world-ambiguos/only-steps/steps1.ts @@ -0,0 +1,6 @@ +import { createBdd } from 'playwright-bdd'; +import { test } from './fixtures'; + +const { Given } = createBdd(test, { worldFixture: 'world1' }); + +Given('step with world1', async function () {}); diff --git a/test/world-ambiguos/only-steps/steps2.ts b/test/world-ambiguos/only-steps/steps2.ts new file mode 100644 index 00000000..b12f136f --- /dev/null +++ b/test/world-ambiguos/only-steps/steps2.ts @@ -0,0 +1,6 @@ +import { createBdd } from 'playwright-bdd'; +import { test } from './fixtures'; + +const { Given } = createBdd(test, { worldFixture: 'world2' }); + +Given('step with world2', async function () {}); diff --git a/test/world-ambiguos/package.json b/test/world-ambiguos/package.json new file mode 100644 index 00000000..de610253 --- /dev/null +++ b/test/world-ambiguos/package.json @@ -0,0 +1,3 @@ +{ + "description": "This file is required for Playwright to consider this dir as a . It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conflicts." +} diff --git a/test/world-ambiguos/playwright.config.ts b/test/world-ambiguos/playwright.config.ts new file mode 100644 index 00000000..be2082f0 --- /dev/null +++ b/test/world-ambiguos/playwright.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from '@playwright/test'; +import { defineBddConfig } from 'playwright-bdd'; + +const testDir = defineBddConfig({ + featuresRoot: 'only-steps', +}); + +export default defineConfig({ + testDir, +}); diff --git a/test/world-ambiguos/test.mjs b/test/world-ambiguos/test.mjs new file mode 100644 index 00000000..361132fc --- /dev/null +++ b/test/world-ambiguos/test.mjs @@ -0,0 +1,10 @@ +import { test, TestDir, execPlaywrightTestWithError } from '../_helpers/index.mjs'; + +const testDir = new TestDir(import.meta); + +test(testDir.name, () => { + execPlaywrightTestWithError(testDir.name, [ + 'All steps in a feature file should have the same worldFixture', + 'Found fixtures: world1, world2', + ]); +});