Testing Tools
Let us also quickly introduce the testing tools you are going to be using in our TDD approach.
You are going to learn how to use the following: Mocha, Chai, Enzyme, jsdom, Sinon.
What is Mocha?
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.
What is Chai?
Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.
Chai has several interfaces that allow the developer to choose the most comfortable. The chain-capable BDD styles provide an expressive language & readable style, while the TDD assert style provides a more classical feel.
-- Chai website
What is Enzyme?
Enzyme is a JavaScript Testing utility for React that makes it easier to assert, manipulate, and traverse your React Components' output.
Enzyme's API is meant to be intuitive and flexible by mimicking jQuery's API for DOM manipulation and traversal.
Enzyme is unopinionated regarding which test runner or assertion library you use, and should be compatible with all major test runners and assertion libraries out there.
-- Enzyme docs
What is jsdom?
jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG DOM and HTML Standards, for use with Node.js. In general, the goal of the project is to emulate enough of a subset of a web browser to be useful for testing and scraping real-world web applications.
-- jsdom docs
Perhaps an easier to understand introduction is given in:
JSDOM is a JavaScript based headless browser that can be used to create a realistic testing environment.
-- Enzyme docs
What is Sinon?
Standalone test spies, stubs and mocks for JavaScript.
Works with any unit testing framework.
Last updated
Was this helpful?