Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"TypeError: global.context.isIncognito is not a function" after upgrading to puppeteer 23.0.1 #586

Closed
replete opened this issue Aug 7, 2024 · 4 comments · Fixed by #588

Comments

@replete
Copy link

replete commented Aug 7, 2024

🐛 Bug Report

After upgrading to puppeteer 23.0.1, tests fail with

> node --experimental-vm-modules --disable-warning=ExperimentalWarning ./node_modules/jest/bin/jest.js --verbose --runInBand --openHandlesTimeout=2000

  console.log
    BrowserSync running at: http://localhost:3003

      at BrowserSync.log [as cb] (jest.setup.js:46:12)

 FAIL  __tests__/e2e.tests.js
  ● Test suite failed to run

    TypeError: global.context.isIncognito is not a function

      at closeContext (node_modules/jest-environment-puppeteer/dist/index.js:210:24)
      at closeAll (node_modules/jest-environment-puppeteer/dist/index.js:222:11)
      at PuppeteerEnvironment.teardown (node_modules/jest-environment-puppeteer/dist/index.js:259:9)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        6.276 s
Ran all test suites.

I thought this might be related to #585 so I tested without --runInBand but the behaviour persists. I'm guessing this is a breaking change in puppeteer so I'm reporting this.

To Reproduce

  • git clone https://github.com/replete/biscuitman
  • npm install
  • npm run test - tests pass
  • npx ncu -u (update packages)
  • npm install
  • npm run test

Expected behavior

Presumably this is a breaking change in puppeteer, which just released Firefox support.

Link to repl or repo (highly encouraged)

See above

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 14.5
 - CPU: (12) x64 11th Gen Intel(R) Core(TM) i5-11400F @ 2.60GHz
 - Memory: 3.16 GB / 32.00 GB
 - Shell: 5.2.26 - /usr/local/bin/bash
## Binaries:
 - Node: 20.15.0 - /usr/local/bin/node
 - Yarn: 1.22.15 - /usr/local/bin/yarn
 - npm: 10.7.0 - /usr/local/bin/npm
## npmPackages:
 - jest-puppeteer: ^10.0.1 => 10.0.1
@cpiber
Copy link

cpiber commented Aug 7, 2024

I managed to temporarily circumvent it by hacking the function in in a custom environment:

import { TestEnvironment } from 'jest-environment-puppeteer';

class Env extends TestEnvironment {
  async setup() {
    await super.setup();

    if (this.global.context.isIncognito === undefined) {
      this.global.context.isIncognito = () => false;
    }
  }
}

export default Env;

Proper solution very much appreciated

@replete
Copy link
Author

replete commented Aug 8, 2024

@jamesgpearce
Copy link

Took a stab at a (two character) fix in #587

@replete
Copy link
Author

replete commented Aug 18, 2024

@gregberge Thank you for fixing this Greg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants