Native Node testing and debugging tools
A preference for tested code has formed part of the Node community's ethos since its inception, reflected in the fact that most popular Node modules, even simple ones, are distributed with test suites. While browser-side development with JavaScript suffered for many years without usable testing tools, the relatively young Node distribution contains many. Perhaps because of this, many mature and easy to use third-party testing frameworks have been developed for Node. This leaves a developer no excuse for writing untested code! Let's look into some of the provided tools for debugging and testing Node programs.
Writing to the console
Console output is the most basic testing and debugging tool, providing a quick way to see what is happening at some point in a script. The globally accessible console.log
is commonly used when debugging.
Node has enriched this standard output mechanism with more useful methods, such as console.error(String, String…)
, which prints...