Why should we write tests for our code?
When there are more than one developers making changes actively to the code base, issues and bug...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
Not a big fan of jest, since it has something about 800 dependencies.
Sadly the ide support for UVU is not great yet, however I'm looking forward.
Currently I prefer mocha for backend node code. For mocks I try to avoid them however if I have to I use sinon
Agreed with that! Because Jest pretty much covers most of the functionalities by itself and it is not as flexible like others :)
Mocha and Sinon makes a good combination too!
you should also mention proxyquire since sinon does not cover everything.
Mocking 3rd party deps is easy with jest, however requires some tinkering with sinon.
Sadly...
Well, I guess nobody is perfect :) Basically, I stick with Jest for the initial setup, and will combine with other libraries when necessary
In my experience that works well. I just got paranoid with the recent supply chain attacks 😂
I like Jest but it quickly becomes a mess when introducing Typescript, and testing backend code.
Mocking named exports is a big mess.
Other than that I like Jest (except for their ties to Facebook evil )
Great article, good for introduction, thanks
Thanks for leaving a comment :)
Yea... It needs a lot of workarounds when it comes to Typescript :)
It does - but I still use Jest as for me its the best all around unit testing framework/library.
For E2E and integration tests, I swear on Cypress, but Jest rules for unit tests.
Cheers, and thanks
Thanks! This article has made me curious to see how jsx is tested.
Sure Rishad! I will try to share more of this in the next article ;)
Besides the problems with Typescript it also suffers from memory leaks. I wouldn't event recommend it. It's just used because of herd effect. Tests are much faster and stable with Mocha.
Thanks for leaving a comment Patrice :)
I see... I haven't read up on its memory leaks issue, but I am interested to read up more and will definitely share my findings on that! Thank you for your suggestions :)
Thank you
Good
Thanks!
Thank you for this article. This helped in my journey exploring unit testing :)
No problem! Glad this could help :)
Code, not codes.
Thanks a lot Paul! I have made the corrections :)
Nice article on testing! Interested to see more of this in the future.
Thanks! Will definitely share more :)
thank you for the article. why did u use jest instead of mocha and chai?
I can't wait to see how to use jest on jsx or tsx hehe
Hey Ragil, thanks for leaving a comment! I generally prefer Jest because it provides a lot of built-in functionalities such as test runner, code coverage etc, without having to combine with other testing tools (it's like all in one) :)
However, Mocha makes a good combination with other libraries such as Sinon.js, Chai.
In order to test React, I planned to use methods from RTL and combination with Jest :)
thanks very helpful
Glad you find it helpful :)
Don't.
Good
Why don't you mock fetch itself? Shall we test 'isomorphic-fetch' itself??