{"id":647,"hash":"099356220128d602485ac33770ed801494a6067a8ed797e579140361ca3f82ed","pattern":"Jest gives an error: &quot;SyntaxError: Unexpected token export&quot;","full_message":"I'm using Jest to test my React app.\n\nRecently, I added DeckGL to my app. My tests fail with this error:\n\nTest suite failed to run\n\n/my_project/node_modules/deck.gl/src/react/index.js:21\nexport {default as DeckGL} from './deckgl';\n^^^^^^\n\nSyntaxError: Unexpected token export\n\n  at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:318:17)\n  at Object.<anonymous> (node_modules/deck.gl/dist/react/deckgl.js:9:14)\n  at Object.<anonymous> (node_modules/deck.gl/dist/react/index.js:7:15)\n\nThis looks like an issue with Jest transforming a node module before running it's tests.\n\nHere is my .babelrc:\n\n{\n  \"presets\": [\"react\", \"es2015\", \"stage-1\"]\n}\n\nHere is my jest setup:\n\n\"jest\": {\n    \"testURL\": \"http://localhost\",\n    \"setupFiles\": [\n      \"./test/jestsetup.js\"\n    ],\n    \"snapshotSerializers\": [\n      \"<rootDir>/node_modules/enzyme-to-json/serializer\"\n    ],\n    \"moduleDirectories\": [\n      \"node_modules\",\n      \"/src\"\n    ],\n    \"moduleNameMapper\": {\n      \"\\\\.(css|scss)$\": \"<rootDir>/test/EmptyModule.js\"\n    }\n  },\n\nI seem to have the correct things necessary to transform export {default as DeckGL }. So any ideas whats going wrong?","ecosystem":"npm","package_name":"jestjs","package_version":null,"solution":"This means, that a file is not transformed through TypeScript compiler, e.g. because it is a JS file with TS syntax, or it is published to npm as uncompiled source files. Here's what you can do.\n\nAdjust your transformIgnorePatterns allowed list:\n\n{\n  \"jest\": {\n    \"transformIgnorePatterns\": [\n      \"node_modules/(?!@ngrx|(?!deck.gl)|ng-dynamic)\"\n    ]\n  }\n}\n\nBy default Jest doesn't transform node_modules, because they should be valid JavaScript files. However, it happens that library authors assume that you'll compile their sources. So you have to tell this to Jest explicitly. Above snippet means that @ngrx, deck and ng-dynamic will be transformed, even though they're node_modules.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/49263429/jest-gives-an-error-syntaxerror-unexpected-token-export","votes":261,"created_at":"2026-04-19T04:51:27.256598+00:00","updated_at":"2026-04-19T04:51:27.256598+00:00"}