jest: jest: document is not defined & puppeteer

πŸ› 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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (3 by maintainers)

Commits related to this issue

Most upvoted comments

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

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

@thymikee to write

/**
 * @jest-environment jsdom
 */

in every unit test - it is little bit annoing but it partially solves the problem

We also have whole documentation on how to separate your tests and use different environments for different needs (e.g. server and browser). Please spend some time reading it before raging on the issue tracker πŸ˜ƒ

@SimenB I know it, but question was: how to have testEnvironment at the same time to be JSDOM and Node? We need not only one type of tests - we need them both at the same time

2018-07-10 11 15 28