How long after getting into development did you start writing tests first?

I'm interested in hearing from NodeJS/Javascript developers, but this is a general question.

How did it help? Which benefits were immediately visible?

Also, any good resources for starting out with testing?

Did you find this post useful? Show some love!

It took me a very long time to get in the habit of writing tests. This was mainly because I was writing backend code with fewer moving parts. I had this habit of writing a driver to test various parts of my code, but it wasn't exactly unit-tests or test-automation. It was somewhere in-between.

One of the biggest advantages of tests is that you can go all out and refactor code without breaking anything (as long as you have good test coverage). You have the peace of mind that you won't accidentally introduce bugs. Usually, if my code broke for some reason, I would add more tests around that breaking bug to ensure it never happened again. This becomes more and more valuable as you get into integration tests because now you can test multiple components working together.

For the past few years, I have been relying mostly on UI Automation for web applications because that's the biggest bang for your buck. It executes the entire pipeline in most cases. However, one of the downsides is that if your UI changes frequently then this becomes more of a chore and developers can disable it.

For Node, you should try Jest. For UI Automation, is nice, but I prefer Puppeteer.

I agree with what Nick and miku86 wrote below. In addition, I think you'll find that writing tests will serve as a guide you towards writing better code as well :)

It forces you to think at a higher level with respect to the code, and make explicit the inputs and outputs of any functions you write. I've found that when my code is poorly written, it becomes almost impossible to write tests for.

Good luck!

After realizing, that small changes can lead to big problems
and fixing old stuff, without being "into it", can waste many hours.

I'm using Jest, up and running in 2min.

Classic DEV Post from Aug 2

Changelog for developers?

Potential way to help teams work together on projects

Follow @scottharrisondev to see more of their posts in your feed.
Arnav Bansal
Hello! I'm an 18 y/o from Bangalore. If it wasn't so cringy, I'd call myself a blockchain enthusiast. I can do full stack web stuff.
More from @itsarnavb
hyperConsole— Instantly load popular JS libraries into devTools and experiment.
#javascript #webdev #opensource #productivity
Trending on
The EmberJS of the future... today!
#javascript #emberjs #typescript #decorators
React router beginners guide
#react #javascript #beginners #webdev
Updating Background with SpeechRecognition & Custom Properties
#css #javascript #speechrecognition
A JavaScript Haiku
#javascript #haiku
Why JavaScript is an OOP Language (Even Though It Doesn't Have Classes)
#javascript #computerscience #programming #programminglanguages
Learning Algorithms with JS, Python and Java 8: Sentence Capitalization
#beginners #javascript #python #java
Testing applications with Cypress
#showdev #testing #beginners
Mint vs JavaScript (stack)
#mintlang #javascript #webdev