Skip to content

Instantly share code, notes, and snippets.

@rakannimer
Last active April 14, 2019 02:29
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rakannimer/f31c0178243e4f1d402546d41e7d7dcd to your computer and use it in GitHub Desktop.
Save rakannimer/f31c0178243e4f1d402546d41e7d7dcd 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