Last active
May 11, 2018 00:11
-
-
Save davidimoore/65f4f11892ea173c610b489ab47bd086 to your computer and use it in GitHub Desktop.
jest-webpacker-setup
This file contains hidden or 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": "NODE_PATH='./app/javascript/node_modules:./app/javascript' jest", | |
"test:watch": "yarn test --watch", | |
"test:coverage": "test --coverage" | |
}, | |
"jest": { | |
"roots": [ | |
"./app/javascript" | |
], | |
"setupFiles": [ | |
"./app/javascript/packs/__test__/shim.js", | |
"./app/javascript/packs/__test__/setup.js" | |
], | |
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js" | |
} | |
} |
This file contains hidden or 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 Enzyme from 'enzyme'; | |
import Adapter from 'enzyme-adapter-react-16'; | |
Enzyme.configure({ adapter: new Adapter() }); | |
const localStorageMock = { | |
getItem: jest.fn(), | |
setItem: jest.fn(), | |
clear: jest.fn() | |
}; | |
global.localStorage = localStorageMock; | |
jest.resetAllMocks(); | |
jest.restoreAllMocks(); |
This file contains hidden or 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
global.requestAnimationFrame = (callback) => { | |
setTimeout(callback, 0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment