-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
Description
When you use ECMAScript Modules in Node (v13.6.0 for me) combined with Jest, the following error occurs:
SyntaxError: Cannot use import statement outside a module
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
Here is the test code I am trying to execute.
import { checks } from '../../../../src/utils/index.js'
describe('Array type check', () => {
test('to return false when not an array', () => {
expect(checks.array('string')).toEqual(false)
})
})
I suspect the issue is Jest is not configured to run Node code using "type: module" (ECMAScript Modules).
sharathkoppolu, stevgouws, EvgenyOrekhov, arctouch-eltonsantana, dreamyguy and 49 moremetrue, ziishaned, willemmulder, thomas-bouvier, JSONRice and 3 more