Created
March 9, 2016 10:47
-
-
Save molily/7a24d0aacce5016ff9e5 to your computer and use it in GitHub Desktop.
Fail tests on console.error calls (e.g. React warnings)
This file contains 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
// Overwrite console.error so calls to it fail a test. | |
// This is mostly targeted at React warnings. For example, the test should not | |
// cause React missing prop warnings. | |
/* eslint-disable no-console */ | |
const originalConsoleError = console.error; | |
console.error = (...args) => { | |
originalConsoleError.apply(console, args); | |
throw new Error(`console.error was called: ${args[0]}`); | |
}; | |
/* eslint-enable no-console */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment