Skip to content

Commit

Permalink
update deps and simplify structure
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Aug 28, 2024
1 parent eab2b8c commit dfdbc76
Show file tree
Hide file tree
Showing 18 changed files with 8,562 additions and 3,797 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ playwright-report

.nx/cache
.env
.nx
update.sh
cucumber-report
17 changes: 4 additions & 13 deletions app1/features/homepage.feature
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
Feature: Playwright Home Page
Feature: Playwright Home Page (app1)

@firefox
Scenario: Check title
Given I am on Playwright home page
Then I see in title "Playwright"

Scenario Outline: Check get started
Given I am on Playwright home page
When I click link "<link>"
Then I see in title "<title>"

Examples:
| link | title |
| Get started | Installation |
| API reference | Library |
When I click link "Get started"
Then I see in title "Installation"

21 changes: 0 additions & 21 deletions app1/features/todopage.feature

This file was deleted.

26 changes: 4 additions & 22 deletions app1/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
import { defineConfig, devices } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
import { defineConfig } from "@playwright/test";
import { defineBddConfig } from "playwright-bdd";

const testDir = defineBddConfig({
importTestFrom: 'steps/fixtures.ts',
paths: ['./features'],
require: ['steps/*.ts'],
quotes: 'backtick',
featuresRoot: './features',
features: "./features",
steps: "steps/*.ts",
});

export default defineConfig({
testDir,
reporter: 'html',
use: {
screenshot: 'only-on-failure',
baseURL: 'http://localhost:3000',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
]
});
2 changes: 1 addition & 1 deletion app1/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"bddgen": {},
"e2e": {}
}
}
}
49 changes: 0 additions & 49 deletions app1/steps/TodoPage.ts

This file was deleted.

15 changes: 5 additions & 10 deletions app1/steps/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { test as base } from 'playwright-bdd';
import { TodoPage } from './TodoPage';
import { test as base, createBdd } from "playwright-bdd";

export const test = base.extend<{ todoPage: TodoPage, browserSpecificTest: void }>({
todoPage: async ({ page }, use) => use(new TodoPage(page)),
browserSpecificTest: [async ({ $tags }, use, testInfo) => {
if ($tags.includes('@firefox') && testInfo.project.name !== 'firefox') {
testInfo.skip();
}
await use();
}, { auto: true }],
export const test = base.extend<{ myFixture: string }>({
myFixture: async ({}, use) => use("my custom fixture"),
});

export const { Given, When, Then } = createBdd(test);
17 changes: 7 additions & 10 deletions app1/steps/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { expect } from '@playwright/test';
import { createBdd } from 'playwright-bdd';
import { test } from './fixtures';
import { expect } from "@playwright/test";
import { Given, Then, When } from "./fixtures";

const { Given, When, Then } = createBdd(test);

Given('I am on Playwright home page', async ({ page }) => {
await page.goto('https://playwright.dev');
Given("I am on Playwright home page", async ({ page }) => {
await page.goto("https://playwright.dev");
});

When('I click link {string}', async ({ page }, name: string) => {
await page.getByRole('link', { name }).click();
When("I click link {string}", async ({ page }, name: string) => {
await page.getByRole("link", { name }).click();
});

Then('I see in title {string}', async ({ page }, text: string) => {
Then("I see in title {string}", async ({ page }, text: string) => {
await expect(page).toHaveTitle(new RegExp(text));
});
17 changes: 4 additions & 13 deletions app2/features/homepage.feature
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
Feature: Playwright Home Page
Feature: Playwright Home Page (app2

@firefox
Scenario: Check title
Given I am on Playwright home page
Then I see in title "Playwright"

Scenario Outline: Check get started
Given I am on Playwright home page
When I click link "<link>"
Then I see in title "<title>"

Examples:
| link | title |
| Get started | Installation |
| API reference | Library |
When I click link "Get started"
Then I see in title "Installation"

21 changes: 0 additions & 21 deletions app2/features/todopage.feature

This file was deleted.

26 changes: 4 additions & 22 deletions app2/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
import { defineConfig, devices } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
import { defineConfig } from "@playwright/test";
import { defineBddConfig } from "playwright-bdd";

const testDir = defineBddConfig({
importTestFrom: 'steps/fixtures.ts',
paths: ['./features'],
require: ['steps/*.ts'],
quotes: 'backtick',
featuresRoot: './features',
features: "./features",
steps: "steps/*.ts",
});

export default defineConfig({
testDir,
reporter: 'html',
use: {
screenshot: 'only-on-failure',
baseURL: 'http://localhost:3000',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
]
});
49 changes: 0 additions & 49 deletions app2/steps/TodoPage.ts

This file was deleted.

15 changes: 5 additions & 10 deletions app2/steps/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { test as base } from 'playwright-bdd';
import { TodoPage } from './TodoPage';
import { test as base, createBdd } from "playwright-bdd";

export const test = base.extend<{ todoPage: TodoPage, browserSpecificTest: void }>({
todoPage: async ({ page }, use) => use(new TodoPage(page)),
browserSpecificTest: [async ({ $tags }, use, testInfo) => {
if ($tags.includes('@firefox') && testInfo.project.name !== 'firefox') {
testInfo.skip();
}
await use();
}, { auto: true }],
export const test = base.extend<{ myFixture: string }>({
myFixture: async ({}, use) => use("my custom fixture"),
});

export const { Given, When, Then } = createBdd(test);
17 changes: 7 additions & 10 deletions app2/steps/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { expect } from '@playwright/test';
import { createBdd } from 'playwright-bdd';
import { test } from './fixtures';
import { expect } from "@playwright/test";
import { Given, Then, When } from "./fixtures";

const { Given, When, Then } = createBdd(test);

Given('I am on Playwright home page', async ({ page }) => {
await page.goto('https://playwright.dev');
Given("I am on Playwright home page", async ({ page }) => {
await page.goto("https://playwright.dev");
});

When('I click link {string}', async ({ page }, name: string) => {
await page.getByRole('link', { name }).click();
When("I click link {string}", async ({ page }, name: string) => {
await page.getByRole("link", { name }).click();
});

Then('I see in title {string}', async ({ page }, text: string) => {
Then("I see in title {string}", async ({ page }, text: string) => {
await expect(page).toHaveTitle(new RegExp(text));
});
5 changes: 2 additions & 3 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"useInferencePlugins": false,
"targetDefaults": {
"bddgen": {
"command": "bddgen",
Expand All @@ -14,7 +15,5 @@
}
}
},
"affected": {
"defaultBase": "main"
}
"defaultBase": "main"
}
Loading

0 comments on commit dfdbc76

Please sign in to comment.