Mocha

Mocha is another JavaScript testing framework and is the one we would like to use. As for library interaction differences, there doesn't appear to be much different in terms of base interactions. The differences come down to the assertion library and the mocking library.

Mocking, which will be covered in detail in Chapter 8What to Know Before Getting Started, is essentially a way to provide alternative implementations of objects, classes, and functions, specifically to aid the testing process.

Mocha itself doesn't come with an assertion library, so one must be provided. The assertion library is what controls test results and how to verify that your code is executing correctly. Most developers who use Mocha rely on Chai for assertions.

As mentioned previously, another consideration is what mocking library you want to use. For many Mocha users, that library is unquestionably Sinon.

We will explain the purpose of any and all parts of Mocha that we use in this book. If you want to know more or want the documentation for quick reference while you are developing, you can go to the Mocha home page at https://mochajs.org.

Mocha can be installed into a JavaScript application using the following command:

>npm install mocha
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.4.181