{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/react/issues/5487","labels_url":"https://api.github.com/repos/facebook/react/issues/5487/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/5487/comments","events_url":"https://api.github.com/repos/facebook/react/issues/5487/events","html_url":"https://github.com/facebook/react/issues/5487","id":117284765,"number":5487,"title":"Issue with Simulate.Click invoking a function that I am spying on.","user":{"login":"andrewheppner","id":12014696,"avatar_url":"https://avatars.githubusercontent.com/u/12014696?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewheppner","html_url":"https://github.com/andrewheppner","followers_url":"https://api.github.com/users/andrewheppner/followers","following_url":"https://api.github.com/users/andrewheppner/following{/other_user}","gists_url":"https://api.github.com/users/andrewheppner/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewheppner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewheppner/subscriptions","organizations_url":"https://api.github.com/users/andrewheppner/orgs","repos_url":"https://api.github.com/users/andrewheppner/repos","events_url":"https://api.github.com/users/andrewheppner/events{/privacy}","received_events_url":"https://api.github.com/users/andrewheppner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-17T05:17:20Z","updated_at":"2015-11-17T05:17:20Z","closed_at":null,"body":"I am having lots of trouble testing out whether clicking on my rendered button element is invoking the onClick handler.\r\n\r\nHere is my code for the Component to be tested...\r\n```\r\n'use strict';\r\n\r\n//Library Dependencies\r\nconst React = require('react');\r\n\r\nconst CategoryClearButton = React.createClass({\r\n\r\n  render() {\r\n    return (\r\n      <button type=\"reset\" className=\"btn btn-primary btn-sm\" onClick={this._clearAllSelectedCategories}>\r\n        Clear\r\n      </button>\r\n    );\r\n  },\r\n\r\n   _clearAllSelectedCategories() {\r\n    this.props.handleClick();\r\n  }\r\n\r\n});\r\n\r\nmodule.exports = CategoryClearButton;\r\n```\r\n\r\nHere is my test case using Jasmine...\r\n```\r\n'use strict';\r\n\r\nconst React = require('react');\r\nconst ReactDOM = require('react-dom');\r\nconst TestUtils = require('react-addons-test-utils');\r\n\r\nconst CategoryClearButton = require('./CategoryClearButton.jsx');\r\nconst Actions = require('../../../actions/DashboardActions');\r\n\r\nlet element;\r\n\r\ndescribe('CategoryClearButton', () => {\r\n\r\n  beforeEach(() =>{\r\n    element = TestUtils.renderIntoDocument(<CategoryClearButton />);\r\n  });\r\n\r\n it('will call the _clearAllSelectedCategories method when clicked', () => {\r\n    let renderedButton = TestUtils.findRenderedDOMComponentWithTag(element, 'button');\r\n    spyOn(element, '_clearAllSelectedCategories');\r\n    TestUtils.Simulate.click(renderedButton);\r\n    expect(element._clearAllSelectedCategories).toHaveBeenCalled();\r\n })\r\n\r\n})\r\n```\r\n\r\nHere is the error message i'm getting in my console...\r\n```\r\nPhantomJS 1.9.8 (Mac OS X 0.0.0) CategoryClearButton will call the _clearAllSelectedCategories method when clicked FAILED\r\n\tTypeError: 'undefined' is not a funtion....\r\n\r\nPhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 70 of 70 (1 FAILED) (0.069 secs / 0.101 secs).\r\n```\r\nI am pretty sure the issue here is with the simulate click event not firing, because I can make this test pass by doing the following, which leads me to believe that the spy is doing its job...\r\n\r\n```\r\nit('will call the _clearAllSelectedCategories method when clicked', () => {\r\n    let renderedButton = TestUtils.findRenderedDOMComponentWithTag(element, 'button');\r\n    spyOn(element, '_clearAllSelectedCategories');\r\n    element._clearAllSelectedCategories();\r\n    expect(element._clearAllSelectedCategories).toHaveBeenCalled();\r\n  })\r\n```\r\nCan anybuddy give a newbie some guidance?\r\nThanks,\r\nAndrew"}}