You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importReactfrom"react";importTestUtilsfrom"react-addons-test-utils";classTestElementextendsReact.Component{render(){return(<divonClick={()=>{console.log('clicked on div!');}}><buttononClick={()=>{console.log('clicked on button!');}}>Click me</button></div>);}}describe('Foo',()=>{it('bar',()=>{varelement=TestUtils.renderIntoDocument(<TestElement/>);window.addEventListener('click',()=>{console.log('click on window');});document.addEventListener('click',()=>{console.log('click on document');});varbutton=TestUtils.findRenderedDOMComponentWithTag(element,'button');TestUtils.Simulate.click(button);});});
Logs:
clicked on button!
clicked on div!
The thing is: both window and document click handlers are never called.
Am I doing something wrong in here?
Thanks in advance!
The text was updated successfully, but these errors were encountered:
Simulate only simulates an event within React's event system. You should use an ordinary .dispatchEvent or similar if you want to create and dispatch a real browser event.
Possibly a dupe of #4766
test:
Logs:
The thing is: both
window
anddocument
click handlers are never called.Am I doing something wrong in here?
Thanks in advance!
The text was updated successfully, but these errors were encountered: