Babel plugin-syntax-dynamic-import not in effect when running with Jest
See original GitHub issueMy project builds and runs fine with webpack normally. When I run it under Jest, it doesn’t like my dynamic import:
const ExtensionReducer = await import('../../../reducers/extension');
^^^^^^
SyntaxError: Unexpected token import
46 |
47 | class LinksContainer extends React.Component {
> 48 | constructor (props) {
49 | super(props)
50 |
51 | this.state = {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
at Object.<anonymous> (src/components/pixel/links/linksContainer.jsx:48:46)
at Object.<anonymous> (src/components/pixel/firstPixelCreator/firstPixelCreator.jsx:22:46)
.babelrc:
{
"presets": [[
"@babel/preset-env", {
"targets": {
"chrome": "60"
}
}], "@babel/react"],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-decorators",
"@babel/plugin-proposal-object-rest-spread"]
}
I tried asking #need-help on discord and they didn’t know what was up.
I share the same webpack config with Jest that I use normally to build.
Issue Analytics
- State:
- Created 5 years ago
- Comments:19
Top Results From Across the Web
Can't test a function with a dynamic import with Jest and babel ...
You use dynamic-import-node plugin twice. I did the same with "presets": [ "react-app", ],.
Read more >Using with webpack - Jest
Non-Babel JavaScript transformations can be handled with Jest's transform config ... you need to enable the dynamic-import-node plugin.
Read more >babel-plugin-syntax-dynamic-import does not transpile-Reactjs
Coding example for the question babel-plugin-syntax-dynamic-import does not transpile-Reactjs.
Read more >Learn Handling Dynamic Imports – Testing React Applications ...
Kent installs a babel plugin to transform dynamic imports to something that can be run in Node that Jest understands.
Read more >jest encountered an unexpected token import - You.com | The ...
The way I got around it was to install two class babel plugins: ... ,global,jest){import { configure } from "enzyme"; ^ SyntaxError: Unexpected...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop 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
Top GitHub Comments
Also I don’t know how people normally figure this insane shit out
it’s working with babel 7, react, jest for react use
for jest use