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: this._getEventHandlerFor is not a function #2456

Closed
2 of 4 tasks
savv opened this issue Oct 1, 2020 · 4 comments
Closed
2 of 4 tasks

TypeError: this._getEventHandlerFor is not a function #2456

savv opened this issue Oct 1, 2020 · 4 comments

Comments

@savv
Copy link

savv commented Oct 1, 2020

Current behavior

This is a duplicate of #2436, but for a different environment. Downgrading to jest@24.9.0 makes this issue go away. Upgrading to >=25, makes this issue surface, but this seems to be because it seems I get an older version of https://github.com/jsdom/jsdom

Your environment

API

  • shallow
  • mount
  • render

Version

library version
enzyme ^3.11.0
react 16.13.1
react-dom ^16.13.1
react-test-renderer 16.13.1
adapter (below) ^1.15.5

Adapter

  • enzyme-adapter-react-16
@ljharb
Copy link
Member

ljharb commented Oct 5, 2020

What version of jsdom are you using? What exact error are you getting, on what code? What jest config are you using, including any setup code?

@savv
Copy link
Author

savv commented Oct 10, 2020

What version of jsdom are you using?

16.4.0

The thing that causes this is upgrading jest from 24.9.0 to 26.5.2 (or 25..). My guess is that it has to do with the transitive jsdom dependencies.

What exact error are you getting, on what code?

I get the same error as in #2436. It's unclear from the stack trace where it happens, but it seems to be during setup:

  ● Test suite failed to run

    TypeError: this._getEventHandlerFor is not a function

      at Object.get (node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:86:26)
          at Array.forEach (<anonymous>)

What jest config are you using, including any setup code?

The setup code is exactly the same as in #2436

My jest config is:

{
    "preset": "react-native",
    "transformIgnorePatterns": [
      "/node_modules/(?!native-base)/"
    ],
    "testMatch": [
      "**/test_*.ts",
      "**/test_*.tsx"
    ],
    "coveragePathIgnorePatterns": [
      "/node_modules/",
      "/common/"
    ],
    "setupFiles": [
      "<rootDir>/testing/setup.js",
      "./node_modules/react-native-gesture-handler/jestSetup.js"
    ]
  }

@ljharb
Copy link
Member

ljharb commented Oct 10, 2020

If you're getting an error from inside jsdom, then that's a bug in jsdom that you should file there.

Specifically for react-native, though, there doesn't yet exist a react-native adapter for enzyme, and you're using a react web adapter. #1436 tracks a proper adapter.

@savv
Copy link
Author

savv commented Oct 11, 2020

Thanks, I'm aware of all this. I would be great to use this new adapter when it's ready, but in the meantime enzyme seems to recommend this approach, here.

I just noticed that the recommended configuration changed. I will try that.

@savv savv closed this as completed Oct 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants