How to fix Jest "Unexpected token" in package code
It's 2019 and we're still figuring out how to share code. Packages are shipping ES6 by default, and denoting commonjs files with a
.cjs.js extension. Since most of us are bundling with Webpack it's cool until we run it through Jest (node). Two ways to solve this are either to explicitly
import thing from 'library/thing.cjs.js' or point to it using
moduleNameMapper in Jest config.