A dive into JavaScript and React testing with Mocha using Chai, Sinon, and Enzyme.
This is the source code for a talk given by Josh Goldberg, Software Development Engineer at Microsoft in Office Sway, for Ada Developer Academy on 6/15/2017. That's me!
I'll cover some preliminary testing practices and protips for JavaScript, then show how they can be used with React:
- Basic Terms
- Mocha
- Chai
- Avoiding Singletons
- Sinon
- Enzyme
All the source code is here / in a GitHub repo.
First make sure you have NodeJS >=7 installed by running node --version
.
Git clone this repo to your compuer.
cd wherever/you/keep/your/code
git clone https://github.com/JoshuaKGoldberg/javascript-testing-and-react
cd javascript-testing-and-react
Install the prerequisite libraries. (If you're on Mac or Linux, you should prepend sudo
to the mocha install command.
npm install -g mocha
npm install
Markdown code samples are approximate subsets of .js files in the same section. You'll want to play along by running the test files using mocha path/to/test.js
.