June 2018
Intermediate to advanced
348 pages
8h 19m
English
It is important to know that we won't use any testing framework at this point. The main goal in this section is to understand how TDD works; we have a complete tour of testing technology in the following sections in this chapter.
We will use TDD to create an additional function called sum, which will return the sum of two numbers that are passed as parameters. First, using an editor of your choice, create a new file called testing.js and add the following code:
const assert = require('assert');function add(n1, n2) { return 0;}
First, we import the assert module to use its equal function. The equal function expects three parameters:
Read now
Unlock full access