jest: Watch mode crashes with ProcessTerminatedError in new test pattern mode

git clone https://github.com/facebook/react.git
cd react
yarn
npm test -- --watch Perf

t
returns <Enter>
screen shot 2017-02-22 at 6 27 29 pm

The watch mode crashes:

 FAIL  src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
  ● Test suite failed to run

    ProcessTerminatedError: cancel after 2 retries!
      
      at Farm.<anonymous> (node_modules/worker-farm/lib/farm.js:81:25)
      at Array.forEach (native)
      at Farm.<anonymous> (node_modules/worker-farm/lib/farm.js:75:36)
      at ontimeout (timers.js:365:14)
      at tryOnTimeout (timers.js:237:5)
      at Timer.listOnTimeout (timers.js:207:5)
      

A worker process has quit unexpectedly! Most likely this an initialization error.


 RUNS  src/renderers/dom/shared/__tests__/findDOMNode-test.js
 RUNS  src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
 RUNS  eslint-rules/__tests__/warning-and-invariant-args-test.js
 RUNS  src/renderers/__tests__/ReactMockedComponent-test.js

Test Suites: 79 skipped, 10 passed, 10 of 126 total
Tests:       1469 skipped, 19 passed, 1488 total
Snapshots:   0 total
Time:        6snpm ERR! Test failed.  See above for more details.

If I just run npm test -- --watch ReactBrowserEventEmitter I can’t reproduce this.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 33 (23 by maintainers)

Most upvoted comments

Try adding jest.useFakeTimers(); above your it blocks. You don’t need to make any global config changes that way.

describe(SomeAnimatedComponent, () => {
    jest.useFakeTimers();

    it('works', () => {
        // ...tests
    });
});

@hakimelek

Getting this issue in our app with react-native while running tests. Adding: "jest": { ... "timers": "fake" ... } resolved the issue. Stacktrace (without timers: fake ): TypeError: Cannot read property 'Object.<anonymous>' of null at Runtime._execModule (/opt/application/node_modules/jest-runtime/build/index.js:518:64) at Runtime.requireModule (/opt/application/node_modules/jest-runtime/build/index.js:332:14) at Runtime.requireModuleOrMock (/opt/application/node_modules/jest-runtime/build/index.js:408:19) at Function.bezier (/opt/application/node_modules/react-native/Libraries/Animated/src/Easing.js:228:13) at ease (/opt/application/node_modules/react-native/Libraries/Animated/src/Easing.js:94:14) at TimingAnimation._easing (/opt/application/node_modules/react-native/Libraries/Animated/src/Easing.js:260:8) at TimingAnimation.onUpdate (/opt/application/node_modules/react-native/Libraries/Animated/src/animations/TimingAnimation.js:138:6) at ontimeout (timers.js:469:11) at tryOnTimeout (timers.js:304:5) at Timer.listOnTimeout (timers.js:264:5)

Same error with 21.0.0.alpha.2:


  ● Console

    console.info node_modules/@storybook/react/dist/server/babel_config.js:67
      => Loading custom .babelrc
    console.error node_modules/fbjs/lib/warning.js:36
      Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.
    console.error node_modules/fbjs/lib/warning.js:36
      Warning: Portal: React.createClass is deprecated and will be removed in version 16. Use plain JavaScript classes instead. If you're not yet ready to migrate, create-react-class is available on npm as a drop-in replacement.
    console.error node_modules/fbjs/lib/warning.js:36
      Warning: Invalid argument supplid to oneOfType. Expected an array of check functions, but received undefined at index 1.

TypeError: Cannot read property '_h' of undefined
    at isUnhandled (/src/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:127:13)
    at isUnhandled (/src/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:133:26)
    at Immediate._onImmediate (/src/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:110:8)
    at processImmediate [as _immediateCallback] (timers.js:396:17)
  ● Test suite failed to run

    ProcessTerminatedError: cancel after 2 retries!
      
      at Farm.<anonymous> (node_modules/worker-farm/lib/farm.js:81:25)
      at Array.forEach (native)
      at Farm.<anonymous> (node_modules/worker-farm/lib/farm.js:75:36)
      at Timer.listOnTimeout (timers.js:92:15)

A worker process has quit unexpectedly! Most likely this is an initialization error.
error Command failed with exit code 1.