---
title: "Discussion on \"[JavaScript] Why do we need tests?\" | Hashnode"
description: "Discussion on \"[JavaScript] Why do we need tests?\". Running a program without tests is like using a mathematical formula without proof. We “hope” program will work as expected for every input.\n\nThe process of converting pseudo code to a working program usually takes one special step at the end called ..."
url: "https://hashnode.com/posts/javascript-why-do-we-need-tests/5d014024ae52bd0a17b2a97d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [\[JavaScript\] Why do we need tests?](https://blog.codecareer.io/javascript-why-do-we-need-tests?utm_source=hashnode&utm_medium=feed)

Running a program without tests is like using a mathematical formula without proof. We “hope” program will work as expected for every input. The process of converting pseudo code to a working program usually takes one special step at the end called ...

Jun 12, 2019 · blog.codecareer.io  
Read the article

-   [#mocha](https://hashnode.com/tag/mocha)
-   [#testing](https://hashnode.com/tag/testing)
-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Amrit Pandey](https://hashnode.com/@ap4tt)

@ap4tt · Madhya Pradesh, India

  
[View profile](https://hashnode.com/@ap4tt)

Anti-Dogmatic Programmer

Self-taught Programming enthusiast. Curiosity to learn new things in tech makes me happy. I am probably not your usual &quot;yes-boss&quot; developer.

## Responses 2

Markdown supported · ⌘↵ to post

[Yashu Mittal](https://hashnode.com/@mittalyashu)

[Jun 14, 2019](https://hashnode.com/posts/javascript-why-do-we-need-tests/5d014024ae52bd0a17b2a97d/comment/5d035a2abf4e2c1e5aeb9e99)

Which one is the best to use for writing tests for JavaScript & Vue.js?

[Amrit Pandey](https://hashnode.com/@ap4tt)

[Jun 14, 2019](https://hashnode.com/posts/javascript-why-do-we-need-tests/5d014024ae52bd0a17b2a97d/comment/5d035a2abf4e2c1e5aeb9e99#reply-5d03b5599f94cb4f567ea485)

If you are beginning Mocha is simple and good both for front-end and back-end. Vue-CLI also have built in option for Unit Testing in Mocha.

But I've heard great things about Karma.js for front-end. Source:

[https://www.youtube.com/watch?v=c9\_jw5CzMrc](https://www.youtube.com/watch?v=c9_jw5CzMrc)

[Yashu Mittal](https://hashnode.com/@mittalyashu)

[Jun 14, 2019](https://hashnode.com/posts/javascript-why-do-we-need-tests/5d014024ae52bd0a17b2a97d/comment/5d035a2abf4e2c1e5aeb9e99#reply-5d03cb362b1a2a7266dbb147)

Ah! Thanks for the reference.

[Agnius Vasiliauskas](https://hashnode.com/@AgniusVasiliauskas)

[Jun 13, 2019](https://hashnode.com/posts/javascript-why-do-we-need-tests/5d014024ae52bd0a17b2a97d/comment/5d020fe9c58d616927458ebd)

Nice article. I would like to add that not every thing can be unit-tested with a test automation framework. At least, not practically- if your single test would run for **a several days**. Consider this, that you are building software which categorizes movies by genre. You can't write a unit test for just a several movies and if they are correctly categorized - hope that your algorithm predicts genre well. It's not working like so. Typically you would want to calculate _false positives_ and _false negatives_ for a genre detection of let's say 2'000 movies. If you will get these false positives / false negatives ratios as a small numbers from this movie set - only then you can conclude that your algo works as expected and change X in the program hasn't broke the classification quality. The problem is that classifying such huge amount of movies requires a long time. So it's reasonable to put such classification task in some sort of CRON scheduler which would be run regularly until it finishes classifying a movie test set. Only then you can calculate FP/FN ratios and say if your test has passed or not. What I'm trying to expose here - that **long-running** tests may not be suitable for a _automation frameworks_.

[Amrit Pandey](https://hashnode.com/@ap4tt)

[Jun 17, 2019](https://hashnode.com/posts/javascript-why-do-we-need-tests/5d014024ae52bd0a17b2a97d/comment/5d020fe9c58d616927458ebd#reply-5d0738d68dc39fa061f6219d)

Thanks for this awesome comment.

I have noted down this fact and will come back to it as I advance my knowledge in testing.
