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: Cannot read property 'bind' of undefined #11720

Closed
hansiemithun opened this issue Aug 3, 2021 · 9 comments
Closed

TypeError: Cannot read property 'bind' of undefined #11720

hansiemithun opened this issue Aug 3, 2021 · 9 comments

Comments

@hansiemithun
Copy link

hansiemithun commented Aug 3, 2021

🐛 Bug Report

 Test suite failed to run

          TypeError: Cannot read property 'bind' of undefined
      at jestAdapter (node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:30:56)

To Reproduce

Steps to reproduce the behavior:

Dependencies
"jest": "^27.0.6",
"ts-jest": "^27.0.4",

Jest configuration
"jest": {
"runner": "@jest-runner/electron",
"testEnvironment": "@jest-runner/electron/environment",
"moduleNameMapper": {
"\.(jpg|jpeg|png|gif|svg|yaml)$": "/mocks/fileMock.js",
"\.(css|less|scss)$": "/mocks/styleMock.js"
},
"modulePaths": [
"/src/",
"node_modules"
],
"preset": "ts-jest",
"transform": {
"^.+\.(ts|tsx)?$": "ts-jest",
"^.+\.(js|jsx)$": "babel-jest"
}
},

Babelrc
{
"presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
"plugins": [["@babel/plugin-proposal-decorators", { "legacy": true }],["@babel/plugin-proposal-class-properties", { "loose": true }]]
}

Expected behavior

The jest looks broken with latest upgrades and there is no proper fix on a particular issue. Every fix leading to one more bug open.

So far these many errors have been identified.

  1. Import Errors - Jest not able to import
  2. Cannot read property 'app' of undefined Use a regex that really never matches #22
  3. TypeError: Jest: a transform must export a process function. Outdated docs on webpack integration #2675
  4. TypeError: Cannot read property 'bind' of undefined jest

Link to repl or repo (highly encouraged)

envinfo

**Node version: **
v12.17.0

**NPM version: **
6.14.4

runtime.setGlobalsForRuntime is undefined hence bind is also undefined. Should we set setGlobalsForRuntime or is this because of some missing config?


@sigveio
Copy link
Contributor

sigveio commented Aug 3, 2021

Hi @hansiemithun,

It would be helpful if you could provide either a repl.it demo or a minimal repository on GitHub that demonstrates the issue. See https://stackoverflow.com/help/minimal-reproducible-example for information on how to create good reproductions.

@hansiemithun
Copy link
Author

This is the similar issue i am talking about and it looks like regression which i can also confirm: #10591.

@hansiemithun
Copy link
Author

The thread says it has got fix here: https://github.com/facebook/jest/releases/tag/v26.5.1. But this version is unavailable from: https://www.npmjs.com/package/jest-runtime/v/26.5.2

@sigveio
Copy link
Contributor

sigveio commented Aug 3, 2021

Please help us help you, by providing a minimal reproduction that demonstrates the problem in the simplest way possible. Otherwise it's hard for us to test it and understand what the issue might be. =)

So far you have only provided some configs, which do not tell us that much. If you are not sure what a minimal reproduction is or how to make it, the stackoverflow link I posted above is a great resource.

@hansiemithun
Copy link
Author

hansiemithun commented Aug 3, 2021

Sure definitely ill provide a reproducible link, meanwhile if i can at-least hear how to download https://github.com/facebook/jest/releases/tag/v26.5.1 would be of great help as its not published. When i try to install via command line: npm i https://github.com/facebook/jest/tarball/v26.5.1 -D, it says npm ERR! Can't install https://github.com/facebook/jest/tarball/v26.5.1: Missing package name. Because this particular version has the conditional check on the setGlobalsForRuntime and that is what i need. I am still not sure about the root cause for this, but this can unblock us.

@sigveio
Copy link
Contributor

sigveio commented Aug 3, 2021

Thank you. :-) It looks like that particular tag was just a test and never released, so it is missing the package name and various other things from the package.json. Probably your best bet would be to download it to a local folder, fix that (add the name and version properties) and use npm install with the local folder path instead of the URL.

But we cannot determine if it is a regression before you can demonstrate that there is a bug in the current version. So if I were you, I would first focus on creating a reproduction showing the error with a minimal setup/configuration. Because that process will also help you narrow down the cause.

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 17, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2023
@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 Apr 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants