Skip to content

Instantly share code, notes, and snippets.

@davidimoore
Last active May 11, 2018 00:11
Show Gist options
  • Save davidimoore/65f4f11892ea173c610b489ab47bd086 to your computer and use it in GitHub Desktop.
Save davidimoore/65f4f11892ea173c610b489ab47bd086 to your computer and use it in GitHub Desktop.
jest-webpacker-setup
{
"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"
}
}
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();
global.requestAnimationFrame = (callback) => {
setTimeout(callback, 0);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment