@@ -408,49 +408,6 @@ describe('ReactDOM', () => { |
408 | 408 | } |
409 | 409 | }); |
410 | 410 |
|
411 | | - it('throws in DEV if jsdom is destroyed by the time setState() is called', () => { |
412 | | - class App extends React.Component { |
413 | | - state = {x: 1}; |
414 | | - componentDidUpdate() {} |
415 | | - render() { |
416 | | - return <div />; |
417 | | - } |
418 | | - } |
419 | | - const container = document.createElement('div'); |
420 | | - const instance = ReactDOM.render(<App />, container); |
421 | | - const documentDescriptor = Object.getOwnPropertyDescriptor( |
422 | | - global, |
423 | | - 'document', |
424 | | - ); |
425 | | - try { |
426 | | - // Emulate jsdom environment cleanup. |
427 | | - // This is roughly what happens if the test finished and then |
428 | | - // an asynchronous callback tried to setState() after this. |
429 | | - delete global.document; |
430 | | - |
431 | | - // The error we're interested in is thrown by invokeGuardedCallback, which |
432 | | - // in DEV is used 1) to replay a failed begin phase, or 2) when calling |
433 | | - // lifecycle methods. We're triggering the second case here. |
434 | | - const fn = () => instance.setState({x: 2}); |
435 | | - if (__DEV__) { |
436 | | - expect(fn).toThrow( |
437 | | - 'The `document` global was defined when React was initialized, but is not ' + |
438 | | - 'defined anymore. This can happen in a test environment if a component ' + |
439 | | - 'schedules an update from an asynchronous callback, but the test has already ' + |
440 | | - 'finished running. To solve this, you can either unmount the component at ' + |
441 | | - 'the end of your test (and ensure that any asynchronous operations get ' + |
442 | | - 'canceled in `componentWillUnmount`), or you can change the test itself ' + |
443 | | - 'to be asynchronous.', |
444 | | - ); |
445 | | - } else { |
446 | | - expect(fn).not.toThrow(); |
447 | | - } |
448 | | - } finally { |
449 | | - // Don't break other tests. |
450 | | - Object.defineProperty(global, 'document', documentDescriptor); |
451 | | - } |
452 | | - }); |
453 | | - |
454 | 411 | it('reports stacks with re-entrant renderToString() calls on the client', () => { |
455 | 412 | function Child2(props) { |
456 | 413 | return <span ariaTypo3="no">{props.children}</span>; |
|