5-10% of Jest builds for React tests fail with "debugID may not be empty"

Viewed 248

We are converting our test suite from Karma/Mocha to Jest. For the most part, the conversion worked except 5-10% of builds contain test failures preceded by this warning:

Warning: ReactDebugTool: debugID may not be empty.

It occurs in different test files each time; this warning being the only thing consistent between the failures. We have console.warn set to throw. If we disable that, in addition to a bunch of (non-deterministic) failures, this warning appears:

Warning: Exception thrown by hook while handling onSetChildren: Invariant Violation: Expected hook events to fire for the child before its parent includes it in onSetChildren().

Things we tried

  • Changed the number of workers. Test flakes go down substantially using 4 workers instead of 7, but they are still present occasionally.
  • Upgraded to the latest stable version of React.
  • Deleted the handful of files in our codebase that have inline requires.
  • Checked that npm ls only returned one React and that is deduped across the dependency tree (also verified with find node_modules -type d -name react).
  • Ran the tests with maxWorkers=1 (and, separately, runInBand=true). The error never occurs, but it may be because the order that the tests run in is relatively consistent. (This is unusable for us as a solution because it is too slow.)
  • Patched Jest to output the worker PID alongside the test file as it runs the test suite (with 7 workers). When it found a failure, we ran Jest with maxWorkers=1 with a patched TestSequencer.js to return that exact set of files in the order in which they failed.
  • Analyze the files in the workers that flaked, attempting to see if there is a file that each of these workers have in common. (There was no single file that was shared among all of them.)

Even after all of this, we are not able to create a deterministic reproduction case (or a way to just stop the error from occurring). Any help would be much appreciated!

Debugging details

  • react / react-dom 15.6.1
  • jest 20.0.4

jest-cli configuration

{
  rootDir: '.',
  cacheDirectory: '<rootDir>/tmp-jest',
  setupFiles: ['<rootDir>/node_modules/internal_polyfills/polyfills.min'],
  setupTestFrameworkScriptFile: '<rootDir>/js/tests/setup_jest.js',
  moduleDirectories: ['node_modules', ...modulePaths],
  testURL: 'http://localhost-jest:9000',
  modulePathIgnorePatterns: ['node_modules'],
  testMatch: (array of ~1000 file paths, generated by another function)
}

Note that resetModules=false.

Possible clues

0 Answers
Related