Being able to unit test stores is critical. This example shows you how to write tests for the TodoMVC stores we created in an earlier example.
cd path/to/flux-jest
npm install
npm run test
The primary differences from the flux-shell
project that are necessary to use Jest are:
- Run
npm install --save-dev jest babel-jest
- Add
"jest"
property topackage.json
- Update
"test"
key in the"scripts"
section ofpackage.json
Setting it up this way will reuse the .babelrc
file we already have set up so we can keep using the same syntax in our test files!
Check out the test file and make sure to read through the comments in beforeEach()
to get a sense of how and why we set up the test file the way we did.