Skip to content

Commit

Permalink
test: add test world-ambiguos
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Nov 29, 2024
1 parent ffa6a6f commit 82eaadb
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/world-ambiguos/only-steps/fixtures.ts
Original file line number Diff line number Diff line change
@@ -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'),
});
5 changes: 5 additions & 0 deletions test/world-ambiguos/only-steps/sample.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: feature

Scenario: scenario
Given step with world1
Given step with world2
6 changes: 6 additions & 0 deletions test/world-ambiguos/only-steps/steps1.ts
Original file line number Diff line number Diff line change
@@ -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 () {});
6 changes: 6 additions & 0 deletions test/world-ambiguos/only-steps/steps2.ts
Original file line number Diff line number Diff line change
@@ -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 () {});
3 changes: 3 additions & 0 deletions test/world-ambiguos/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conflicts."
}
10 changes: 10 additions & 0 deletions test/world-ambiguos/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';

const testDir = defineBddConfig({
featuresRoot: 'only-steps',
});

export default defineConfig({
testDir,
});
10 changes: 10 additions & 0 deletions test/world-ambiguos/test.mjs
Original file line number Diff line number Diff line change
@@ -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',
]);
});

0 comments on commit 82eaadb

Please sign in to comment.