Unexpected token 'export' for >v3
See original GitHub issueHi, I tried to understand for a very long time, but I ran out of ideas. After updating to version 3, tests began to fall with this error, in the place where I call the Api class. The project includes a dependency that was generated using swagger-typescript-api, everything was fine on version 2. Any idea why this is happening? Thanks
Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/Users/r/project/specifications/lib/index.js:16
export class HttpClient {
^^^^^^
SyntaxError: Unexpected token 'export'
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (6 by maintainers)
Top Results From Across the Web
Getting Unexpected Token Export - javascript - Stack Overflow
The problem was that I was changing my code from non-modules to modules and I forgot to delete the imported script file. My...
Read more >Problem with Nuxt3: Unexpected token 'export' #333 - GitHub
I've found a temporary solution. Rename the plugin to fontawesome.client.js, and remove it from nuxt.config.js (Nuxt3 automatically loads it).
Read more >How to fix SyntaxError: Unexpected token 'export' in JavaScript?
In this article, we are going to see How to fix SyntaxError: Unexpected token 'export' in JavaScript? and what are Es6 modules.
Read more >SyntaxError: Unexpected token 'export' - Abhishek Kumar
In case you are getting error like 'Unexpected token export' while starting the server, then export like below in schema.js
Read more >syntaxerror unexpected token 'export' typescript - You.com
The "Uncaught SyntaxError Unexpected token 'export'" occurs for 2 main reasons: Using the ES6 Module syntax in a Node.js application without type to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@js2me Thanks for the help. You pushed me in the right way. jest.config.json
these lines are needed
@js2me Yes