June 2018
Intermediate to advanced
348 pages
8h 19m
English
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: ...Read now
Unlock full access