question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when testing with jest

See original GitHub issue

I’m using jest and enzyme to write tests for my project. When testing components with charts in them and calling component.unmount(), I’m getting this error:

TypeError: Cannot read property 'destroy' of undefined
  at ChartComponent.componentWillUnmount (node_modules/react-chartjs-2/lib/index.js:127:26)
  at node_modules/react-dom/lib/ReactCompositeComponent.js:409:25
  ...pointlessly looking enormous trace 

Full stack trace here: http://pastebin.com/yHNX5QnV

Does anybody else have any similar problem, do I have to do something more specific when testing components with charts in them and do you have any idea how I might be able to fix this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
amiquelinocommented, Jan 26, 2017

+1

2reactions
jainanshulcommented, Feb 9, 2017

I am getting the same error when using react-chartjs-2 in a react webapp. Is there a solution to this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to test the type of a thrown exception in Jest
In Jest, when you test for a case where an error should be thrown, within your expect() wrapping of the function under testing,...
Read more >
How to Correctly Expect an Error in Jest - Webtips
We have a mock function and we want to test whether it throws the error we are expecting. We can do this by...
Read more >
How to test a function that's expected to throw error in jest…
So, I needed to write unit tests for a function that's expected to throw an error if the parameter supplied is undefined and...
Read more >
Successfully Throwing Async Errors with the Jest Testing Library
Today, I'll discuss how to successfully test expected errors are thrown with the popular JavaScript testing library Jest, so you can rest ...
Read more >
Testing errors with Jest - DEV Community ‍ ‍
Use try catch statement. · call the generateCalcSettings with wrong parameters · The catch take the return and use tobeInstanceOf and compare with ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found