Mocha is a testing framework similar to QUnit but more suited for console-based testing, as opposed to browser-based testing. It has familiar
describe()
and it()
blocks.
Zombie.js is a headless testing tool that allows us to test our application end-to-end. Using Zombie, we can open our application within a simulated browser environment and interact with the server layer of our application to verify both the backend and frontend functions as expected.
In this recipe, we will use Mocha and Zombie together as an effective tool to test our application end-to-end.
In our example, we will create a test that will launch our simple Calculator app and verify that it can add two numbers. We will have a simple HTML form with two input boxes, a button to trigger the calculation, and then verify the answer that is displayed.
We will need to install Mocha and Zombie. These are both available as NPM packages.