Skip to content

Commit

Permalink
Merge pull request #2297 from storybooks/make-console-error-and-log-f…
Browse files Browse the repository at this point in the history
…ail-tests-#2196

Issue #2196 - Set console.warn and console.error to throw in tests
  • Loading branch information
Hypnosphi committed Nov 21, 2017
2 parents cad0dc2 + 041deca commit 72e5c97
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scripts/jest.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@ import Adapter from 'enzyme-adapter-react-16';
global.console.info = jest.fn().mockImplementation(() => {})

configure({ adapter: new Adapter() });

/* Fail tests on PropType warnings
This allows us to throw an error in tests environments when there are prop-type warnings. This should keep the tests
free of warnings going forward.
*/

const throwError = message => {
throw new Error(message);
};

global.console.error = throwError;
global.console.warn = throwError;

0 comments on commit 72e5c97

Please sign in to comment.