DEV Community

Discussion on: Why I Love TDD

Collapse
 
miketalbot profile image
Mike Talbot ⭐ • Edited

I do love TDD on the server because "it makes sense" to have a framework to ensure your code works. I use the excellent Wallaby.js that runs tests in the background as you type and integrates with VSCode/other IDEs to show issues and code coverage in real time - I love it.

What I don't love is the hours wasted making mocks for things in increasingly complicated systems. It starts off making sense, then eventually you end up debugging your mocks and how they are getting loaded. There are circumstances where this ends up being hard and where it isn't clear what all of the input characteristics to a unit will be - this can lead to a false sense of security. On the server side, I think my team have a good balance on this. Properly stacking the levels of deeply tested 95%+ code coverage core modules with integration driven tests higher up.

But then I consider the front-end. Sure it isn't too bad if you are building a library component, but yeah, there is more time wasted in unit testing than in working if you aren't careful. We are Cypress and integration tests all the way because so much of the FE work is about "how smooth it looks" and does it make sense as well as "did this button appear and did X happen when I clicked it".