score:4
Accepted answer
here is how i resolved the issue.
- • add the following content to your .babelrc file and make sure .babelrc is in the root folder
{ "presets": ["env","react"] }
- • make sure you exclude static assets like css, images, scss, pdf, fonts, etc. add the following to package.json as highlighted in the screenshot
"modulenamemapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootdir>/__mocks__/filemock.js",
"\\.(css|less)$": "<rootdir>/__mocks__/stylemock.js"
}
screenshot:
score:0
if anybody comes here to figure out what is happening, i think the accepted answer is not related to the issue here.
when the file extension is .js
and if you try to write jsx in that file, linter will complain if you have a correct eslint configuration.
instead, try to change the file extension to .jsx
or .tsx
(if typescript involved).
Source: stackoverflow.com
Related Query
- Jest Error Unexpected token on react component
- Unexpected token < error in react router component
- ' Jest encountered an unexpected token { ' error on react application
- Error of unexpected token import in react jest test
- Getting Module parse failed: Unexpected token (1:0) error when I try to import css file for a specific component in react
- Unexpected token error in React Component
- Fragments giving Unexpected token error in React 16.2
- React JS Jest causing "SyntaxError: Unexpected token ."
- spread operator in react throwing error of Unexpected token
- Testing an error thrown by a React component using testing-library and jest
- Jest tests on React components: Unexpected token "<"
- React Jest test fails to run with ts-jest - Unexpected token on imported file
- Jest with Create React App: Test suite failed to run - Unexpected token
- Arrow function is considered unexpected token in React component using babel
- React Jest test fails to run with ts-jest - Encountered an unexpected token on imported file
- Unexpected token '=' in React Component
- Error when running jest on a react native + typescript app (Jest encountered an unexpected token)
- React Native: Transform Error for Unexpected Token (
- Jest encountered an unexpected token when working with React TypeScript
- React Jest - Unexpected token import
- Babel 7 Unexpected token for React component
- React testing with Jest and Enzyme (in Symfony) got "Syntax Error: Unexpected token import"
- Jest encountered an unexpected token with react + konva and/or react-konva
- React scripts start is giving Unexpected token error
- Testing React component with Jest gives 'Cannot find module' error
- Testing react components: Jest encountered an unexpected token
- Jest error Unexpected token ... (ES6)
- React app: Jest encountered an unexpected token
- Simple Webpack + React + ES6 + babel example doesn't work. Unexpected token error
- I have an error with my jsconfig.json in react js says throw err Unexpected token } in JSON at position
More Query from same tag
- With a `new Request` in Node/React, how to pass params with a GET request?
- How could I make react-create-app to minify my code?
- Why new Date() won't render inside a JSX element (React)
- Displaying a different option than selected value in MUI's autocomplete
- How to conditionally render a component when I am at my index route with Reach-Router (or my top level route)?
- Test Coverage React, Istanbul -_registerComponent(...): Target container is not a DOM element
- I have a react problem that is driving me crazy
- Correct way to select dom element by className in React and Gatsby
- How to import&use javascript functions in jsx?
- Monaca Android App crashes when cordova-plugin-local-notification tries to play a mp3 file
- Multiple values are getting selected in radio options
- React router displaying Multiple components at the same time
- ReactJS Class Component Rendering Twice
- React - Cloud FireStore - How can I add pagination to this component?
- Reset input field's value with a ref?
- Ract FontAwesome ES6 usage
- Cornerstone Tools do not work (after following doc)
- React fetch Firebase get unique key value
- Property 'Group' does not exist on type 'ForwardRefExoticComponent<InputProps & RefAttributes<HTMLInputElement>>'
- Test for displaying button only when conditions are true
- How to setup form with multiple Checkboxes which only one can be "checked" with Material-UI components?
- ownProps in list item edit value disappears
- Why useState hook causes unnecessarily re-render cycle in React?
- React and importing classes
- try-catch statement in React JSX
- Get a reference to an element in React for using 'fromEvent' method of rxjs
- get html saved as string from db and use it as react html in react js
- DRY react Code multiple similar functions
- this.setState is not a function error is persistent even though I have followed many examples that use the same code
- React: Is there a way to append the same instance of a component to two separate child components?