Jest-puppeteer: Cannot read property 'removeListener' of undefined

Created on 27 Jan 2019  ·  2Comments  ·  Source: smooth-code/jest-puppeteer

🐛 Bug Report

Upon trying to run my tests, I'm presented with what seems to be the same error from #72, #116. Upon running my tests, I get the error

  ● Test suite failed to run
    TypeError: Cannot read property 'removeListener' of undefined
      at PuppeteerEnvironment.teardown (../../node_modules/jest-environment-puppeteer/lib/PuppeteerEnvironment.js:126:22)

To Reproduce

Steps to reproduce the behavior:

  • I'm using both a global-setup.js and global-teardown.js
  • Check out the linked repo (below). From project root, run yarn to install deps then jest to kick off the test suite. Error pops up almost immediately.

Expected behavior

I expect my tests to run and not get this error.

Link to repo

https://github.com/imjared/jest-puppeteer-issue-repro

## System:
 - OS: macOS 10.14.2
 - CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
 - Memory: 2.22 GB / 16.00 GB
 - Shell: 5.3 - /bin/zsh
## Binaries:
 - Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
 - Yarn: 1.12.3 - /usr/local/bin/yarn
 - npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
 - Watchman: 4.9.0 - /usr/local/bin/watchman
bug 🐛

Most helpful comment

hi,@imjared

It seems that you have not added a globalSetup of jest-environment-puppeteer to the global-setup file.
If you don't need globalSetup, don't specify it in jest.config.

This PR may solve the problem

https://github.com/imjared/jest-puppeteer-issue-repro/pull/1

All 2 comments

hi,@imjared

It seems that you have not added a globalSetup of jest-environment-puppeteer to the global-setup file.
If you don't need globalSetup, don't specify it in jest.config.

This PR may solve the problem

https://github.com/imjared/jest-puppeteer-issue-repro/pull/1

nailed it @xiaoyuhen. Thanks for the oversight there and apologies for the false alarm bug report here!

image

Can confirm that the changes work as expected. I think my confusion was that I used the examples from the jest-dev-server readme rather than the main package.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexander-elgin picture alexander-elgin  ·  4Comments

macabeus picture macabeus  ·  4Comments

Greg-oliver99 picture Greg-oliver99  ·  4Comments

undrafted picture undrafted  ·  4Comments

songguohfut picture songguohfut  ·  6Comments