Posts

Showing posts with the label Es6 Modules

Babel-jest Doesn't Handle ES6 Within Modules

Answer : By default any code in node_modules is ignored by babel-jest , see the Jest config option transformIgnorePatterns . I've also created a PR on your example repo, so you can see it working. While this works, I've found it to be extremely slow in real applications that have a lot of dependencies containing ES modules. The Jest codebase has a slightly different approach to this as you can find in "babel-jest transforming dependencies" (sorry, won't let me post more than 2 URLs) . This can also take much longer on Windows, see "Taking 10 seconds on an empty repo" . If doing "unit" testing, mocking is probably the better way to go. You could try adding the transform-es2015-modules-commonjs plugin to your babel config file for testing only. Here is an example config file which tells babel to transpile modules only when in a testing environment. You can put it underneath your presets: { "presets": [ "react...