From 8c5794eab3cfb8a027bd6eb338a3ba16f03d3564 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 18 Apr 2019 17:03:04 +0100 Subject: [PATCH] Fail tests on errors in renderer --- src/__tests__/setupTests.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/__tests__/setupTests.js b/src/__tests__/setupTests.js index 40475c8245..ab3b0e1f82 100644 --- a/src/__tests__/setupTests.js +++ b/src/__tests__/setupTests.js @@ -15,6 +15,15 @@ env.beforeEach(() => { // Fake timers let us flush Bridge operations between setup and assertions. jest.useFakeTimers(); + const originalConsoleError = console.error; + console.error = (...args) => { + if (args[0] === 'Warning: React DevTools encountered an error: %s') { + // Rethrow errors from React. + throw args[1]; + } + originalConsoleError.apply(console, args); + }; + installHook(global); const bridgeListeners = [];