syntaxerror: cannot use import statement outside a module jest

4f568f3f61aba3ec45488f9e11235afa
7 abril, 2023

syntaxerror: cannot use import statement outside a module jest

Which saves a lot of time, of course. Connect and share knowledge within a single location that is structured and easy to search. I recommend using ts-jest for simplicity. Specifically testing a component that imports from @sapper/app. UPDATE Here is a file called example.test.ts located in the src/ directory. So the problem (and perhaps the solution) might be in the babel-jest package.. Be careful out there folks! If I use this, then change the path to include the "js" for the required file, then change the format of the export statements in the required file, and then take all the "require" statements I changed from "import"because now "require" is unknownthis will work, so I'll accept this answer. Right now, the only way to do that is to either create a HTTP content-type on the server of "module" for any file with a .mjs extension and change your file extension on module JavaScript files to ".mjs", or have an HTML script tag with type="module" added to any external