expect-puppeteer can't use the "page" object -- any "expect" dies with "[object Object] is not supported"
See original GitHub issue🐛 Bug Report
To Reproduce
Using the demo test from the README (slightly modified to absolutely ensure a correct import):
import expectPP from 'expect-puppeteer'
describe('Google', () => {
beforeAll(async () => {
await page.goto('https://google.com')
})
it('should display "google" text on page', async () => {
await expectPP(page).toMatch('google')
})
})
The test as written fails:
● Google › should display "google" text on page
[object Object] is not supported
7 |
8 | it('should display "google" text on page', async () => {
> 9 | await expectPP(page).toMatch('google')
| ^
10 | })
11 | })
at expectPuppeteer (node_modules/expect-puppeteer/lib/index.js:105:13)
at Object.<anonymous> (__tests__/google.js:9:11)
I dug in to expect-puppeteer/lib/utils.js
a little bit and expect-puppeteer expects a “Page” object but the object appears to be called “CDPPage”. However, I modified getPuppeteerType and getContext to accept “CDPPage” and that does not solve the problem.
Expected behavior
The test should run as normal using the page
object provided.
Link to repl or repo (highly encouraged)
https://gitlab.com/simberman/ppexpect_problem
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: Windows 10 10.0.19043
- CPU: (16) x64 Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz
- Memory: 3.63 GB / 15.93 GB
## Binaries:
- Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
- npm: 8.18.0 - C:\Program Files\nodejs\npm.CMD
## npmPackages:
- jest-puppeteer: ^6.1.1 => 6.1.1
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:6
Top Results From Across the Web
Issues · smooth-code/jest-puppeteer - GitHub
expect-puppeteer can't use the "page" object -- any "expect" dies with "[object Object] is not supported" bug good first issue Good for newcomers....
Read more >Page Object Model structure for a complex application
I want to use the famed Page Object Model, where in I have separated the locators, page methods in separate files and I'm...
Read more >How many of you use Cypress ? : r/javascript - Reddit
The last time I checked, the Cypress team is quite adamant about not using page objects, so that might be a hard sell...
Read more >Getting to Know Puppeteer Using Practical Examples
Puppeteer is a project from the Google Chrome team which enables us to control a Chrome (or any other Chrome DevTools Protocol based ......
Read more >Sennheiser MobileConnect Station
You are not allowed to use the Software to control or to administrate any hardware ... under Section 2) in object code or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is also preventing us to upgrade
puppeteer
from 17 to 18 or 19. Any news on this?Yes if someone wants to continue that PR and get the tests passing it can be merged.