dimanche 28 février 2021

How to import class to test using ES6 modules

Hello I have a folder structure that looks like this:

  • Folder
    • index.js
    • someClass.js
    • index.html
  • Tests
    • someclass.test.js

I've exported this someClass using export default, imported it using import statement to index.js and after I open index.html, everything works, however I can't import this class to someClass.test.js file and after I run jest I get this error

 **SyntaxError: Cannot use import statement outside a module**

I've also changed type property in package.json file to be module. How to solve this issue?

Aucun commentaire:

Enregistrer un commentaire