flatMap doesn't work in yarn test javascript

A coworker of mine found the solution. Apparently flatMap isn't supported by Node.js:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap#Browser_compatibility


flatMap is now supported in node 11+ as said below, see the same link.


For what it is worth, using a react polyfill package also worked for me. I can control my own local environment, but the build system I have to work with is more restricted and used by multiple teams.

npm package: react-app-polyfill

Usage:

// setupTests.js (jest)
// Using ie9 polyfills as the "kitchen sink" of polyfills
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';

This works for Node v10.16.0, what I have currently.