Frontend Weekly
Published in

Frontend Weekly

Making testable JavaScript code

This is the story of a developer who was asked to write a text transformation code and test cover it.

The developer wrote JavaScript ES6 class with just 20 lines of code, added a unit test (Mocha, Chai) and the code coverage tool (NYC) reported all unit tests to be passing with 100 % code coverage.

Let’s see this JavaScript code:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store