'Cannot use import statement outside a module although type is module

I'm using ES6 style and want to be consistent of using import from ES6.

Here is my jest test file I'm setting up:

import Get from './Get'

test('Some test', async () => {
    expect(true).toBe(true)
})

And here is my Get file:

import cli from "commander";
import get from "./myHandler.js"

const GET = () => {
    // Doing some stuff here...
}

export default GET

I keep getting:

    C:\...\GET\get.test.js:2
    import Get from './Get';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1773:14)

And I have already added "type": "module", in my package.json as suggested by this and others. What am I doing wrong here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source