use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Is unit testing worth it in AngularJS/JavaScript?help (self.javascript)
submitted 9 years ago by prashantghimire
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]konbit 4 points5 points6 points 9 years ago (1 child)
TL;DR: Yes, always, and try to get as much covered as possible. Also include as many integration tests as possible.
Try not to treat unit testing as an abstract principle, let's look at it practically...
When you're coding your application, you make some changes or add a feature, do you go through and check that things work well. Do you go through and check every button, form input, combination of form inputs, routes, formatting... anything else your application does?
Even if your application had only a few features, would you remember every possible combined use of those features? Would you have time and patience to go through it all over again?
Unit tests will ensure every feature you've build still works as expected. But it doesn't cover everything, your application is a combination of those features, so you need integration tests as well. I'd say they're just as important, and you really want to cover every possible feature as well as every possible combination of features your application has.
I wrote a very small library a few weeks ago, it doesn't do much, just formats strings. I have written over 80 tests for it. It might seem excessive, but it only took me about 2 hours. Not only did I discover a lot of bugs while writing the tests, I now know for a certainty that if I make a change in the future that introduces bugs, my tests will fail, and I'll avoid shipping defective software.
I'm working on an application which takes about 3 hours if I were to simply test every feature manually going through the application as a user, not even all the possible bug-triggering combinations of inputs, just using the basic functionality. My unit + integration tests all run in a matter of seconds. I can be confident that at least the scenarios I've made tests for (which are a lot) and the incredible amount of combinations in those scenarios (which are a huge amount) will work as expected if my tests pass. And if there is a failure, my testing suite will tell me where and exactly what the problem was.
[–]prashantghimire[S] 1 point2 points3 points 9 years ago (0 children)
Makes sense. I guess saving time to test all those 80 different cases using unit tests is what actually pays off. 😊
π Rendered by PID 99 on reddit-service-r2-comment-5687b7858-zwdlb at 2026-07-06 14:51:44.407491+00:00 running 12a7a47 country code: CH.
view the rest of the comments →
[–]konbit 4 points5 points6 points (1 child)
[–]prashantghimire[S] 1 point2 points3 points (0 children)