-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add default tags to @fixture decorator
- Loading branch information
Showing
18 changed files
with
186 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { test as base } from 'playwright-bdd'; | ||
import { TodoPage, TodoPage2, TodoPage3, TodoPage4 } from './poms'; | ||
|
||
export const logger = console; | ||
|
||
export const test = base.extend<{ | ||
todoPage: TodoPage; | ||
todoPage2: TodoPage2; | ||
todoPage3: TodoPage3; | ||
todoPage4: TodoPage4; | ||
}>({ | ||
todoPage: async ({}, use, testInfo) => use(new TodoPage(testInfo)), | ||
todoPage2: async ({}, use, testInfo) => use(new TodoPage2(testInfo)), | ||
todoPage3: async ({}, use, testInfo) => use(new TodoPage3(testInfo)), | ||
todoPage4: async ({}, use, testInfo) => use(new TodoPage4(testInfo)), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Given, Fixture } from 'playwright-bdd/decorators'; | ||
import { logger, test } from './fixtures'; | ||
import { TestInfo } from '@playwright/test'; | ||
|
||
export | ||
@Fixture<typeof test>('todoPage') | ||
class TodoPage { | ||
constructor(private testInfo: TestInfo) {} | ||
|
||
@Given('decorator step', { tags: '@todoPage' }) | ||
step() { | ||
logger.log(`${this.testInfo.title}: todoPage - decorator step`); | ||
} | ||
} | ||
|
||
export | ||
@Fixture<typeof test>('todoPage2') | ||
class TodoPage2 { | ||
constructor(private testInfo: TestInfo) {} | ||
|
||
@Given('decorator step', { tags: '@todoPage2' }) | ||
step() { | ||
logger.log(`${this.testInfo.title}: todoPage2 - decorator step`); | ||
} | ||
} | ||
|
||
export | ||
@Fixture<typeof test>({ name: 'todoPage3', tags: '@todoPage3' }) | ||
class TodoPage3 { | ||
constructor(private testInfo: TestInfo) {} | ||
|
||
@Given('decorator step') | ||
step() { | ||
logger.log(`${this.testInfo.title}: todoPage3 - decorator step`); | ||
} | ||
|
||
@Given('decorator step', { tags: 'not @todoPage3' }) | ||
step2() { | ||
// this step should not be used, because it does not match anything: | ||
// (@todoPage3) and (not @todoPage3) | ||
logger.log(`${this.testInfo.title}: todoPage3 - decorator step`); | ||
} | ||
} | ||
|
||
/* inheritance */ | ||
|
||
export | ||
@Fixture({ tags: '@todoPage4' }) | ||
class Base { | ||
constructor(protected testInfo: TestInfo) {} | ||
|
||
@Given('decorator step') | ||
step() { | ||
logger.log(`${this.testInfo.title}: todoPage4 - decorator step from base`); | ||
} | ||
} | ||
|
||
export | ||
@Fixture<typeof test>('todoPage4') | ||
class TodoPage4 extends Base { | ||
@Given('unique step of todoPage4') | ||
step2() { | ||
logger.log(`${this.testInfo.title}: todoPage4 - unique step`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Feature: feature with poms | ||
|
||
@todoPage | ||
Scenario: scenario for TodoPage | ||
Given decorator step | ||
|
||
@todoPage2 | ||
Scenario: scenario for TodoPage2 | ||
Given decorator step | ||
|
||
@todoPage3 | ||
Scenario: scenario for TodoPage3 | ||
Given decorator step | ||
|
||
@todoPage4 | ||
Scenario: scenario for TodoPage4 | ||
Given decorator step | ||
Given unique step of todoPage4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 'features', | ||
}); | ||
|
||
export default defineConfig({ | ||
testDir, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { test, expect, TestDir, execPlaywrightTest } from '../_helpers/index.mjs'; | ||
|
||
const testDir = new TestDir(import.meta); | ||
|
||
test(testDir.name, () => { | ||
const stdout = execPlaywrightTest(testDir.name); | ||
|
||
expect(stdout).toContain('scenario for TodoPage: todoPage - decorator step'); | ||
expect(stdout).toContain('scenario for TodoPage2: todoPage2 - decorator step'); | ||
expect(stdout).toContain('scenario for TodoPage3: todoPage3 - decorator step'); | ||
expect(stdout).toContain('scenario for TodoPage4: todoPage4 - decorator step from base'); | ||
expect(stdout).toContain('scenario for TodoPage4: todoPage4 - unique step'); | ||
}); |
Oops, something went wrong.