0

I am using Jest to run tests on my JS code.
But currently, I am having an error: Cannot use import statement outside a module
How can i fix this ?
I looked here but it does not what i am looking for: How to resolve "Cannot use import statement outside a module" in jest

This is my module:

class Path {
  // code in here
}

export default Path;

This is the test file that exported from it:

import Path from "./Path";
// test() ...

This is my folder structure:
enter image description here

Community
  • 1
  • 1
Sonny
  • 166
  • 1
  • 4
  • 12
  • Have you tried import { Path } from "./Path"; – Yatin Gaikwad Jun 14 '20 at 21:25
  • There's a similar thread that explains the issue you are experiencing quite well. Check it out here: https://stackoverflow.com/questions/60372790/node-v13-jest-es6-native-support-for-modules-without-babel-or-esm/61653104#61653104 – Iyanu Adelekan Jun 14 '20 at 21:45

0 Answers0