score:0
jest currently doesn't understand either import
or export
. it looks like you followed common setup docs for your jest config so you're probably using babel and transpiling your code from using modules to using commonjs, but you're not transpiling your dependencies:
transformignorepatterns: [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$", // <-- do not transform node_modules
"^.+\\.module\\.(css|sass|scss)$",
],
but, what's causing your problem is that one of your exports (amcharts
) needs to be transformed in order to make those import
/export
statements compliant with the commonjs format that jest is expecting.
your easiest fix is probably to edit the transformignorepatterns
:
transformignorepatterns: [
//add other modules here that ship esm that jest doesn't like
'node_modules/(?!@amcharts)',
"^.+\\.module\\.(css|sass|scss)$",
],
so we're saying "go ahead and don't transform anything in node modules unless it matches @amcharts
. if you get more dependencies that need to be transformed, then you can add it to that regex.
for a different solution, if you like experimental features, then you can try turning on jest's experimental support for esm: https://jestjs.io/docs/ecmascript-modules.
Source: stackoverflow.com
Related Query
- How do I unit test amcharts using jest with react and typescript?
- How to unit test a react event handler that contains history.push using Jest and Enzyme?
- How to test with jest and typescript with types a basic react function component
- How to check the value of a nested React component in a unit test with Enzyme and Jest
- How To Unit Test React Component With react-intl, react-router-dom v4 and TypeScript
- How to test React component with children using jest and enzyme?
- how to unit test react reduxsauce saga using jest and enzyme?
- How to test a className with the Jest and React testing library
- How to unit test useEffect cleanUp return function using Jest and Enzyme
- How to test form submission in React with Jest and Enzyme? Cannot read property 'preventDefault' of undefined
- How to test snapshots with Jest and new React lazy 16.6 API
- How to test API calls in react using jest and enzyme?
- how can I test if useState hook has been called with jest and react testing library?
- How to test events created with mousetrap in react using jest
- Unit test method that calls clearInterval with Jest and Enzyme on React
- How to test redux state update with react testing library and jest
- How to properly test React Native Modals using Jest and Native Testing Library
- Jest test for a copy to clipboard method using react with typescript
- How to test a React component that has Router, Redux and two HOCs... with Jest and Enzyme?
- How to set up a chrome extension using React and TypeScript with multiple pages and entry points?
- How to test functions in React with Jest and Enzyme
- react create app, typescript unit test with mocha and chai what is the correct setup to support es6 modules?
- how to test Routes in react using jest and react testing library
- How to test styles and media queries rendered by a React component with Jest and/or Enzyme
- Test suits failed with "SyntaxError: Unexpected token 'export" ' react typescript using jest
- how to test OnSubmit in React using Jest and Enzyme
- How to unit test promise rejection in React and Jest
- stub fetch unit test react with enzyme and jest
- How to test axios api using jest and react testing library?
- How to test react functional component correctly using jest and enzyme?
More Query from same tag
- React/Typescript 2 optional props required together
- Push items into empty State array of objects
- Set active class with react-router Link that has an optional URL parameter
- react state hook wont update on sort even making a copy of the state
- How to render a nested array of React components
- How to customize both, width of the bar & spacing between bar in Highcharts.js
- onClick does not work for custom component
- How to import a file, residing in the same app, as blob using XMLHttpRequest in ReactJS
- React : Save value after edit
- I am having problem while using filter in react Hooks,how can i solve this issue?
- How to refactor this part of component more testably in react?
- Reactjs - How to load and map data in reactjs material table
- Combine arrays and merge keys together for table output
- Is it possible to make SVG equal to path?
- Deploy React Starter Kit (by Kriasoft) to Heroku
- How to add Stripe.js script in React component
- How do I import react as a cdn?
- Handling redux state with filtering, sorting and pagination done in backend
- React Testing Library - testing hooks with React.context
- Object reference comparison in JavaScript
- How can I make a component render onClick in a React functional component?
- Recursive function keeps returning false
- Node/React: How to handle jQuery AJAX when rendering on server?
- How to change routing as component: lazy() to simple routes
- mapping images with gatsby-image
- TypeError: Cannot read property 'byteLength' of undefined - AWS S3 Upload
- Most efficient way for checking the existence of a property
- Radio Button Group in Material-UI
- Why are only one of my states changing upon invoking my function?
- Sanctum with react SPA returning 419 page expired