Skip to content

Commit dd1bb5d

Browse files
authored
Update dependencies (#63)
1 parent be9eef7 commit dd1bb5d

9 files changed

Lines changed: 682 additions & 617 deletions

File tree

.changeset/many-carrots-join.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'test-mule': patch
3+
---
4+
5+
Update dependencies

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- run: npm test -- --colors
2020
env:
2121
CI: true
22+
FORCE_COLOR: 1
2223

2324
lint:
2425
runs-on: ubuntu-latest

jest.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ module.exports = {
66
testRunner: 'jest-circus/runner',
77
watchPathIgnorePatterns: ['<rootDir>/src/'],
88
transform: {
9-
'^.+\\.tsx?$': ['esbuild-jest', { sourcemap: true }],
9+
'^.+\\.[jt]sx?$': ['esbuild-jest', { sourcemap: true }],
1010
},
11+
// Don't transform node_modules, _except_ ansi-regex
12+
// ansi-regex is ESM and since we are using Jest in CJS mode,
13+
// it must be transpiled to CJS
14+
transformIgnorePatterns: ['<rootDir>/node_modules/(?!ansi-regex)'],
1115
};

package-lock.json

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

package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,43 @@
88
"dist"
99
],
1010
"devDependencies": {
11-
"@babel/core": "7.13.1",
12-
"@babel/preset-env": "7.13.5",
11+
"@babel/core": "7.14.3",
12+
"@babel/preset-env": "7.14.2",
1313
"@babel/preset-typescript": "7.13.0",
14-
"@changesets/changelog-github": "0.2.8",
15-
"@changesets/cli": "2.14.1",
14+
"@changesets/changelog-github": "0.4.0",
15+
"@changesets/cli": "2.16.0",
1616
"@cloudfour/eslint-plugin": "16.0.0",
1717
"@rollup/plugin-babel": "5.3.0",
1818
"@rollup/plugin-node-resolve": "11.2.0",
19-
"@testing-library/dom": "7.29.4",
20-
"@testing-library/jest-dom": "5.11.9",
21-
"@types/jest": "26.0.20",
22-
"@types/node": "14.14.31",
19+
"@testing-library/dom": "7.31.0",
20+
"@testing-library/jest-dom": "5.12.0",
21+
"@types/jest": "26.0.23",
22+
"@types/node": "15.6.0",
2323
"@types/puppeteer": "5.4.3",
24-
"ansi-regex": "5.0.0",
24+
"ansi-regex": "6.0.0",
2525
"aria-query": "*",
2626
"babel-plugin-un-cjs": "2.3.0",
27-
"env-paths": "2.2.0",
28-
"errorstacks": "2.3.0",
29-
"esbuild": "0.11.21",
27+
"env-paths": "2.2.1",
28+
"errorstacks": "2.3.2",
29+
"esbuild": "0.12.1",
3030
"esbuild-jest": "0.5.0",
31-
"eslint": "7.22.0",
31+
"eslint": "7.27.0",
3232
"jest": "26.6.3",
3333
"jest-circus": "26.6.3",
34-
"kolorist": "1.2.10",
35-
"liquidjs": "9.22.1",
36-
"preact": "10.5.12",
37-
"prettier": "2.2.1",
34+
"kolorist": "1.4.1",
35+
"liquidjs": "9.25.0",
36+
"preact": "10.5.13",
37+
"prettier": "2.3.0",
3838
"remark-cli": "9.0.0",
3939
"remark-lint-no-dead-urls": "1.1.0",
40-
"remark-validate-links": "10.0.2",
40+
"remark-validate-links": "10.0.4",
4141
"rollup": "2.39.1",
4242
"rollup-plugin-dts": "2.0.1",
4343
"rollup-plugin-prettier": "2.1.0",
4444
"rollup-plugin-terser": "7.0.2",
45-
"sass": "1.32.6",
45+
"sass": "1.34.0",
4646
"smoldash": "0.9.0",
47-
"typescript": "4.2.2"
47+
"typescript": "4.2.4"
4848
},
4949
"dependencies": {
5050
"@types/testing-library__jest-dom": "^5.9.5",

src/extend-expect.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,14 @@ Received ${this.utils.printReceived(arg)}`,
150150
: (matcherResult) => matcherResult.message(),
151151
);
152152
const deserializedMessage = runJestUtilsInNode(message, this as any);
153-
const {
154-
messageWithElementsRevived,
155-
messageWithElementsStringified,
156-
} = await elementHandle
157-
.evaluateHandle(
158-
// @ts-expect-error pptr's types don't like new Function
159-
new Function(
160-
'el',
161-
'message',
162-
`return import("http://localhost:${port}/@test-mule/jest-dom")
153+
const { messageWithElementsRevived, messageWithElementsStringified } =
154+
await elementHandle
155+
.evaluateHandle(
156+
// @ts-expect-error pptr's types don't like new Function
157+
new Function(
158+
'el',
159+
'message',
160+
`return import("http://localhost:${port}/@test-mule/jest-dom")
163161
.then(({ reviveElementsInString, printElement }) => {
164162
const messageWithElementsRevived = reviveElementsInString(message)
165163
const messageWithElementsStringified = messageWithElementsRevived
@@ -170,21 +168,22 @@ Received ${this.utils.printReceived(arg)}`,
170168
.join('')
171169
return { messageWithElementsRevived, messageWithElementsStringified }
172170
})`,
173-
),
174-
deserializedMessage,
175-
)
176-
.then(async (returnHandle) => {
177-
const {
178-
messageWithElementsRevived,
179-
messageWithElementsStringified,
180-
} = Object.fromEntries(await returnHandle.getProperties());
181-
return {
182-
messageWithElementsStringified: await messageWithElementsStringified.jsonValue(),
183-
messageWithElementsRevived: await jsHandleToArray(
184-
messageWithElementsRevived,
185171
),
186-
};
187-
});
172+
deserializedMessage,
173+
)
174+
.then(async (returnHandle) => {
175+
const {
176+
messageWithElementsRevived,
177+
messageWithElementsStringified,
178+
} = Object.fromEntries(await returnHandle.getProperties());
179+
return {
180+
messageWithElementsStringified:
181+
await messageWithElementsStringified.jsonValue(),
182+
messageWithElementsRevived: await jsHandleToArray(
183+
messageWithElementsRevived,
184+
),
185+
};
186+
});
188187
if (thrownError) {
189188
const error = new Error(messageWithElementsStringified as any);
190189
// @ts-expect-error messageForBrowser is a property we added to Error

src/pptr-testing-library.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,15 @@ export const getQueriesForElement = (
113113
throw error;
114114
};
115115

116-
const result: JSHandle<
117-
Element | Element[] | DTLError | null
118-
> = await page
119-
.evaluateHandle(
120-
// Using new Function to avoid babel transpiling the import
121-
// @ts-expect-error pptr's types don't like new Function
122-
new Function(
123-
'argsString',
124-
'element',
125-
`return import("http://localhost:${port}/@test-mule/dom-testing-library")
116+
const result: JSHandle<Element | Element[] | DTLError | null> =
117+
await page
118+
.evaluateHandle(
119+
// Using new Function to avoid babel transpiling the import
120+
// @ts-expect-error pptr's types don't like new Function
121+
new Function(
122+
'argsString',
123+
'element',
124+
`return import("http://localhost:${port}/@test-mule/dom-testing-library")
126125
.then(async ({ reviveElementsInString, printElement, addToElementCache, ...dtl }) => {
127126
const deserializedArgs = JSON.parse(argsString, (key, value) => {
128127
if (value.__serialized === 'RegExp')
@@ -148,14 +147,14 @@ export const getQueriesForElement = (
148147
return { failed: true, messageWithElementsRevived, messageWithElementsStringified }
149148
}
150149
})`,
151-
),
152-
serializedArgs,
153-
element?.asElement() ||
154-
(await page
155-
.evaluateHandle(() => document)
156-
.catch(handleExecutionAfterTestFinished)),
157-
)
158-
.catch(handleExecutionAfterTestFinished);
150+
),
151+
serializedArgs,
152+
element?.asElement() ||
153+
(await page
154+
.evaluateHandle(() => document)
155+
.catch(handleExecutionAfterTestFinished)),
156+
)
157+
.catch(handleExecutionAfterTestFinished);
159158

160159
const failed = await result.evaluate(
161160
(r) => typeof r === 'object' && r !== null && (r as DTLError).failed,
@@ -164,7 +163,8 @@ export const getQueriesForElement = (
164163
const resultProperties = Object.fromEntries(
165164
await result.getProperties(),
166165
);
167-
const messageWithElementsStringified = (await resultProperties.messageWithElementsStringified.jsonValue()) as any;
166+
const messageWithElementsStringified =
167+
(await resultProperties.messageWithElementsStringified.jsonValue()) as any;
168168
const messageWithElementsRevived = await jsHandleToArray(
169169
resultProperties.messageWithElementsRevived,
170170
);
@@ -186,7 +186,7 @@ export const getQueriesForElement = (
186186
});
187187
const props = await result.getProperties();
188188
for (const [key, value] of props.entries()) {
189-
array[(key as any) as number] = value;
189+
array[key as any as number] = value;
190190
}
191191

192192
return array;

src/user-util/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ${el}`;
2929
let opacity = Number(style.opacity);
3030
let opacityEl: Element | null = el;
3131
while (opacity && (opacityEl = opacityEl.parentElement)) {
32-
opacity *= (getComputedStyle(opacityEl).opacity as any) as number;
32+
opacity *= getComputedStyle(opacityEl).opacity as any as number;
3333
}
3434

3535
if (opacity < 0.05) {

src/user.ts

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -328,36 +328,39 @@ const runWithUtils = <Args extends any[], Return extends unknown>(
328328
* When code that is evaluated in the browser returns {error: ...}, this function causes an error to be thrown in Node.
329329
* This is better than just throwing directly from the browser code because that would cause the error to be wrapped by Puppeteer's EvaluationError, which causes a confusing stack trace.
330330
*/
331-
const throwBrowserError = (func: (...params: any) => any) => async (
332-
result: JSHandle,
333-
) => {
334-
const resultJSON = (await result.jsonValue()) as any;
335-
if (resultJSON?.error) {
336-
let err;
337-
if (typeof resultJSON.error === 'string') {
338-
err = new Error(resultJSON.error);
339-
} else {
340-
const errorProp = await result.getProperty('error');
341-
const errorProperties = Object.fromEntries(
342-
await errorProp.getProperties(),
343-
);
344-
// eslint-disable-next-line @cloudfour/typescript-eslint/no-unnecessary-condition
345-
if (errorProperties.msgWithStringEls && errorProperties.msgWithLiveEls) {
346-
err = new Error(
347-
(await errorProperties.msgWithStringEls.jsonValue()) as any,
348-
);
349-
// @ts-expect-error messageForBrowser is a custom thing
350-
err.messageForBrowser = await jsHandleToArray(
351-
errorProperties.msgWithLiveEls,
352-
);
331+
const throwBrowserError =
332+
(func: (...params: any) => any) => async (result: JSHandle) => {
333+
const resultJSON = (await result.jsonValue()) as any;
334+
if (resultJSON?.error) {
335+
let err;
336+
if (typeof resultJSON.error === 'string') {
337+
err = new Error(resultJSON.error);
353338
} else {
354-
err = new Error((await errorProp.jsonValue()) as any);
339+
const errorProp = await result.getProperty('error');
340+
const errorProperties = Object.fromEntries(
341+
await errorProp.getProperties(),
342+
);
343+
if (
344+
// eslint-disable-next-line @cloudfour/typescript-eslint/no-unnecessary-condition
345+
errorProperties.msgWithStringEls &&
346+
// eslint-disable-next-line @cloudfour/typescript-eslint/no-unnecessary-condition
347+
errorProperties.msgWithLiveEls
348+
) {
349+
err = new Error(
350+
(await errorProperties.msgWithStringEls.jsonValue()) as any,
351+
);
352+
// @ts-expect-error messageForBrowser is a custom thing
353+
err.messageForBrowser = await jsHandleToArray(
354+
errorProperties.msgWithLiveEls,
355+
);
356+
} else {
357+
err = new Error((await errorProp.jsonValue()) as any);
358+
}
355359
}
356-
}
357360

358-
removeFuncFromStackTrace(err, func);
359-
throw err;
360-
}
361+
removeFuncFromStackTrace(err, func);
362+
throw err;
363+
}
361364

362-
return result;
363-
};
365+
return result;
366+
};

0 commit comments

Comments
 (0)