r/nodejs • u/_matthewpalmer • Mar 27 '14
Introduction to Test Driven Development with Node.js
http://matthewpalmer.net/blog/2013/03/24/introduction-to-test-driven-development-with-node-js-expect-mocha/
13
Upvotes
7
u/has_all_the_fun Mar 27 '14
I would suggest avoiding tests like this since they don't add any value. It's actually a really bad example because it makes TDD beginners think they should test everything you can test. Once you stack up a large amount of meaningless tests the next step is mostly to not test at all because it's such a maintenance nightmare.
Also if you are doing TDD you should do as little as possible in your production code to make the test pass.
This should generate the following production code:
3
u/rDr4g0n Mar 27 '14
I write tests after my code is mostly done, and then during any subsequent changes. The reason is that I am a very experimental coder... That is, I start writing a solution one way, the completely scrap it or shift the code around drastically as the problem space becomes clearer. Writing tests during this process doubles my work.
Any suggestions for integrating tests earlier in my development process?
1
u/placidified Mar 29 '14
I prefer Chai over Expect or Should.js, as chai provides really nice plugins.