Here are a few troubleshooting tips to enable Jest, the JavaScript testing framework, to be able to work with ES modules without needing Babel in the mix for transpilation. Let’s get going with a basic set-up.
package.json
Note: take note of the crucial "type": "module"
part as it’s the least-documented bit and your most likely omission!
After that set-up, you’re free to import
and export
to your heart’s content.
javascript/sum.js
spec/sum.test.js
Hopefully that’ll save you (and future me) some head-scratching.
(Reference: Jest’s EcmaScript Modules docs page)