Open KELEN opened 3 months ago
https://www.kelen.cc/faq/jest-cannot-use-import-statement-outside-a-module
使用 jest 编写测试用例时,如果使用了 import 语句,jest 会以下错误:SyntaxError: Cannot use import statement outside a module。默认情况下 jest 只支持 commonjs 的模块引入方式,不支持 es6 的模块引入方式。这需要 babel 进行代码转换。
https://www.kelen.cc/faq/jest-cannot-use-import-statement-outside-a-module
使用 jest 编写测试用例时,如果使用了 import 语句,jest 会以下错误:SyntaxError: Cannot use import statement outside a module。默认情况下 jest 只支持 commonjs 的模块引入方式,不支持 es6 的模块引入方式。这需要 babel 进行代码转换。