Skip to content

Commit

Permalink
Show a friendly error when using TestUtils.Simulate with shallow rend…
Browse files Browse the repository at this point in the history
…ering
  • Loading branch information
conorhastings committed Nov 2, 2015
1 parent 88bae3f commit 661c046
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/test/ReactTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ ReactShallowRenderer.prototype._render = function(element, transaction, context)
function makeSimulator(eventType) {
return function(domComponentOrNode, eventData) {
var node;
invariant(
!React.isValidElement(domComponentOrNode),
'TestUtils.Simulate expects a component instance and not a React Element.' +
'TestUtils.Simulate will not work if you are utilizing shallowRender.'
);
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
node = findDOMNode(domComponentOrNode);
} else if (domComponentOrNode.tagName) {
Expand Down

0 comments on commit 661c046

Please sign in to comment.