From 707f97bc8acc6b67bf2c438c3946c44c817820cd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 8 Jul 2021 13:36:19 -0700 Subject: [PATCH] [Requires manual changes] Update dependency puppeteer to ^10.1.0 (#137) Co-authored-by: Renovate Bot Co-authored-by: Caleb Eby --- .changeset/stupid-mails-switch.md | 5 +++++ README.md | 30 +++++++++++++++--------------- package-lock.json | 14 +++++++------- package.json | 2 +- 4 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 .changeset/stupid-mails-switch.md diff --git a/.changeset/stupid-mails-switch.md b/.changeset/stupid-mails-switch.md new file mode 100644 index 00000000..3029e962 --- /dev/null +++ b/.changeset/stupid-mails-switch.md @@ -0,0 +1,5 @@ +--- +'pleasantest': minor +--- + +Update puppeteer to [`10.1.0`](https://github.com/puppeteer/puppeteer/blob/main/CHANGELOG.md#1010-2021-06-29) diff --git a/README.md b/README.md index af1eb67a..389eba77 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ test( ); ``` -Sometimes, you may want to traverse the DOM tree to find parent, sibling, or descendant elements. Pleasantest 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=v10.0.0&show=api-elementhandleevaluatepagefunction-args) to run code in the browser using an `ElementHandle` returned from a query: +Sometimes, you may want to traverse the DOM tree to find parent, sibling, or descendant elements. Pleasantest 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=v10.1.0&show=api-elementhandleevaluatepagefunction-args) to run code in the browser using an `ElementHandle` returned from a query: ```js import { withBrowser } from 'pleasantest'; @@ -219,7 +219,7 @@ test( You can use the [User API](#user-api-pleasantestuser) to perform actions in the browser. -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=v10.0.0&show=api-class-elementhandle) +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=v10.1.0&show=api-class-elementhandle) ```js test( @@ -348,7 +348,7 @@ Call Signatures: `WithBrowserOpts`: - `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`. -- `device`: Device Object [described here](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pageemulateoptions). +- `device`: Device Object [described here](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pageemulateoptions). By default, `withBrowser` will launch a headless Chromium browser. You can tell it to instead launch a headed (visible) browser by chaining `.headed`: @@ -385,7 +385,7 @@ The `devices` import from `pleasantest` is re-exported from Puppeteer, [here is #### `PleasantestContext.screen` -The `PleasantestContext` 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 Pleasantest compared to Testing Library: in Pleasantest, 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=v10.0.0&show=api-class-elementhandle)'s from Puppeteer. +The `PleasantestContext` 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 Pleasantest compared to Testing Library: in Pleasantest, 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=v10.1.0&show=api-class-elementhandle)'s from Puppeteer. List of queries attached to screen object: @@ -436,7 +436,7 @@ test( #### `PleasantestContext.page` -The `PleasantestContext` object exposes the `page` property, which is an instance of Puppeteer's [`Page` class](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-class-page). This will most often be used for navigation ([`page.goto`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagegotourl-options)), but you can do anything with it that you can do with puppeteer. +The `PleasantestContext` object exposes the `page` property, which is an instance of Puppeteer's [`Page` class](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-class-page). This will most often be used for navigation ([`page.goto`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagegotourl-options)), but you can do anything with it that you can do with puppeteer. ```js import { withBrowser } from 'pleasantest'; @@ -469,7 +469,7 @@ The user API allows you to perform actions on behalf of the user. If you have us #### `PleasantestUser.click(element: ElementHandle, options?: { force?: boolean }): Promise` -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=v10.0.0&show=api-elementhandleclickoptions). The difference is that `PleasantestUser.click` checks that the target element is an element that actually can be clicked before clicking it! +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=v10.1.0&show=api-elementhandleclickoptions). The difference is that `PleasantestUser.click` checks that the target element is an element that actually can be clicked before clicking it! **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 }`. @@ -498,7 +498,7 @@ The `delay` option controls the amount of time (ms) between keypresses (defaults **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 }`. -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=v10.0.0&show=api-pagekeyboard) +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=v10.1.0&show=api-pagekeyboard) | Text string | Key | Notes | | -------------- | ---------- | --------------------------------------------------------------------------------------- | @@ -546,7 +546,7 @@ test( #### `PleasantestUser.selectOptions(element: ElementHandle, values: ElementHandle | ElementHandle[] | string[] | string, options?: { force?: boolean }): Promise` -Selects the specified option(s) of a `` element. Values can be passed as either strings (option values) or as [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-class-elementhandle) references to elements. +Selects the specified option(s) of a `` element. Values can be passed as either strings (option values) or as [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-class-elementhandle) references to elements. **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 }`. @@ -596,7 +596,7 @@ test( ); ``` -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=v10.0.0&show=api-class-jshandle) or an [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-class-elementhandle). The arguments can be received in the browser as parameters to a default-exported function: +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=v10.1.0&show=api-class-jshandle) or an [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-class-elementhandle). The arguments can be received in the browser as parameters to a default-exported function: ```js import { withBrowser } from 'pleasantest'; @@ -713,11 +713,11 @@ test( Pleasantest uses [Puppeteer](https://github.com/puppeteer/puppeteer) under the hood. You don't need to know how to use Puppeteer in order to use Pleasantest, but a little bit of Puppeteer knowledge might come in handy. Here are the parts of Puppeteer that are most helpful and relevant for Pleasantest: -### [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-class-elementhandle) +### [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-class-elementhandle) An `ElementHandle` is a reference to a DOM element in the browser. When you use one of the [Testing Library queries](#pleasantestcontextscreen) to find elements, the queries return promises that resolve to `ElementHandle`s. -You can use the [`.evaluate`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-elementhandleevaluatepagefunction-args) method to execute code in the browser, using a reference to the actual `Element` instance that the `ElementHandle` points to. For example, if you want to get the [`innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText) of an element: +You can use the [`.evaluate`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-elementhandleevaluatepagefunction-args) method to execute code in the browser, using a reference to the actual `Element` instance that the `ElementHandle` points to. For example, if you want to get the [`innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText) of an element: ```js import { withBrowser } from 'pleasantest'; @@ -737,7 +737,7 @@ test( ); ``` -Sometimes, you may want to return another `ElementHandle` from the browser callback, or some other value that can't be serialized in order to be transferred from the browser to Node. To do this, you can use the [`.evaluateHandle`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-elementhandleevaluatehandlepagefunction-args) method. In this example, we want to get a reference to the parent of an element. +Sometimes, you may want to return another `ElementHandle` from the browser callback, or some other value that can't be serialized in order to be transferred from the browser to Node. To do this, you can use the [`.evaluateHandle`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-elementhandleevaluatehandlepagefunction-args) method. In this example, we want to get a reference to the parent of an element. ```js import { withBrowser } from 'pleasantest'; @@ -755,13 +755,13 @@ test( ); ``` -### [`Page`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-class-page) +### [`Page`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-class-page) The page object is one of the properties that is passed into the test callback by [`withBrowser`](#withbrowser). You can use `.evaluate` and `.evaluateHandle` on `Page`, and those methods work the same as on `ElementHandle`. Here are some useful methods that are exposed through `Page`: -[`page.cookies`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagecookiesurls), [`page.emulateMediaFeatures`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pageemulatemediafeaturesfeatures), [`page.emulateNetworkConditions`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pageemulatenetworkconditionsnetworkconditions), [`page.evaluate`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pageevaluatepagefunction-args), [`page.evaluateHandle`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pageevaluatehandlepagefunction-args), [`page.exposeFunction`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pageexposefunctionname-puppeteerfunction), [`page.goBack`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagegobackoptions), [`page.goForward`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagegoforwardoptions), [`page.goto`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagegotourl-options), [`page.metrics`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagemetrics), [`page.reload`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagereloadoptions), [`page.screenshot`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagescreenshotoptions), [`page.setGeolocation`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagesetgeolocationoptions), [`page.setOfflineMode`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagesetofflinemodeenabled), [`page.setRequestInterception`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagesetrequestinterceptionvalue-cachesafe), [`page.title`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagetitle), [`page.url`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pageurl), [`page.waitForNavigation`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-pagewaitfornavigationoptions), [`page.browserContext().overridePermissions`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-browsercontextoverridepermissionsorigin-permissions), [`page.keyboard.press`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-keyboardpresskey-options), [`page.mouse.move`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-mousemovex-y-options), [`page.mouse.click`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-mouseclickx-y-options), [`page.touchscreen.tap`](https://pptr.dev/#?product=Puppeteer&version=v10.0.0&show=api-touchscreentapx-y) +[`page.cookies`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagecookiesurls), [`page.emulateMediaFeatures`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pageemulatemediafeaturesfeatures), [`page.emulateNetworkConditions`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pageemulatenetworkconditionsnetworkconditions), [`page.evaluate`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pageevaluatepagefunction-args), [`page.evaluateHandle`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pageevaluatehandlepagefunction-args), [`page.exposeFunction`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pageexposefunctionname-puppeteerfunction), [`page.goBack`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagegobackoptions), [`page.goForward`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagegoforwardoptions), [`page.goto`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagegotourl-options), [`page.metrics`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagemetrics), [`page.reload`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagereloadoptions), [`page.screenshot`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagescreenshotoptions), [`page.setGeolocation`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagesetgeolocationoptions), [`page.setOfflineMode`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagesetofflinemodeenabled), [`page.setRequestInterception`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagesetrequestinterceptionvalue-cachesafe), [`page.title`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagetitle), [`page.url`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pageurl), [`page.waitForNavigation`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-pagewaitfornavigationoptions), [`page.browserContext().overridePermissions`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-browsercontextoverridepermissionsorigin-permissions), [`page.keyboard.press`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-keyboardpresskey-options), [`page.mouse.move`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-mousemovex-y-options), [`page.mouse.click`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-mouseclickx-y-options), [`page.touchscreen.tap`](https://pptr.dev/#?product=Puppeteer&version=v10.1.0&show=api-touchscreentapx-y) ## Comparisons with other testing tools @@ -787,7 +787,7 @@ Jest uses [jsdom](https://github.com/jsdom/jsdom) and exposes browser-like globa ### [pptr-testing-library](https://github.com/testing-library/pptr-testing-library) + Jest -`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=v10.0.0&show=api-class-elementhandle)s, similarly to how Pleasantest does. +`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=v10.1.0&show=api-class-elementhandle)s, similarly to how Pleasantest does. - It does not make the [jest-dom](https://github.com/testing-library/jest-dom) assertions work with Puppeteer ElementHandles. - It does not manage the browser for you. You must manually set up and tear down the browser. diff --git a/package-lock.json b/package-lock.json index 362d437e..55f2941f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "esbuild": "^0.12.11", "mime": "^2.5.2", "postcss": "^8.3.5", - "puppeteer": "^10.0.0", + "puppeteer": "^10.1.0", "rollup": "^2.52.7", "rollup-plugin-postcss": "^4.0.0", "source-map": "0.8.0-beta.0" @@ -17907,9 +17907,9 @@ } }, "node_modules/puppeteer": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-10.0.0.tgz", - "integrity": "sha512-AxHvCb9IWmmP3gMW+epxdj92Gglii+6Z4sb+W+zc2hTTu10HF0yg6hGXot5O74uYkVqG3lfDRLfnRpi6WOwi5A==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-10.1.0.tgz", + "integrity": "sha512-bsyDHbFBvbofZ63xqF7hMhuKBX1h4WsqFIAoh1GuHr/Y9cewh+EFNAOdqWSkQRHLiBU/MY6M+8PUnXXjAPtuSg==", "hasInstallScript": true, "dependencies": { "debug": "4.3.1", @@ -35413,9 +35413,9 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "puppeteer": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-10.0.0.tgz", - "integrity": "sha512-AxHvCb9IWmmP3gMW+epxdj92Gglii+6Z4sb+W+zc2hTTu10HF0yg6hGXot5O74uYkVqG3lfDRLfnRpi6WOwi5A==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-10.1.0.tgz", + "integrity": "sha512-bsyDHbFBvbofZ63xqF7hMhuKBX1h4WsqFIAoh1GuHr/Y9cewh+EFNAOdqWSkQRHLiBU/MY6M+8PUnXXjAPtuSg==", "requires": { "debug": "4.3.1", "devtools-protocol": "0.0.883894", diff --git a/package.json b/package.json index bdf84892..cee46e0d 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "esbuild": "^0.12.11", "mime": "^2.5.2", "postcss": "^8.3.5", - "puppeteer": "^10.0.0", + "puppeteer": "^10.1.0", "rollup": "^2.52.7", "rollup-plugin-postcss": "^4.0.0", "source-map": "0.8.0-beta.0"