npm i -D cli-color jest jest-localstorage-mock
# or
yarn add -D cli-color jest jest-localstorage-mock
# `jest-localstorage-mock` is optional if you don't use localStorage
# `cli-color` is used for the `UnhandledRejectionReporter`
Troubleshooting
- On OSX I ran into openSSL hashing errors while trying to install NPM modules.
To fix the errors I ran
ERROR:root:code for hash md5 was not found.
brew unlink openssl brew reinstall python@2
- After upgrading to Jest 26 I started getting
window
ordescribe
undefined errors.- After a lot of digging, I came across jestjs/jest#9538 (comment). Where they call out you should be using
Node >=10.14.2
. - If you have
nvm
installed, you can just runnvm install 10.14.2 && nvm alias default 10.14.2 && nvm use default
- After a lot of digging, I came across jestjs/jest#9538 (comment). Where they call out you should be using
- Package json scripts
- ES Lint
- Babel config
- If you're not using Babel, omit any items referencing Babel in the configs.
- Jest config
- If you're dealing with CSS modules, you'd add
moduleNameMapper: { '\\.(css|styl)$': 'identity-obj-proxy', },
- If you're using Webpack aliases, you'd add
// bring in your Array of aliases const { paths: ALIASES } = require('./conf.repo'); // -- place the below just above module.exports -- // map Webpack alias' so files resolve Object.keys(ALIASES).forEach((alias) => { conf.moduleNameMapper[`^${alias}(.*)$`] = `${ALIASES[alias]}$1`; });
- Custom reporters
- Unhandled Rejections
- Requires
cli-color
to be installed
- Requires
- Unhandled Rejections
- If you're dealing with CSS modules, you'd add