From 75e7cd8df5c5783833d6e2ec159dba0306eaaeef Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Fri, 5 May 2017 18:18:38 +0200 Subject: [PATCH] Make sure dependency error reporting always works In some cases, the logging from console.error is swallowed (e.g. when using create-react-app and having multiple test files). By placing the message in the error instead, it is shown. --- src/react-compat.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/react-compat.js b/src/react-compat.js index 8ae286f24..dc3d6fa42 100644 --- a/src/react-compat.js +++ b/src/react-compat.js @@ -76,13 +76,11 @@ if (REACT013) { // eslint-disable-next-line import/no-extraneous-dependencies ReactDOM = require('react-dom'); } catch (e) { - // eslint-disable-next-line no-console - console.error( + throw new Error( 'react-dom is an implicit dependency in order to support react@0.13-14. ' + 'Please add the appropriate version to your devDependencies. ' + 'See https://github.com/airbnb/enzyme#installation', ); - throw e; } // eslint-disable-next-line import/no-extraneous-dependencies @@ -116,19 +114,18 @@ if (REACT013) { } } catch (e) { if (REACT155) { - console.error( // eslint-disable-line no-console + throw new Error( 'react-dom@15.5+ and react-test-renderer are implicit dependencies when using ' + 'react@15.5+ with enzyme. Please add the appropriate version to your ' + 'devDependencies. See https://github.com/airbnb/enzyme#installation', ); } else { - console.error( // eslint-disable-line no-console + throw new Error( 'react-addons-test-utils is an implicit dependency in order to support react@0.13-14. ' + 'Please add the appropriate version to your devDependencies. ' + 'See https://github.com/airbnb/enzyme#installation', ); } - throw e; } // Shallow rendering changed from 0.13 => 0.14 in such a way that