Skip to content

Instantly share code, notes, and snippets.

@Happy-Ferret
Forked from rakannimer/add-jest-to-nwb.sh
Created March 20, 2018 12:37
Show Gist options
  • Save Happy-Ferret/3fb1e5c86d62c2a87ce968f6e5b807ec to your computer and use it in GitHub Desktop.
Save Happy-Ferret/3fb1e5c86d62c2a87ce968f6e5b807ec to your computer and use it in GitHub Desktop.
Adding jest tests to nwb project
yarn add -D jest babel-jest babel-preset-es2015 babel-preset-react react-test-renderer
#Edit package.json adding the jest command :
"scripts": {
"build": "nwb build-react-component",
"clean": "nwb clean-module && npm clean-demo",
"start": "nwb serve-react-demo",
"test": "nwb test",
"test:coverage": "nwb test --coverage",
"test:watch": "nwb test --server",
"test:jest": "jest"
},
# For most setups this should be enough, for tweaking check below
# And add jest config ( OPTIONAL )
"jest": {
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
"testFileExtensions": [
"js"
],
"moduleFileExtensions": [
"js",
"json",
"jsx"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment