Created
December 27, 2017 10:31
-
-
Save digigarlab/ca88f6e3dac190acc2dd957d625796b3 to your computer and use it in GitHub Desktop.
Jest + Enzyme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is file is used by jest to resolve imports to asset files such as images or fonts | |
export default 'test-file-stub' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'raf/polyfill' | |
import Enzyme, { shallow, render, mount } from 'enzyme' | |
import Adapter from 'enzyme-adapter-react-16' | |
// React 16 Enzyme adapter | |
Enzyme.configure({ adapter: new Adapter() }) | |
// Make Enzyme functions available in all test files without importing | |
global.shallow = shallow | |
global.render = render | |
global.mount = mount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"test": "jest", | |
"test:watch": "jest --watch", | |
"test:coverage": "jest --coverage" | |
}, | |
"jest": { | |
"setupFiles": [ | |
"./jestsetup.js" | |
], | |
"snapshotSerializers": [ | |
"enzyme-to-json/serializer" | |
], | |
"projects": [ | |
"<rootDir>/services/app" | |
], | |
"modulePaths": [ | |
"<rootDir>/services/app" | |
], | |
"moduleNameMapper": { | |
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js", | |
"\\.(css|less)$": "identity-obj-proxy" | |
}, | |
"coverageReporters": [ | |
"text", | |
"text-summary" | |
] | |
}, | |
"devDependencies": { | |
"babel-jest": "^21.2.0", | |
"babel-preset-env": "^1.6.1", | |
"babel-preset-es2015": "^6.24.1", | |
"babel-preset-latest": "^6.24.1", | |
"babel-preset-react": "^6.24.1", | |
"enzyme": "^3.2.0", | |
"enzyme-adapter-react-16": "^1.1.0", | |
"enzyme-to-json": "^3.2.2", | |
"identity-obj-proxy": "^3.0.0", | |
"jest": "^21.2.1", | |
"raf": "^3.4.0", | |
"react-test-renderer": "^16.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment