Logical units

A unit can be a function or class that does not interact with the UI; functions like validateInput are a prime example. These logical units uses plain JavaScript and should work independently from the environment. Therefore, we can unit test them using Mocha, Chai, and Sinon in the same manner as we did for our backend code.

Because logical units are the easiest to test. You should pull as much of that application logic as possible and test it.

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.