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

How to mock for jest? #1548

Closed
amduffy19 opened this issue Oct 20, 2021 · 2 comments
Closed

How to mock for jest? #1548

amduffy19 opened this issue Oct 20, 2021 · 2 comments

Comments

@amduffy19
Copy link

I set up bugsnag for react native according to the docs, but I didn't see anything mentioned about how to mock for jest. I'm getting the following error when I try to run a render test:

console.warn
    Bugsnag.getPlugin() was called before Bugsnag.start()

console.error
    The above error occurred in the <App> component:
        in App
    
    Consider adding an error boundary to your tree to customize error handling behavior.
    Visit https://fb.me/react-error-boundaries to learn more about error boundaries.

TypeError: Cannot read property 'createErrorBoundary' of undefined

I understand that the problem is that Bugsnag.getPlugin() is undefined so it's trying to call createErrorBoundary on undefined, but I don't know how to fix this. Is there a way to mock it?

@amduffy19
Copy link
Author

This fix got me around the jest problem. I'm not sure if this is the best solution or just a workaround.

@johnkiely1
Copy link
Member

Hi @amduffy19

There is some discussion around this here with some examples of how you could look to mock bugsnag. Perhaps you could try those and see how you get on.

@johnkiely1 johnkiely1 added the awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks. label Oct 22, 2021
@mattdyoung mattdyoung removed the awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks. label Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants