-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
component tests: run on real mergeTest for pw >= 1.39
- Loading branch information
Showing
8 changed files
with
69 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// keep this file as .js because @playwright/test has mergeTest only since 1.39 | ||
import { mergeTests } from '@playwright/test'; | ||
import { test as ctBase } from '@playwright/experimental-ct-react'; | ||
import { test as base } from 'playwright-bdd'; | ||
|
||
export const test = mergeTests(base, ctBase).extend({ | ||
world: ({}, use) => use({ clickedTimes: 0 }), | ||
}); |
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,37 @@ | ||
import React from 'react'; | ||
import { expect } from '@playwright/test'; | ||
import { createBdd } from 'playwright-bdd'; | ||
import { test } from './fixtures'; | ||
|
||
const { Given, When, Then } = createBdd(test); | ||
|
||
Given('Mounted input component', async ({ mount }) => { | ||
// use <textarea> instead of <input> | ||
// see: https://github.com/microsoft/playwright/issues/28566 | ||
await mount(<textarea data-testid="textField" />); | ||
}); | ||
|
||
When('I type {string}', async ({ page }, arg) => { | ||
await page.getByTestId('textField').fill(arg); | ||
}); | ||
|
||
Then('input field has {string}', async ({ page }, arg) => { | ||
await expect(page.getByTestId('textField')).toHaveValue(arg); | ||
}); | ||
|
||
Given( | ||
'Mounted button with an event handler that record how many times it was pressed', | ||
async ({ mount, world }) => { | ||
await mount( | ||
<button type="button" data-testid="button" onClick={() => (world.clickedTimes += 1)} />, | ||
); | ||
}, | ||
); | ||
|
||
When('I press the button', async ({ page }) => { | ||
await page.getByTestId('button').click(); | ||
}); | ||
|
||
Then('the recorded number of times the button was pressed is {int}', async ({ world }, arg) => { | ||
expect(world.clickedTimes).toBe(arg); | ||
}); |
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { test, getTestName, execPlaywrightTest, getPackageVersion } from '../helpers.mjs'; | ||
|
||
// Playwright 1.33 has a strange error | ||
const pwVersion = getPackageVersion('@playwright/test'); | ||
|
||
// Playwright 1.33 has a weird error. | ||
// See: https://github.com/vitalets/playwright-bdd/pull/63#issuecomment-1782832507 | ||
const isPW133 = getPackageVersion('@playwright/test').startsWith('1.33.'); | ||
const skip = pwVersion.startsWith('1.33.'); | ||
|
||
test(getTestName(import.meta), { skip: isPW133 }, (t) => { | ||
execPlaywrightTest(t.name); | ||
test(getTestName(import.meta), { skip }, (t) => { | ||
execPlaywrightTest(t.name, { | ||
NATIVE_MERGE_TESTS: pwVersion >= '1.39.0', | ||
}); | ||
}); |