Skip to content

Commit

Permalink
test: import-test-from with decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Nov 27, 2024
1 parent 9d9658e commit 1c2ec01
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/import-test-guess-decorators/features/sample.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Feature: feature 1

Scenario: scenario 1
Given todoPage: step
4 changes: 4 additions & 0 deletions test/import-test-guess-decorators/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"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.",
"smoke": true
}
11 changes: 11 additions & 0 deletions test/import-test-guess-decorators/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';

const testDir = defineBddConfig({
features: 'features',
steps: 'steps/*.ts',
});

export default defineConfig({
testDir,
});
9 changes: 9 additions & 0 deletions test/import-test-guess-decorators/steps/TodoPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Fixture, Given } from 'playwright-bdd/decorators';
import { test } from './fixtures';

export
@Fixture<typeof test>('todoPage')
class TodoPage {
@Given('todoPage: step')
async step() {}
}
6 changes: 6 additions & 0 deletions test/import-test-guess-decorators/steps/fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { test as base } from 'playwright-bdd';
import { TodoPage } from './TodoPage';

export const test = base.extend<{ todoPage: TodoPage }>({
todoPage: ({}, use) => use(new TodoPage()),
});
7 changes: 7 additions & 0 deletions test/import-test-guess-decorators/test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { test, TestDir, execPlaywrightTest } from '../_helpers/index.mjs';

const testDir = new TestDir(import.meta);

test(testDir.name, () => {
execPlaywrightTest(testDir.name);
});

0 comments on commit 1c2ec01

Please sign in to comment.