Skip to content

Commit

Permalink
Make sure dependency error reporting always works
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
trygveaa committed May 5, 2017
1 parent 84e10fa commit 75e7cd8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/react-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 75e7cd8

Please sign in to comment.