O'Reilly logo

Hands-On Full Stack Web Development with Aurelia by Erikson Haziz Murrugarra Sifuentes, Diego Jose Arguelles Rojas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the code

Now, let's implement the code in the add function. We will declare a result variable into the function to house the addition between the two parameters passed to it. Open the testing.js file and apply the following changes:

const assert = require('assert');function add(n1, n2) {    const result = n1 + n2;  return result;}var result = add(5, 5);assert.equal(result, 10, "Should be 10");console.log("Test passed!!");

Now that we have implemented the logic for our add function, the next time we run the test, we expect that the assertion.equal function won't fail and the Test passed!! message will be displayed. Let's try it out. Execute the following command:

$ node testing.js  Test passed!!

As you can see, the test passed and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required