Skip to content

Instantly share code, notes, and snippets.

@molily
Created March 9, 2016 10:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save molily/7a24d0aacce5016ff9e5 to your computer and use it in GitHub Desktop.
Fail tests on console.error calls (e.g. React warnings)
// 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