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

[Bug]: Cannot read property 'bind' of undefined #12182

Closed
PierreTurnbull opened this issue Dec 22, 2021 · 12 comments
Closed

[Bug]: Cannot read property 'bind' of undefined #12182

PierreTurnbull opened this issue Dec 22, 2021 · 12 comments

Comments

@PierreTurnbull
Copy link

PierreTurnbull commented Dec 22, 2021

Version

27.4.5

Steps to reproduce

Just run a simple test with nothing in it:

test("a", () => {
})

Expected behavior

Not getting this error, and the test should work.

Actual behavior

 FAIL  tests/jest/integration/promoCodeTemplateEditor.spec.js
  ● Test suite failed to run

    TypeError: Cannot read property 'bind' of undefined

      at Runtime._createJestObjectFor (node_modules/@jest/core/node_modules/jest-runtime/build/index.js:2193:46)
      at async TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)

Capture d’écran 2021-12-22 à 18 02 06

Additional context

The error doesn't show up on 26.6.3. I'll use this version until the bug is fixed.

Probably related issue: #11720

Environment

MacOS Big Sur v11.4
node v14.17.0
npm 6.14.13
jest 27.4.5
@bboydflo
Copy link

I've got the same after an update from jest version 27.4.3

@falconbin
Copy link

falconbin commented Dec 28, 2021

I have the same issue running in jenkins pipeline(probably ubuntu) for both version ^27.0.6 and ^27.4.5, but works in my local mac.

@SimenB
Copy link
Member

SimenB commented Dec 28, 2021

Please provide a reproduction we can run and see the error

@falconbin
Copy link

falconbin commented Dec 29, 2021

This issue happens on ubuntu, mac works fine. On ubuntu:

"jest": "^26.0.1",
"ts-jest": "^26.0.0",

works fine, but when I upgrade to

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

all the UT failed with error:
image

@SimenB
Copy link
Member

SimenB commented Dec 29, 2021

Again, a reproduction is needed

@falconbin
Copy link

I tried to reproduce the issue with minimum dependencies, but failed, everything works fine. And finally I found that my issue relates to mono repo as we use lerna.

@falconbin
Copy link

I tried to reproduce the issue with minimum dependencies, but failed, everything works fine. And finally I found that my issue relates to mono repo as we use lerna.

use yarn install instead of npm install solved my issue

@bboydflo
Copy link

bboydflo commented Jan 1, 2022

I am trying to identify the issue too. I am using jest in a npm@8 workspaces setup and I think the issue might be due to an update of a different package that depends on jest. I think one issue could be the resulting package-lock.json after I attempt to update a package that indirectly depends on an older version of jest. still investigating

UPDATE:
I've tried to update every dependency one by one and unfortunately the last one is jest and bumping it from 27.4.3 to 27.4.5 produces the same error. I run jest via ts-jest and I suspect it has to be something to do with how jest is being ran.

This is roughly my folder structure

+ root
    - package.json
    - package-lock.json
    + node_modules
    + packages
          + backend
          + frontend

The errors I get are from running tests inside the backend npm workspace.

My jest.config.js

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
};

and the error:

#20 16.75 FAIL src/utils/sanitization-utils.test.ts
#20 16.75   ● Test suite failed to run
#20 16.75
#20 16.75     TypeError: Cannot read property 'bind' of undefined
#20 16.75
#20 16.75       at Runtime._createJestObjectFor (../../node_modules/jest-runtime/build/index.js:2193:46)
#20 16.75       at async TestScheduler.scheduleTests (../../node_modules/@jest/core/build/TestScheduler.js:333:13)
#20 16.75       at async runJest (../../node_modules/@jest/core/build/runJest.js:404:19)

@laat
Copy link

laat commented Jan 3, 2022

I get this error with @types/jest-environment-puppeteer which has a dependency "jest-environment-node": ">=24 <=26".

repro

@bboydflo
Copy link

bboydflo commented Jan 5, 2022

@laat it seems to be working if you update to latest jest. I've just tried that.

updating to last version of jest (27.4.6) also fixed my issue.

@SimenB
Copy link
Member

SimenB commented Jan 5, 2022

Yeah, fixed by #12213

@SimenB SimenB closed this as completed Jan 5, 2022
@github-actions
Copy link

github-actions bot commented Feb 5, 2022

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 Feb 5, 2022
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

5 participants