O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

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 in the browser

In the last section we learned how to use mocha in a Node.js environment, but this framework can also be used to execute client-side tests in a browser environment. To do this we need to create an HTML page and add the CSS and js of mocha to it:

To add the mocha.css you add the following line in your HTML:

<link href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css" rel="stylesheet" /> 

To add the JavaScript you add the following line in your HTML:

<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script> 

On the server side we could use the default assert module from Node.js, but as this module is not available in the browser context, we will have to add a library to handle the assertions of ...

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