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.

jest: document is not defined & puppeteer

See original GitHub issue

🐛 Bug Report

I have asked about the problem on stackoverflow for a week ago without any answer question (( I have configured jest as described jest for puppeteer but suddenly I’ve got the errot on usual test with document event listeners

To Reproduce

Steps to reproduce the behavior:

  • configure jest to work with puppeteer
  • write test for React App which is using event listeners

Expected behavior

pass test without errors

Link to repl or repo (highly encouraged)

https://github.com/budarin/react-ssr-bootstrap-project

Run `npx envinfo --preset jest

System:
    OS: macOS High Sierra 10.13.5
    CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  Binaries:
    Node: 10.6.0 - /usr/local/bin/node
yarn install v0.15.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 15.39s. - /usr/local/bin/yarn
    npm: 6.2.0-next.1 - /usr/local/bin/npm
  npmPackages:
    jest: ^23.3.0 => 23.3.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20

github_iconTop GitHub Comments

14reactions
SimenBcommented, Jul 10, 2018

Again, this isn’t a help forum - please ask questions on discord

6reactions
budarincommented, Jul 10, 2018

It’s not a question - it’s a bug to have only one type of tests!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why I got document is not defined error in puppeteer?
I think document would only be available within page.evaluate (according to puppeteer documentation ). Try: async function gallery(page) ...
Read more >
jest referenceerror: document is not defined - You.com | The AI ...
I get this error ReferenceError: AudioContext is not defined in all of my Jest tests. I don't use it in my test cases...
Read more >
How To Fix ReferenceError document is not defined ... - Isotropic
If you are trying to use the document object and receiving a ReferenceError: document is not defined error then there is a good...
Read more >
Using with puppeteer - Jest
Generating code coverage for test files using Puppeteer is currently not possible if your test uses page.$eval , page.
Read more >
How to fix ReferenceError: Document is not defined ... - Sabe.io
The most common reason for this error is because you're using Node. That is to say, you are trying to access the document...
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