question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created a year ago
  • Reactions:6
  • Comments:6

github_iconTop GitHub Comments

1reaction
jpreynatcommented, Nov 19, 2022

This is also preventing us to upgrade puppeteer from 17 to 18 or 19. Any news on this?

0reactions
UziTechcommented, Nov 19, 2022

Yes if someone wants to continue that PR and get the tests passing it can be merged.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found