{"action":"created","issue":{"url":"https://api.github.com/repos/airbnb/enzyme/issues/58","labels_url":"https://api.github.com/repos/airbnb/enzyme/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/airbnb/enzyme/issues/58/comments","events_url":"https://api.github.com/repos/airbnb/enzyme/issues/58/events","html_url":"https://github.com/airbnb/enzyme/issues/58","id":120679405,"number":58,"title":"setState causes Invariant Violation when it changes markup","user":{"login":"silvenon","id":471278,"avatar_url":"https://avatars.githubusercontent.com/u/471278?v=3","gravatar_id":"","url":"https://api.github.com/users/silvenon","html_url":"https://github.com/silvenon","followers_url":"https://api.github.com/users/silvenon/followers","following_url":"https://api.github.com/users/silvenon/following{/other_user}","gists_url":"https://api.github.com/users/silvenon/gists{/gist_id}","starred_url":"https://api.github.com/users/silvenon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silvenon/subscriptions","organizations_url":"https://api.github.com/users/silvenon/orgs","repos_url":"https://api.github.com/users/silvenon/repos","events_url":"https://api.github.com/users/silvenon/events{/privacy}","received_events_url":"https://api.github.com/users/silvenon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/airbnb/enzyme/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/airbnb/enzyme/labels/Mount","name":"Mount","color":"5319e7"}],"state":"open","locked":false,"assignee":{"login":"lelandrichardson","id":1885623,"avatar_url":"https://avatars.githubusercontent.com/u/1885623?v=3","gravatar_id":"","url":"https://api.github.com/users/lelandrichardson","html_url":"https://github.com/lelandrichardson","followers_url":"https://api.github.com/users/lelandrichardson/followers","following_url":"https://api.github.com/users/lelandrichardson/following{/other_user}","gists_url":"https://api.github.com/users/lelandrichardson/gists{/gist_id}","starred_url":"https://api.github.com/users/lelandrichardson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lelandrichardson/subscriptions","organizations_url":"https://api.github.com/users/lelandrichardson/orgs","repos_url":"https://api.github.com/users/lelandrichardson/repos","events_url":"https://api.github.com/users/lelandrichardson/events{/privacy}","received_events_url":"https://api.github.com/users/lelandrichardson/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2015-12-07T01:06:53Z","updated_at":"2015-12-07T22:15:26Z","closed_at":null,"body":"I'm aware of #27, mine happens on React v0.14 and it crushes my soul as well :disappointed: \r\n\r\nAs far as I've tested (AFAIT?), this only happens when the state alters markup:\r\n\r\n```jsx\r\nimport React from 'react';\r\nimport { mount, describeWithDOM } from 'enzyme';\r\n\r\nconst Component = React.createClass({\r\n  getInitialState() {\r\n    return { flag: false };\r\n  },\r\n\r\n  render() {\r\n    return this.state.flag ? <a /> : <div />\r\n  }\r\n});\r\n\r\ndescribeWithDOM('<Component />', () => {\r\n  it('turns on the flag', () => {\r\n    const wrapper = mount(<Component />);\r\n    wrapper.setState({ flag: true });\r\n  });\r\n});\r\n```\r\n\r\n```\r\nError: Invariant Violation: dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a worker thread. Make sure `window` and `document` are available globally before requiring React when unit testing or use ReactDOMServer.renderToString() for server rendering.\r\n```\r\n\r\nThis does not happen if both elements are the same (e.g. `this.state.flag ? <div /> : <div />`).\r\n\r\nJest seemed to have solved this issue, it doesn't happen there, so it might be worth looking how they did it. I can take a look later, but I was wondering if you knew what's causing this.\r\n\r\n[This](http://stackoverflow.com/a/26872245/1247274) SO answer might help, though I'm not sure if it's related."},"comment":{"url":"https://api.github.com/repos/airbnb/enzyme/issues/comments/162684020","html_url":"https://github.com/airbnb/enzyme/issues/58#issuecomment-162684020","issue_url":"https://api.github.com/repos/airbnb/enzyme/issues/58","id":162684020,"user":{"login":"silvenon","id":471278,"avatar_url":"https://avatars.githubusercontent.com/u/471278?v=3","gravatar_id":"","url":"https://api.github.com/users/silvenon","html_url":"https://github.com/silvenon","followers_url":"https://api.github.com/users/silvenon/followers","following_url":"https://api.github.com/users/silvenon/following{/other_user}","gists_url":"https://api.github.com/users/silvenon/gists{/gist_id}","starred_url":"https://api.github.com/users/silvenon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silvenon/subscriptions","organizations_url":"https://api.github.com/users/silvenon/orgs","repos_url":"https://api.github.com/users/silvenon/repos","events_url":"https://api.github.com/users/silvenon/events{/privacy}","received_events_url":"https://api.github.com/users/silvenon/received_events","type":"User","site_admin":false},"created_at":"2015-12-07T22:15:26Z","updated_at":"2015-12-07T22:15:26Z","body":"Thanks for the detailed explanation :+1: Learning so much from you guys."}}