From 7c7773c12359be2e578b78af8f722e649ee21101 Mon Sep 17 00:00:00 2001 From: Dan Green Date: Sun, 12 Nov 2017 13:40:07 -0500 Subject: [PATCH] Issue #2196 - Set console.warn and console.error to throw in tests --- scripts/jest.init.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/jest.init.js b/scripts/jest.init.js index e9f263b0e13..2260c0eec77 100644 --- a/scripts/jest.init.js +++ b/scripts/jest.init.js @@ -5,3 +5,15 @@ import { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; 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;