The 3 Magical Words…!! NodeJS Mocha Chai ;)

Rajesh Mishra
3 min readMay 22, 2019

“I Love You”…!!

  • You are, and always have been, my dream.
  • There’s always that one person, that will always have your heart….
  • Wait… What??? Noo..!! I am a Developer. I have my own “3 Magical Words”.

“NodeJS Mocha Chai”…!!

Image result for mocha chai nodejs
The 3 Magical Words..!!

Just like “Pehli Nazar me Pyaar ho gayaa..”, I fell in love with these three, super-instantly. (Though I fell in love with NodeJS since long)

After working with SailJS (A framework of NodeJS) for a long, our team has decided to move to typescript. We started looking for a better and robust alternative and finally decided to move our Front-End in ReactJS and APIs to Express with TypeScript.

We have enjoyed using TypeScript while developing Hybrid Apps in Ionic. And finally, we will be writing our APIs also. It’s really very exciting for me to try out something new.

Even though I haven’t spent much time and the platform is still in the development stage, I am having a good feeling. After migrating a bunch of APIs, I observed optimized performance, ease of writing (initial few days were tough, as I was learning), wide options to monitor the App Performance and the most important, restricting human errors(forced to write a sanitized code).

For building a fully functional, bug-free platform, Testing plays an important role. With a very small team and loads of work to take the platform to the production, we never got a real chance to focus on testing. In fact, we skipped the testing part, even after being advised by many people.

Recently, as we have decided to make our product better, we tried adding test codes to our APIs. A few hours ago, I had no idea what to do, except for a few names of testing tools. Somehow, I started to look for the steps to add testing using “Mocha/Chai”.

Mocha is a test running framework, and Chai is an assertion library. I tried adding test cases to one of my new APIs. It was so smooth and easy. I wondered, why the hell we are using these??!!.. The feeling was just like getting a Major OS Upgrade with attractive features in a Mobile Device.

For those, new to this, here’s a good read on “How to Implement Mocha/Chai Unit Tests”. And for automating the testing process, I have used Buddy. You can go for the Free Plan of Buddy to try and test your requirements. It has integrations with BitBucket and GitHub. Also, the option to send Notification through platforms like Slack on fail tests and a lot more features. Overall a good platform for newbies like me.

I don’t need to explain its benefits. It's a must-have thing. Though we’re late, will make it up soon..!! And hopefully, this will help us build a better product.

P.S.: Also waiting for the other 3 Magical Words.. :P.

--

--

Rajesh Mishra

A coder by profession, sharing life experiences with the Words. Learning more about Productivity, Habits, Decision Making and ambitious towards self freedom.