DEV Community

loading...

Discussion on: Introduction to Practical Test-Driven Development with JavaScript for beginners

Collapse
loujaybee profile image
Lou — Cloud Engineer

Nice, Vlad! Nice to see you writing 😁 I've been thinking for a long time to try and write up some fairly extensive run through of JS test mocking etc. Covering things like philosophy of mocking and what not. That was a huge hurdle for me to get into TDD, as you need to have all the "tools" before you begin.

That said, I literally now cannot code without tests. The prospect of compiling and then refreshing a browser or API and manually verifying fills me with horror. I'd much rather spend the first X amount of time writing some decent tests before I begin. I can't often fathom the idea of not doing that.

Collapse
loujaybee profile image
Lou — Cloud Engineer

Also nice that you wrote your own little test runner. I remember watching some tutorial where someone did that and I remember being like... "oh... I can do that?". Then I started kicking myself since the true barrier to entry for tests is just one small test function (as you did). There's pretty much no excuse or reason not to.

Collapse
vladdubrovskis profile image
Vlad Dubrovskis Author

Thanks Lou!

I wanted to show that writing tests is all about a way of thinking and that it helps you navigate the problem. I like the idea around mocking/not mocking as have fallen to that trap too before where mocked out things to the point - so if will find more time for writing may write some more stuff around testing :)

I had to recently try and explain how testing works and realised that we are too used to tooling and in reality all it is just a function that makes sure that result matches the expectation. The frameworks are out there to make a lot of things easier but the basics are still the same.

And as you said - I think once it clicks and you see the benefit of it you just don't want to go back to not doing it :)

As someone on LinkedIn said: "I never understood why someone wouldn't write lots of tests! What kind of person doesn't like to consistently prove themselves right?"