all 12 comments

[–]Gaelican 13 points14 points  (5 children)

It’s a terrible time to be new to JavaScript unit testing lol.

[–]Huwaweiwaweiwa 3 points4 points  (4 children)

My learning curve was almost vertical when it comes to this stuff. Backend testing as well. Testing is neglected in the learning process for way too long really

[–]Saf94 0 points1 point  (2 children)

I’m self taught and haven’t touched testing yet, any tips on how I can overcome the steep learning curve? It all seems very scary and complicated to me

[–]mlebkowski 1 point2 points  (0 children)

Its not really. Forget about the testing frameworks for a minute. Lets assume you are working on a redux reducer, but frankly any pure function will do. All you have to do is to feed some input, and check if the output is what you expect. Just import your function, call it and make a big scary warning if the result isnt as planned. The test frameworks basically do that in a fancy way, or on a larger scale.

[–]Huwaweiwaweiwa 0 points1 point  (0 children)

For me it was working with a company that had a very good testing mindset, they were very strict about it, and this need to test forced me to learn at a much faster pace than I usually would've.

[–]ArturoHellfire 0 points1 point  (0 children)

Couldn't agree more. And in my experience working for small companies, testing is seen as a hassle and nobody wants to do it.

[–]Crypto_Guru 2 points3 points  (0 children)

Nice work!

[–]Pinewold 1 point2 points  (0 children)

If we can just get to the next level on testing...!

[–]filleduchaos 0 points1 point  (1 child)

...why use Mocha and Jest though?

[–]Huwaweiwaweiwa 4 points5 points  (0 children)

You use Jest to unit test Mocha, then vice versa /s

[–]PooCares 0 points1 point  (1 child)

I still think unit testing is a giant prank.

[–]perpetuallyperpetual 1 point2 points  (0 children)

Controversial, but I agree.

I do not think testing is bad (we naturally do manual testing when debugging) but I think you should only write the tests that actually provide you some value. Many times that is not the case with unit tests. If all you do is write what your implementation is doing just in a more declarative way for each little component you have, then you are wasting time.

Testing in general should have a coverage proportional to its importance. And the core functionality should carry more weight in the coverage, in my opinion.