Skip to content

Commit

Permalink
Config Jest to mock static assets since they're not needed during test.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhusee2 committed Mar 9, 2017
1 parent 9ca37d2 commit b6b3226
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'mocked-file';
5 changes: 5 additions & 0 deletions config/jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"moduleNameMapper": {
"\\.(css|scss|sass|md|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|)$": "<rootDir>/__mocks__/fileMock.js"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"build:lib": "BABEL_ENV=lib babel src --out-dir lib",
"build:es5": "BABEL_ENV=es5 babel src --out-dir es5",
"lint": "eslint ./ && echo \"eslint: no lint errors\"",
"test": "jest ./src --config=config/jest.config.json",
"clean": "rm -rf ./dist ./lib ./es5 ./deploy",
"deploy": "npm run clean && npm run build && sh deploy.sh"
},
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from '../index';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});

0 comments on commit b6b3226

Please sign in to comment.