jest-puppeteer icon indicating copy to clipboard operation
jest-puppeteer copied to clipboard

[expect-puppeteer] Puppeteer v17 incompatibility

Open swissspidy opened this issue 3 years ago • 1 comments

🐛 Bug Report

expect-puppeteer uses ElementHandle.executionContext() to get the page object from a given ElementHandle:

https://github.com/smooth-code/jest-puppeteer/blob/a7b569351fc6be97f6e24b6f2967d47ddd6f4329/packages/expect-puppeteer/src/utils.js#L24-L30

In https://github.com/puppeteer/puppeteer/pull/8844, which was released as part of Puppeteer v17, the execution context has been marked internal, so this access is no longer possible.

To Reproduce

If you do something like this, this will break with Puppeteer v17:

const elementHandle = await expect(page).toMatchElement('button');
expect(elementHandle).toClick();

Getting errors like this:

TypeError: executionContext.frame is not a function

Expected behavior

There needs to be either a workaround to ensure compatibility or a new major release removing support for this usage if this is no longer possible.

Link to repl or repo (highly encouraged)

Please provide a minimal repository on GitHub.

Issues without a reproduction link are likely to stall.

Run npx envinfo --system --binaries --npmPackages expect-puppeteer,jest-dev-server,jest-environment-puppeteer,jest-puppeteer,spawnd --markdown --clipboard

Paste the results here:

## System:
 - OS: macOS 12.5.1
 - CPU: (10) arm64 Apple M1 Pro
 - Memory: 329.19 MB / 32.00 GB
 - Shell: 3.2.57 - /bin/bash
## Binaries:
 - Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
 - npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm

swissspidy avatar Aug 31 '22 17:08 swissspidy

The new recommended approach in v17.1.0 is to use ElementHandle.frame() directly, see https://github.com/puppeteer/puppeteer/pull/8875. It should be released soon.

swissspidy avatar Sep 01 '22 07:09 swissspidy

The last version (v7) is compatible to Puppeteer v19.

gregberge avatar Feb 04 '23 16:02 gregberge