Skip to content

Commit be9eef7

Browse files
authored
Update puppeteer to v9.1.1 (#61)
1 parent 2bc0ea2 commit be9eef7

5 files changed

Lines changed: 38 additions & 29 deletions

File tree

.changeset/tasty-boats-speak.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'test-mule': minor
3+
---
4+
5+
Update puppeteer to v9.1.1
6+
7+
Chromium version is now 91.0.4469.0 (r869685)

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ test(
167167
);
168168
```
169169

170-
Sometimes, you may want to traverse the DOM tree to find parent, sibling, or descendant elements. Test Mule communicates asynchronously with the browser, so you do not have synchronous access to the DOM tree. You can use [`ElementHandle.evaluate`](https://pptr.dev/#?product=Puppeteer&version=v7.1.0&show=api-elementhandleevaluatepagefunction-args) to run code in the browser using an `ElementHandle` returned from a query:
170+
Sometimes, you may want to traverse the DOM tree to find parent, sibling, or descendant elements. Test Mule communicates asynchronously with the browser, so you do not have synchronous access to the DOM tree. You can use [`ElementHandle.evaluate`](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-elementhandleevaluatepagefunction-args) to run code in the browser using an `ElementHandle` returned from a query:
171171

172172
```js
173173
import { withBrowser } from 'test-mule';
@@ -209,7 +209,7 @@ test(
209209

210210
You can use the [User API](#user-api-testmuleuser) to perform actions in the browser.
211211

212-
If the User API is missing a method that you need, you can instead use [methods on `ElementHandle`s directly](https://pptr.dev/#?product=Puppeteer&version=v7.0.1&show=api-class-elementhandle)
212+
If the User API is missing a method that you need, you can instead use [methods on `ElementHandle`s directly](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-class-elementhandle)
213213

214214
```js
215215
test(
@@ -316,7 +316,7 @@ Call Signatures:
316316
`WithBrowserOpts`:
317317

318318
- `headless`: `boolean`, default `true`: Whether to open a headless (not visible) browser. If you use the `withBrowser.headed` chain, that will override the value of `headless`.
319-
- `device`: Device Object [described here](https://pptr.dev/#?product=Puppeteer&version=v7.1.0&show=api-pageemulateoptions).
319+
- `device`: Device Object [described here](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-pageemulateoptions).
320320

321321
By default, `withBrowser` will launch a headless Chromium browser. You can tell it to instead launch a headed (visible) browser by chaining `.headed`:
322322

@@ -353,7 +353,7 @@ The `devices` import from `test-mule` is re-exported from Puppeteer, you can see
353353

354354
#### `TestMuleContext.screen`
355355

356-
The `TestMuleContext` object exposes the [`screen`](https://testing-library.com/docs/queries/about/#screen) property, which is an [object with Testing Library queries pre-bound to the document](https://testing-library.com/docs/queries/about/#screen). All of the [Testing Library queries](https://testing-library.com/docs/queries/about#overview) are available. These are used to find elements in the DOM for use in your tests. There is one difference in how you use the queries in Test Mule compared to Testing Library: in Test Mule, all queries must be `await`ed to handle the time it takes to communicate with the browser. In addition, since your tests are running in Node, the queries return Promises that resolve to [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v7.0.1&show=api-class-elementhandle)'s from Puppeteer.
356+
The `TestMuleContext` object exposes the [`screen`](https://testing-library.com/docs/queries/about/#screen) property, which is an [object with Testing Library queries pre-bound to the document](https://testing-library.com/docs/queries/about/#screen). All of the [Testing Library queries](https://testing-library.com/docs/queries/about#overview) are available. These are used to find elements in the DOM for use in your tests. There is one difference in how you use the queries in Test Mule compared to Testing Library: in Test Mule, all queries must be `await`ed to handle the time it takes to communicate with the browser. In addition, since your tests are running in Node, the queries return Promises that resolve to [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-class-elementhandle)'s from Puppeteer.
357357

358358
```js
359359
import { withBrowser } from 'test-mule';
@@ -394,7 +394,7 @@ test(
394394

395395
#### `TestMuleContext.page`
396396

397-
The `TestMuleContext` object exposes the `page` property, which is an instance of Puppeteer's [`Page` class](https://pptr.dev/#?product=Puppeteer&version=v7.0.1&show=api-class-page). This will most often be used for navigation ([`page.goto`](https://pptr.dev/#?product=Puppeteer&version=v7.0.1&show=api-pagegotourl-options)), but you can do anything with it that you can do with puppeteer.
397+
The `TestMuleContext` object exposes the `page` property, which is an instance of Puppeteer's [`Page` class](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-class-page). This will most often be used for navigation ([`page.goto`](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-pagegotourl-options)), but you can do anything with it that you can do with puppeteer.
398398

399399
```js
400400
import { withBrowser } from 'test-mule';
@@ -425,7 +425,7 @@ The user API allows you to perform actions on behalf of the user. If you have us
425425
426426
#### `TestMuleUser.click(element: ElementHandle, options?: { force?: boolean }): Promise<void>`
427427

428-
Clicks an element, if the element is visible and the center of it is not covered by another element. If the center of the element is covered by another element, an error is thrown. This is a thin wrapper around Puppeteer's [`ElementHandle.click` method](https://pptr.dev/#?product=Puppeteer&version=v7.0.1&show=api-elementhandleclickoptions). The difference is that `TestMuleUser.click` checks that the target element is an element that actually can be clicked before clicking it!
428+
Clicks an element, if the element is visible and the center of it is not covered by another element. If the center of the element is covered by another element, an error is thrown. This is a thin wrapper around Puppeteer's [`ElementHandle.click` method](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-elementhandleclickoptions). The difference is that `TestMuleUser.click` checks that the target element is an element that actually can be clicked before clicking it!
429429

430430
**Actionability checks**: It refuses to click elements that are not [**attached**](#attached) or not [**visible**](#visible). You can override the visibility check by passing `{ force: true }`.
431431

@@ -454,7 +454,7 @@ The `delay` option controls the amount of time (ms) between keypresses (defaults
454454

455455
**Actionability checks**: It refuses to type into elements that are not [**attached**](#attached) or not [**visible**](#visible). You can override the visibility check by passing `{ force: true }`.
456456

457-
In the text, you can pass special commands using curly brackets to trigger special keypresses, similar to [user-event](https://github.com/testing-library/user-event#special-characters) and [Cypress](https://docs.cypress.io/api/commands/type.html#Arguments). Open an issue if you want more commands available here! Note: If you want to simulate individual keypresses independent from a text field, you can use Puppeteer's [page.keyboard API](https://pptr.dev/#?product=Puppeteer&version=v7.1.0&show=api-pagekeyboard)
457+
In the text, you can pass special commands using curly brackets to trigger special keypresses, similar to [user-event](https://github.com/testing-library/user-event#special-characters) and [Cypress](https://docs.cypress.io/api/commands/type.html#Arguments). Open an issue if you want more commands available here! Note: If you want to simulate individual keypresses independent from a text field, you can use Puppeteer's [page.keyboard API](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-pagekeyboard)
458458

459459
| Text string | Key | Notes |
460460
| -------------- | ---------- | --------------------------------------------------------------------------------------- |
@@ -503,7 +503,7 @@ test(
503503

504504
#### `TestMuleUser.selectOptions(element: ElementHandle, values: ElementHandle | ElementHandle[] | string[] | string, options?: { force?: boolean }): Promise<void>`
505505

506-
Selects the specified option(s) of a `<select>` or a `<select multiple>` element. Values can be passed as either strings (option values) or as [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v7.1.0&show=api-class-elementhandle) references to elements.
506+
Selects the specified option(s) of a `<select>` or a `<select multiple>` element. Values can be passed as either strings (option values) or as [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-class-elementhandle) references to elements.
507507

508508
**Actionability checks**: It refuses to select in elements that are not [**attached**](#attached) or not [**visible**](#visible). You can override the visibility check by passing `{ force: true }`.
509509

@@ -553,7 +553,7 @@ test(
553553
);
554554
```
555555

556-
To pass variables from the test environment into the browser, you can pass them as the 2nd parameter. Note that they must either be JSON-serializable or they can be a [`JSHandle`](https://pptr.dev/#?product=Puppeteer&version=v7.1.0&show=api-class-jshandle) or an [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v7.1.0&show=api-class-elementhandle). The arguments can be received in the browser as parameters to a default-exported function:
556+
To pass variables from the test environment into the browser, you can pass them as the 2nd parameter. Note that they must either be JSON-serializable or they can be a [`JSHandle`](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-class-jshandle) or an [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-class-elementhandle). The arguments can be received in the browser as parameters to a default-exported function:
557557

558558
```js
559559
import { withBrowser } from 'test-mule';
@@ -685,7 +685,7 @@ Jest uses [jsdom](https://github.com/jsdom/jsdom) and exposes browser-like globa
685685

686686
### [pptr-testing-library](https://github.com/testing-library/pptr-testing-library) + Jest
687687

688-
`pptr-testing-library` makes versions of the [Testing Library](https://testing-library.com) queries that work with Puppeteer's [ElementHandle](https://pptr.dev/#?product=Puppeteer&version=v7.1.0&show=api-class-elementhandle)s, similarly to how Test Mule does.
688+
`pptr-testing-library` makes versions of the [Testing Library](https://testing-library.com) queries that work with Puppeteer's [ElementHandle](https://pptr.dev/#?product=Puppeteer&version=v9.1.1&show=api-class-elementhandle)s, similarly to how Test Mule does.
689689

690690
- It does not make the [jest-dom](https://github.com/testing-library/jest-dom) assertions work with Puppeteer ElementHandles.
691691
- It does not manage the browser for you. You must manually set up and tear down the browser.

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"dependencies": {
5050
"@types/testing-library__jest-dom": "^5.9.5",
51-
"puppeteer": "^7.1.0",
51+
"puppeteer": "^9.1.1",
5252
"source-map": "^0.7.3",
5353
"vite": "2.0.0-beta.52"
5454
},

src/jest-dom/to-have-style.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ export function toHaveStyle(htmlElement, css) {
6767
);
6868
}
6969

70-
const receivedSubset = Object.fromEntries(
71-
Object.entries(received).filter(([prop]) => prop in expected),
72-
);
70+
const receivedSubset = {};
71+
for (const prop of Object.keys(expected)) {
72+
receivedSubset[prop] = received[prop];
73+
}
74+
7375
return `${matcherHint}\n\n${this.utils.diff(
7476
printoutStyles(expected),
7577
printoutStyles(receivedSubset),

0 commit comments

Comments
 (0)