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

Testing example

For the Calculator app example, let's create the src folder in the root project's folder and create the calculator.js file inside:

$ mkdir src$ touch src/calculator.js

As you can see, we are not saving our calculator.js file inside the specs/ folder, so we need to configure karma to load the files present in the src/ folder. Apply the following changes in the karma.conf.js file:

...files: [      'specs/*.spec.js',      'src/*.js'],...

Now, Karma will load all the files from the specs and src folder when testing is running.

Let's implement the code of our calculator.js file. Using your editor of choice, open the src/calculator.js file and apply the following code:

window.Calculator = {  add: function(n1, n2) {    return n1 + n2;  }, multiply: ...

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