-
Notifications
You must be signed in to change notification settings - Fork 51
unit tests
Nelson Omuto edited this page Jul 12, 2018
·
3 revisions
To use this repo as an example for getting started and to setup jest in another pocket repo.

The outcome is simple:
- Run the app locally
- Run
npm run test:watch
- Write code and unit tests 💥 (for organization purposes and to group snapshots, tests should be either colocated with a corresponding src file or under a
__test__
directory and the filename should match **.test.js) - Make sure to include any generated snapshots in your git commit 😅
To read more on the philosophy behind snapshots and jest visit their website.
To setup jest for other pocket react apps follow these steps: (note this is already done in this repo ✅)
- Install the following dependencies (add them to your package.json and run npm i):
"babel-core": "^6.26.0",
"babel-eslint": "^7.1.1",
"babel-jest": "^21.2.0",
"babel-loader": "^7.1.2",
"babel-plugin-dynamic-import-node": "^1.0.2",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.23.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.0",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.23.0",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-hot-loader": "^3.0.0-beta.7",
"react-redux": "5.0.6",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.0",
"react-test-renderer": "^16.0.0",
- Update your circle
config.yml
file to run jest tests

-
Add a .babelrc to the root of your repo
-
Add the following jest plugins by copying .tooling/config/jest
-
Update your package.json scripts with the test alias
-
Update or add to your package.json to the following precommit config