-
Notifications
You must be signed in to change notification settings - Fork 5
Jest setup
Kenza Boulisfane edited this page Mar 26, 2020
·
1 revision
- Install Jest using npm:
npm install --save-dev jest
- In the scripts section, add the following to the package.json file
scripts: { ..., "test": "jest" }
- In the same file, create a Jest section as follows:
"jest": { "preset": "jest-expo", "setupFilesAfterEnv": [ "<rootDir>setupTests.js" ], "transformIgnorePatterns": [ "node_modules/(?!(jest-)?react-native|unimodules-permissions-interface|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|sentry-expo|native-base)" ], "collectCoverage": true, "collectCoverageFrom": [ "**/*.{js,jsx}", "!**/coverage/**", "!**/node_modules/**"] }
- Add Jest to Travis CI:
language: node_js node_js:
- node
- lts/* cache: directories:
- ~/.npm\
- .jest before_script:
- npm install -g npm@latest script:
- npm ci
- npx jest --ci
- npm test -- --coverage --updateSnapshot