O'Reilly logo

Continuous Integration, Delivery, and Deployment by Sander Rossel

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

Running Mocha and Chai with Karma

As I said earlier, Karma is an abstraction, which makes it possible to run different tests from different test frameworks. While I do not want to dwell on this for too long, learning a single test framework is enough after all, I do wish to quickly show you how this is done.

So, let's install Mocha (https://mochajs.org/) and the popular Chai (http://chaijs.com/) assertion library:

npm install mocha --save-dev
npm install chai --save-dev

Now, create a file called mocha-tests.js inside your test folder. We are going to test repository.search in mocha-tests.js:

describe('web app tests', function() { describe('repository', function () { it('should search products with "fantas"', function() { var products = repository.search('fantas'); ...

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