August 02, 2014
I’m currently going through the process creating unit tests for Griddle and thought it would be good to document the steps I took to get Jest up and running. I did not find it as simple as typing
npm install -g jest-cli, however it was not too bad.
My primary machine is running Windows 8 — these steps may be a bit different if you’re on Mac / Linux.
GYP_MSVS_VERSIONor the command line option
--msvs_version. My environment variable looks a bit like this
GYP_MSVS_VERSION=2013but if you are using Express, I think you have to say
npm install jest-cli --save-dev
At this point you should be ready to run Jest, however, I experienced some further trouble on Windows against React components. In the react example, the package.json contains
"unmockedModulePathPatterns": ["<rootDir>/node_modules/react"] which is basically stating that we don’t want to mock React when running our tests. Unfortunately, it seemed like we need to change this path to just
"unmockedModulePathPatterns": ["react"] in order for the test to run successfully (again on Windows — seems fine on other OS). See this GitHub issue for more on that.
For more reading on installing Jest’s requirements see: