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

Jest hangs indefinitely using external jsdom #2288

Closed
EnoahNetzach opened this issue Dec 11, 2016 · 11 comments
Closed

Jest hangs indefinitely using external jsdom #2288

EnoahNetzach opened this issue Dec 11, 2016 · 11 comments

Comments

@EnoahNetzach
Copy link
Contributor

EnoahNetzach commented Dec 11, 2016

Do you want to request a feature or report a bug?

A bug.

What is the current behavior?

Running tests with jsdom.jsdom(undefined, { url: URL }) hangs indefinitely.
If the CLI var --env=jsdom is provided, the number of tests in one single file that can use jsdom grows to ~12 (but this could be machine-dependent), but adding one additional test makes it hang once again.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can npm install and npm test.

git clone https://github.com/EnoahNetzach/jsdom-server-test, then follow the instructions on its README.

A real-life example is facebook/create-react-app#1187.

What is the expected behavior?

It shouldn't hang.

Run Jest again with --debug and provide the full configuration it prints. Please mention your node and npm version and operating system.

  • uname -mrs: Linux 4.8.8-200.fc24.x86_64 x86_64
  • npm --version: 3.10.8
  • node --version: v6.9.1
  • jest config:
{
  "collectCoverageFrom": [
    "src/**/*.{js,jsx}"
  ],
  "setupFiles": [
    "/home/netzach/Develop/jest-jsdom/node_modules/react-scripts/config/polyfills.js"
  ],
  "testPathIgnorePatterns": [
    "/home/netzach/Develop/jest-jsdom[/\\\\](build|docs|node_modules)[/\\\\]"
  ],
  "testEnvironment": "/home/netzach/Develop/jest-jsdom/node_modules/jest-environment-node/build/index.js",
  "testURL": "http:https://localhost",
  "transform": [
    [
      "^.+\\.(js|jsx)$",
      "/home/netzach/Develop/jest-jsdom/node_modules/react-scripts/config/jest/babelTransform.js"
    ],
    [
      "^.+\\.css$",
      "/home/netzach/Develop/jest-jsdom/node_modules/react-scripts/config/jest/cssTransform.js"
    ],
    [
      "^(?!.*\\.(js|jsx|css|json)$)",
      "/home/netzach/Develop/jest-jsdom/node_modules/react-scripts/config/jest/fileTransform.js"
    ]
  ],
  "transformIgnorePatterns": [
    "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
  ],
  "moduleNameMapper": [
    [
      "^react-native$",
      "react-native-web"
    ]
  ],
  "rootDir": "/home/netzach/Develop/jest-jsdom",
  "name": "-home-netzach-Develop-jest-jsdom",
  "testRunner": "/home/netzach/Develop/jest-jsdom/node_modules/jest-jasmine2/build/index.js",
  "automock": false,
  "bail": false,
  "browser": false,
  "cacheDirectory": "/tmp/jest",
  "coveragePathIgnorePatterns": [
    "/node_modules/"
  ],
  "coverageReporters": [
    "json",
    "text",
    "lcov",
    "clover"
  ],
  "expand": false,
  "globals": {},
  "haste": {
    "providesModuleNodeModules": []
  },
  "mocksPattern": "__mocks__",
  "moduleDirectories": [
    "node_modules"
  ],
  "moduleFileExtensions": [
    "js",
    "json",
    "jsx",
    "node"
  ],
  "modulePathIgnorePatterns": [],
  "noStackTrace": false,
  "notify": false,
  "preset": null,
  "resetMocks": false,
  "resetModules": false,
  "snapshotSerializers": [],
  "testPathDirs": [
    "/home/netzach/Develop/jest-jsdom"
  ],
  "testRegex": "(/__tests__/.*|\\.(test|spec))\\.jsx?$",
  "timers": "real",
  "useStderr": false,
  "verbose": null,
  "watch": false,
  "cache": true,
  "watchman": true
}

I'm not entirely sure this is a jest bug.
It could be a jsdom one, although I can reproduce this only with jest.

@cpojer
Copy link
Member

cpojer commented Dec 12, 2016

I don't think this is a Jest issue. We don't have any issues with jsdom starting to hang with thousands of tests, so it may be your test code. Is there a reason you cannot use Jest's provided jsdom environment?

@cpojer cpojer closed this as completed Dec 12, 2016
@EnoahNetzach
Copy link
Contributor Author

Is there a way to use jsom's internal calls (jsdom.env() or jsdom.jsdom()) from jest?

@cpojer
Copy link
Member

cpojer commented Dec 12, 2016

no, we don't expose those. It may be that your test is not cleaning up old instances of jsdom properly if you can only use 12 instances of jsdom.

@EnoahNetzach
Copy link
Contributor Author

EnoahNetzach commented Dec 12, 2016

it happens also with onlt one instance when I'm not passing --env=jsdom to jest, and it doesn't happen with mocha (I tried it just for being confident about it not being a jsdom problem, I still prefer jest a lot ❤️)

@cpojer
Copy link
Member

cpojer commented Dec 12, 2016

Yeah, there might be some issue somewhere but it isn't really something we actively support so we'll have to rely on your pull requests to help us out :)

@EnoahNetzach
Copy link
Contributor Author

understood, I'll try to find out that somewhere (if any) asap ;)

@Nitive
Copy link

Nitive commented Dec 12, 2016

@EnoahNetzach, recently has a problem when jest hangs after even jest --version. And everything was fine on CI. It was a problem with watchman which used inside jest.
Maybe this helps.

@EnoahNetzach
Copy link
Contributor Author

Thanks @Nitive, but for other tests it works just fine, and there is a "hard wired" number of tests it correctly handles (12), so I don't think it's a watchman problem.

@sattaman
Copy link

I've got a similar issue

@bugzpodder
Copy link

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

● PROMISE

      at Function.resolve (<anonymous>)
  at Object.<anonymous> (node_modules/lodash.sortby/index.js:1808:32)
  at Object.<anonymous> (node_modules/whatwg-url/lib/URLSearchParams-impl.js:2:22)

https://github.com/lodash/lodash/blob/d10b44bdef2b735865c493fbaec8687ec8998aef/.internal/getTag.js#L30

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants