Unexpected token 'export' when using `@aws-sdk` with Jest
See original GitHub issueI have created a new worker using npx wrangler init
with typescript. I am using the @aws-sdk/client-eventbridge
package in my worker. However, when I try and mock it in tests using aws-sdk-client-mock
I get the following error.
.../node_modules/uuid/dist/esm-browser/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { default as v1 } from './v1.js';
This appears to be an ES module issue and only occurs when I have new EventBridgeClient({})
in my test code.
My jest config looks like this.
module.exports = {
preset: 'ts-jest',
testEnvironment: 'miniflare',
};
If I change testEnvironment
to node
, the error no longer occurs and the test will pass. However, I loose the miniflare benefits in jest.
Is there something I’m missing here to get this working with the miniflare
test environment?
Issue Analytics
- State:
- Created a year ago
- Reactions:8
- Comments:11
Top Results From Across the Web
Jest gives an error: "SyntaxError: Unexpected token export"
This means, that a file is not transformed through TypeScript compiler, e.g. because it is a JS file with TS syntax, or it...
Read more >nx jest unexpected token 'export' - You.com | The AI Search ...
Current Behavior. The error Jest encountered an unexpected token when writing a test for a library that depends on another library, coming from...
Read more >Mocking modular AWS SDK for JavaScript (v3) in Unit Tests
But we keep it short and simple to focus on our tests. Example code for unit testing. All the examples below use Jest...
Read more >stryker-mutator/stryker - Gitter
And the unexpected token is in the line: import { shallowMount } from "@vue/test-utils";. I have configured Stryker to use my Jest config.js...
Read more >Jest: Unexpected Token Export With React-Navigation
Unexpected token is similar to syntax error but more specific. react-color on gitmemory. cd react-node-boilerplate npm i aws-sdk multer-s3 multer path.
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
https://github.com/microsoft/accessibility-insights-web/pull/5421#issuecomment-1109168149/
This solve my problem create a resolver. the uuid has a incompatibility with jest.
@maxy4u as @andreMycroft mentioned, the resolver. He could be a little bit more specific I guess 😝 : https://github.com/microsoft/accessibility-insights-web/pull/5421/commits/9ad4e618019298d82732d49d00aafb846fb6bac7