Sentry.Init: 'Cannot read property 'bind' of undefined' when running jest
See original GitHub issueEnvironment
How do you use Sentry? Sentry SaaS (sentry.io)
Which SDK and version?
"@sentry/react-native": "^2.5.0",
Steps to Reproduce
- Run tests with jest
Expected Result
Tests should run fine
Actual Result
Get this error:
● Test suite failed to run
TypeError: Cannot read property 'bind' of undefined
16 | const appBuild = RNDeviceInfo.getBuildNumber();
17 |
> 18 | Sentry.init({
| ^
19 | dsn:
20 | '...',
21 | ignoreErrors,
at getNativeFetchImplementation (node_modules/@sentry/browser/src/transports/fetch.ts:73:20)
at new FetchTransport (node_modules/@sentry/browser/src/transports/fetch.ts:84:72)
at ReactNativeBackend._setupTransport (node_modules/@sentry/react-native/src/js/backend.ts:87:12)
at ReactNativeBackend.BaseBackend (node_modules/@sentry/core/src/basebackend.ts:72:28)
at new ReactNativeBackend (node_modules/@sentry/react-native/src/js/backend.ts:18:5)
at ReactNativeClient.BaseClient (node_modules/@sentry/core/src/baseclient.ts:88:21)
at new ReactNativeClient (node_modules/@sentry/react-native/src/js/client.ts:22:5)
at initAndBind (node_modules/@sentry/core/src/sdk.ts:21:18)
at Object.init (node_modules/@sentry/react-native/src/js/sdk.ts:82:3)
at new ErrorHandler (src/client-blocks/helpers/ErrorHandler.ts:18:12)
This error started happening after I upgraded from 2.4.2 to 2.5.0. I setup sentry like this:
Sentry.init({
dsn: '...',
ignoreErrors,
enableNative:
typeof process?.env?.JEST_WORKER_ID !== 'undefined' ? false : true,
release: `${bundleId}@${appVersion}+${appBuild}`,
});
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
jest: Test suite failed to run, TypeError: Cannot read property ...
Try to re-install both jest and jest babel last versions ... Test suite failed to run, TypeError: Cannot read property 'bind' of undefined....
Read more >Troubleshooting for React - Sentry Documentation
If your application started to misbehave because of performing additional OPTIONS requests, it is most likely an issue with unwanted sentry-trace request ......
Read more >typeerror: cannot read properties of undefined ... - You.com
Reason : As there is no named export of ReactDOM from "react-dom", it is not imported and the reference will be undefined. So,...
Read more >@sentry/react | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >TypeError: Cannot read property 'bind' of undefined
I am facing some issues with running detox test with jest . The error I am getting is: detox test -c ios detox[47286]...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This seems to work and is exactly what I need, thanks! Had to import
NoopTransport
from@sentry/core
though. What’s the default value of the transport param actually?@svenlombaert When running jest tests, you would now have to pass
NoopTransport
toSentry.init
undertransport
. You should be able to import it from@sentry/react
. Although this will cause errors to not be sent (as the transport is a No-Op) I assume that should be fine unless you’re also testing your Sentry integration?