Skip to content

Commit e0ea8b9

Browse files
vaadin-botvursen
andauthored
test: switch from puppeteer to playwright chrome (#8659) (#8664)
Co-authored-by: Sergey Vinogradov <[email protected]>
1 parent e70a493 commit e0ea8b9

File tree

9 files changed

+31
-123
lines changed

9 files changed

+31
-123
lines changed

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
- name: Install Dependencies
2424
run: yarn --frozen-lockfile --no-progress --non-interactive
2525

26+
- name: Install Playwright
27+
run: npx playwright install chrome --with-deps
28+
2629
- name: Test
2730
run: yarn test
2831
firefox:

.github/workflows/verify.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,8 @@ jobs:
6565
- name: Install Dependencies
6666
run: yarn --frozen-lockfile --no-progress --non-interactive
6767

68+
- name: Install Playwright
69+
run: npx playwright install chrome --with-deps
70+
6871
- name: Test
6972
run: yarn test:it

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"@web/rollup-plugin-html": "^2.0.0",
4242
"@web/test-runner": "^0.19.0",
4343
"@web/test-runner-playwright": "^0.11.0",
44-
"@web/test-runner-puppeteer": "^0.17.0",
4544
"@web/test-runner-saucelabs": "^0.13.0",
4645
"@web/test-runner-visual-regression": "^0.10.0",
4746
"axios": "^1.4.0",

packages/a11y-base/test/active-mixin.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ describe('active-mixin', () => {
6161
});
6262

6363
describe('keyboard', () => {
64+
afterEach(async () => {
65+
for (const key of ['Space', 'Enter']) {
66+
await sendKeys({ up: key });
67+
}
68+
});
69+
6470
it('should set active attribute when Space is pressed', async () => {
6571
await sendKeys({ down: 'Space' });
6672
expect(element.hasAttribute('active')).to.be.true;

test/test-runner-commands/index.js

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -29,66 +29,3 @@ export async function sendMouseToElement(payload) {
2929
const y = Math.floor(rect.y + rect.height / 2);
3030
await executeServerCommand('send-mouse', { ...payload, position: [x, y] });
3131
}
32-
33-
/**
34-
* Resets the mouse position and releases mouse buttons.
35-
*/
36-
export async function resetMouse() {
37-
await executeServerCommand('reset-mouse');
38-
// 'reset-mouse' moves mouse to [0,0], which can interfere with following tests that
39-
// depend on mouse events by causing unwanted `mouseenter` events with Puppeteer.
40-
// Instead move it to the bottom right to make it less likely to affect other tests.
41-
if (/Chrome/u.test(navigator.userAgent) && /Google Inc/u.test(navigator.vendor)) {
42-
await executeServerCommand('send-mouse', { type: 'move', position: [window.innerWidth, window.innerHeight] });
43-
}
44-
}
45-
46-
/**
47-
* Extends the `sendKeys` command to support pressing multiple keys
48-
* simultaneously when provided in the format "Shift+Tab". This format
49-
* is natively supported by Playwright but not by Puppeteer. This wrapper
50-
* enables the same syntax to be used in Puppeteer.
51-
*
52-
* In WebDriver, this functionality is still unavailable because
53-
* web-test-runner does not provide an API for holding keys down.
54-
*
55-
* For more documentation on the original command, please see
56-
* https://modern-web.dev/docs/test-runner/commands/#send-keys
57-
*
58-
* @typedef {{ type: string }} TypePayload
59-
* @typedef {{ press: string }} PressPayload
60-
* @typedef {{ down: string }} DownPayload
61-
* @typedef {{ up: string }} UpPayload
62-
* @param payload {TypePayload | PressPayload | DownPayload | UpPayload}
63-
*
64-
* @example
65-
* // Tab to the next element
66-
* await sendKeys({ press: 'Tab' });
67-
*
68-
* @example
69-
* // Tab to the previous element
70-
* await sendKeys({ press: 'Shift+Tab' });
71-
*
72-
* @example
73-
* await sendKeys({ down: 'Shift' });
74-
* // Do something while holding Shift
75-
* await sendKeys({ up: 'Shift' });
76-
*/
77-
export async function sendKeys(payload) {
78-
const { press } = payload;
79-
if (press && press.includes('+')) {
80-
const keys = press.split('+').map((key) => key.trim());
81-
82-
for (const key of keys) {
83-
await executeServerCommand('send-keys', { down: key });
84-
}
85-
86-
for (const key of keys.reverse()) {
87-
await executeServerCommand('send-keys', { up: key });
88-
}
89-
90-
return;
91-
}
92-
93-
await executeServerCommand('send-keys', payload);
94-
}

web-test-runner-it.config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/* eslint-env node */
2-
const { puppeteerLauncher } = require('@web/test-runner-puppeteer');
32
const { createIntegrationTestsConfig } = require('./wtr-utils.js');
43
const devServerConfig = require('./web-dev-server.config.js');
4+
const { playwrightLauncher } = require('@web/test-runner-playwright');
55

66
const unitTestsConfig = createIntegrationTestsConfig({
77
browsers: [
8-
puppeteerLauncher({
8+
playwrightLauncher({
9+
product: 'chromium',
910
launchOptions: {
10-
headless: 'shell',
11+
channel: 'chrome',
12+
headless: true,
1113
},
1214
}),
1315
],

web-test-runner-snapshots.config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/* eslint-env node */
2-
const { puppeteerLauncher } = require('@web/test-runner-puppeteer');
2+
const { playwrightLauncher } = require('@web/test-runner-playwright');
33
const { createSnapshotTestsConfig } = require('./wtr-utils.js');
44

55
module.exports = createSnapshotTestsConfig({
66
browsers: [
7-
puppeteerLauncher({
7+
playwrightLauncher({
8+
product: 'chromium',
89
launchOptions: {
9-
headless: 'shell',
10+
channel: 'chrome',
11+
headless: true,
1012
},
1113
}),
1214
],

web-test-runner.config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/* eslint-env node */
2-
const { puppeteerLauncher } = require('@web/test-runner-puppeteer');
32
const { createUnitTestsConfig } = require('./wtr-utils.js');
43
const devServerConfig = require('./web-dev-server.config.js');
4+
const { playwrightLauncher } = require('@web/test-runner-playwright');
55

66
const unitTestsConfig = createUnitTestsConfig({
77
browsers: [
8-
puppeteerLauncher({
8+
playwrightLauncher({
9+
product: 'chromium',
910
launchOptions: {
10-
headless: 'shell',
11+
channel: 'chrome',
12+
headless: true,
1113
},
1214
}),
1315
],

yarn.lock

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,15 +2556,6 @@
25562556
"@web/test-runner-coverage-v8" "^0.8.0"
25572557
playwright "^1.22.2"
25582558

2559-
"@web/test-runner-puppeteer@^0.17.0":
2560-
version "0.17.0"
2561-
resolved "https://registry.yarnpkg.com/@web/test-runner-puppeteer/-/test-runner-puppeteer-0.17.0.tgz#a194df3f57a53d66b1bc9ef993358d4f3b2d0469"
2562-
integrity sha512-uGk0G28RfQFDRoBBGOwq4i+PGcVS2dTqu/wFJzT4A7o1DIwKk32dT68q+m7idtH/6X+jIKVg4nnDBVEVgujtpg==
2563-
dependencies:
2564-
"@web/test-runner-chrome" "^0.17.0"
2565-
"@web/test-runner-core" "^0.13.0"
2566-
puppeteer "^23.2.0"
2567-
25682559
"@web/test-runner-saucelabs@^0.13.0":
25692560
version "0.13.0"
25702561
resolved "https://registry.yarnpkg.com/@web/test-runner-saucelabs/-/test-runner-saucelabs-0.13.0.tgz#66b50d4cf6ca29163e8c67e0d6a0b5863ac69172"
@@ -10312,7 +10303,7 @@ punycode@^2.1.0, punycode@^2.1.1:
1031210303
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
1031310304
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
1031410305

10315-
puppeteer-core@23.11.1, puppeteer-core@^23.2.0:
10306+
puppeteer-core@^23.2.0:
1031610307
version "23.11.1"
1031710308
resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-23.11.1.tgz#3e064de11b3cb3a2df1a8060ff2d05b41be583db"
1031810309
integrity sha512-3HZ2/7hdDKZvZQ7dhhITOUg4/wOrDRjyK2ZBllRB0ZCOi9u0cwq1ACHDjBB+nX+7+kltHjQvBRdeY7+W0T+7Gg==
@@ -10324,18 +10315,6 @@ [email protected], puppeteer-core@^23.2.0:
1032410315
typed-query-selector "^2.12.0"
1032510316
ws "^8.18.0"
1032610317

10327-
puppeteer@^23.2.0:
10328-
version "23.11.1"
10329-
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-23.11.1.tgz#98fd9040786b1219b1a4f639c270377586e8899c"
10330-
integrity sha512-53uIX3KR5en8l7Vd8n5DUv90Ae9QDQsyIthaUFVzwV6yU750RjqRznEtNMBT20VthqAdemnJN+hxVdmMHKt7Zw==
10331-
dependencies:
10332-
"@puppeteer/browsers" "2.6.1"
10333-
chromium-bidi "0.11.0"
10334-
cosmiconfig "^9.0.0"
10335-
devtools-protocol "0.0.1367902"
10336-
puppeteer-core "23.11.1"
10337-
typed-query-selector "^2.12.0"
10338-
1033910318
q@^1.5.1:
1034010319
version "1.5.1"
1034110320
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
@@ -11593,7 +11572,7 @@ string-argv@~0.3.2:
1159311572
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.2.tgz#2b6d0ef24b656274d957d54e0a4bbf6153dc02b6"
1159411573
integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==
1159511574

11596-
"string-width-cjs@npm:string-width@^4.2.0":
11575+
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
1159711576
version "4.2.3"
1159811577
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
1159911578
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -11611,15 +11590,6 @@ string-width@^1.0.1, string-width@^1.0.2:
1161111590
is-fullwidth-code-point "^1.0.0"
1161211591
strip-ansi "^3.0.0"
1161311592

11614-
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
11615-
version "4.2.3"
11616-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
11617-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
11618-
dependencies:
11619-
emoji-regex "^8.0.0"
11620-
is-fullwidth-code-point "^3.0.0"
11621-
strip-ansi "^6.0.1"
11622-
1162311593
string-width@^5.0.1, string-width@^5.1.2:
1162411594
version "5.1.2"
1162511595
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
@@ -11704,7 +11674,7 @@ string_decoder@~1.1.1:
1170411674
dependencies:
1170511675
safe-buffer "~5.1.0"
1170611676

11707-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
11677+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
1170811678
version "6.0.1"
1170911679
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
1171011680
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -11718,13 +11688,6 @@ strip-ansi@^3.0.0, strip-ansi@^3.0.1:
1171811688
dependencies:
1171911689
ansi-regex "^2.0.0"
1172011690

11721-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
11722-
version "6.0.1"
11723-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
11724-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
11725-
dependencies:
11726-
ansi-regex "^5.0.1"
11727-
1172811691
strip-ansi@^7.0.1, strip-ansi@^7.1.0:
1172911692
version "7.1.0"
1173011693
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -12945,7 +12908,7 @@ wordwrapjs@^5.1.0:
1294512908
resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-5.1.0.tgz#4c4d20446dcc670b14fa115ef4f8fd9947af2b3a"
1294612909
integrity sha512-JNjcULU2e4KJwUNv6CHgI46UvDGitb6dGryHajXTDiLgg1/RiGoPSDw4kZfYnwGtEXf2ZMeIewDQgFGzkCB2Sg==
1294712910

12948-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
12911+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
1294912912
version "7.0.0"
1295012913
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
1295112914
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -12971,15 +12934,6 @@ wrap-ansi@^6.2.0:
1297112934
string-width "^4.1.0"
1297212935
strip-ansi "^6.0.0"
1297312936

12974-
wrap-ansi@^7.0.0:
12975-
version "7.0.0"
12976-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
12977-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
12978-
dependencies:
12979-
ansi-styles "^4.0.0"
12980-
string-width "^4.1.0"
12981-
strip-ansi "^6.0.0"
12982-
1298312937
wrap-ansi@^8.1.0:
1298412938
version "8.1.0"
1298512939
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)