Skip to content

Commit 5cfee1f

Browse files
authored
fix: fix compatibility with Puppeteer v21 (#566)
1 parent 3fb7702 commit 5cfee1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+8829
-12905
lines changed

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
jestPuppeteer: "readonly",
1515
page: "readonly",
1616
},
17+
1718
overrides: [
1819
{
1920
files: ["*.test.?(m|t)js"],
@@ -37,6 +38,9 @@ module.exports = {
3738
tsconfigRootDir: __dirname,
3839
},
3940
plugins: ["@typescript-eslint"],
41+
rules: {
42+
"@typescript-eslint/no-explicit-any": "warn",
43+
},
4044
},
4145
],
4246
};

lerna.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"useWorkspaces": true,
32
"version": "9.0.0",
43
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
54
}

package-lock.json

Lines changed: 8641 additions & 12733 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
},
1616
"devDependencies": {
1717
"@swc/cli": "^0.1.62",
18-
"@swc/core": "^1.3.59",
19-
"@swc/jest": "^0.2.26",
20-
"@typescript-eslint/eslint-plugin": "^5.59.7",
21-
"@typescript-eslint/parser": "^5.59.7",
18+
"@swc/core": "^1.3.90",
19+
"@swc/jest": "^0.2.29",
20+
"@typescript-eslint/eslint-plugin": "^6.7.3",
21+
"@typescript-eslint/parser": "^6.7.3",
2222
"conventional-github-releaser": "^3.1.5",
2323
"cross-env": "^7.0.3",
24-
"eslint": "^8.41.0",
25-
"eslint-plugin-jest": "^27.2.1",
24+
"eslint": "^8.50.0",
25+
"eslint-plugin-jest": "^27.4.2",
2626
"express": "^4.18.2",
27-
"jest": "^29.5.0",
28-
"lerna": "^6.6.2",
29-
"prettier": "^2.8.8",
30-
"puppeteer": "^20.3.0",
31-
"typescript": "^5.0.4"
27+
"jest": "^29.7.0",
28+
"lerna": "^7.3.0",
29+
"prettier": "^3.0.3",
30+
"puppeteer": "^21.3.6",
31+
"typescript": "^5.2.2"
3232
},
3333
"name": "jest-puppeteer",
3434
"engines": {

packages/expect-puppeteer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ import { join } from "node:path";
204204

205205
await expect(page).toUploadFile(
206206
'input[type="file"]',
207-
join(__dirname, "file.txt")
207+
join(__dirname, "file.txt"),
208208
);
209209
```
210210

packages/expect-puppeteer/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ module.exports = {
33
transform: {
44
"^.+\\.(t|j)sx?$": ["@swc/jest"],
55
},
6+
testTimeout: 10000,
67
};

packages/expect-puppeteer/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
"build": "rollup -c"
4545
},
4646
"devDependencies": {
47-
"puppeteer": "^20.3.0",
48-
"rollup": "^3.23.0",
49-
"rollup-plugin-dts": "^5.3.0",
50-
"rollup-plugin-swc3": "^0.8.1"
47+
"puppeteer": "^21.3.6",
48+
"rollup": "^3.29.4",
49+
"rollup-plugin-dts": "^6.0.2",
50+
"rollup-plugin-swc3": "^0.10.1"
5151
}
5252
}

packages/expect-puppeteer/rollup.config.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { swc, defineRollupSwcOption } from "rollup-plugin-swc3";
22
import dts from "rollup-plugin-dts";
3+
import * as url from "node:url";
34

45
const bundle = (config) => ({
56
input: "src/index.ts",
@@ -12,14 +13,14 @@ const bundle = (config) => ({
1213
const swcPlugin = swc(
1314
defineRollupSwcOption({
1415
jsc: {
16+
baseUrl: url.fileURLToPath(new URL(".", import.meta.url)),
1517
parser: {
1618
syntax: "typescript",
1719
},
20+
target: "es2022",
21+
externalHelpers: false,
1822
},
19-
env: {
20-
targets: "node 16",
21-
},
22-
})
23+
}),
2324
);
2425

2526
export default [

packages/expect-puppeteer/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-namespace, no-use-before-define, no-restricted-syntax, no-await-in-loop */
1+
/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-namespace, no-use-before-define, no-restricted-syntax, no-await-in-loop, @typescript-eslint/no-unused-vars */
22
import {
33
checkIsPuppeteerInstance,
44
checkIsElementHandle,
@@ -100,7 +100,7 @@ const jestExpect = global.expect as JestExpect;
100100

101101
const wrapMatcher = <TPage extends PuppeteerInstance>(
102102
matcher: Matcher<TPage>,
103-
instance: PuppeteerInstance
103+
instance: PuppeteerInstance,
104104
) => {
105105
return async function throwingMatcher(...args: any[]) {
106106
jestExpect.getState().assertionCalls += 1;
@@ -116,7 +116,7 @@ const wrapMatcher = <TPage extends PuppeteerInstance>(
116116

117117
const createExpect = <T extends PuppeteerInstance>(
118118
instance: T,
119-
matchers: MatcherSet<T>
119+
matchers: MatcherSet<T>,
120120
) => {
121121
const expectation = {
122122
not: {} as Record<string, any>,
@@ -134,7 +134,7 @@ const createExpect = <T extends PuppeteerInstance>(
134134
};
135135

136136
const expectPuppeteerInstance = <TInstance extends PuppeteerInstance>(
137-
actual: TInstance
137+
actual: TInstance,
138138
): PuppeteerMatchers => {
139139
if (checkIsPage(actual)) {
140140
return createExpect(actual, pageMatchers) as PuppeteerMatchers;

packages/expect-puppeteer/src/matchers/getElementFactory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type GetElementOptions = {
1515
export async function getElementFactory(
1616
instance: PuppeteerInstance,
1717
selector: Selector,
18-
options: GetElementOptions
18+
options: GetElementOptions,
1919
) {
2020
const { text: searchExpr, visible = false } = options;
2121

@@ -24,7 +24,7 @@ export async function getElementFactory(
2424
const { text, regexp } = serializeSearchExpression(searchExpr);
2525

2626
const parseSearchExpressionHandle = await evaluateParseSearchExpression(
27-
ctx.page
27+
ctx.page,
2828
);
2929

3030
const getElementArgs = [
@@ -43,9 +43,9 @@ export async function getElementFactory(
4343
regexp: string | null,
4444
visible: boolean,
4545
parseSearchExpression: (
46-
expr: SerializedSearchExpression
46+
expr: SerializedSearchExpression,
4747
) => ((value: string) => boolean) | null,
48-
type: "element" | "positive" | "negative"
48+
type: "element" | "positive" | "negative",
4949
) => {
5050
const hasVisibleBoundingBox = (element: Element): boolean => {
5151
const rect = element.getBoundingClientRect();

0 commit comments

Comments
 (0)