Esm: How to enable es6 import modules in Jest in a ESM used back-end?

Created on 28 Apr 2020  路  3Comments  路  Source: standard-things/esm

I'm using a NodeJs backend with ESM package enabled mode to use es6+ import modules system when I'm trying to access a file in my test, even if I use require in my test file because target file uses import/export, it throws this error:

SyntaxError: Cannot use import statement outside a module

I know, I can use babel to solve Jest problem, but due to my main project files (which are using ESM), is there any solution to config Jest with ESM?

All 3 comments

Any luck?

@pouyajabbarisani The better solution is to use Babel to transpile ES6 import ;)

See you
Romain

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bensampaio picture bensampaio  路  3Comments

pvdlg picture pvdlg  路  3Comments

kherock picture kherock  路  3Comments

StphamZ picture StphamZ  路  3Comments

deepsweet picture deepsweet  路  3Comments