priyanka
priyanka

Reputation: 25

Error in aws-amplify style.css while running the npm test

Had issue while running the npm test

C:\projects\Test\node_modules\@aws-amplify\ui\dist\style.css:13:root {^

error:

SyntaxError: Unexpected token :

  at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
  at Object.<anonymous> (node_modules/aws-amplify-react/src/Amplify-UI/Amplify-UI-Components-React.jsx:5:1)

here are my import statements

import Amplify from 'aws-amplify'; import { AuthPiece } from 'aws-amplify-react'; import { Auth, Logger, JS } from 'aws-amplify';

If I comment out the style.css it works without any errors. But how can I remove this issue so that it doesnt cause issue to others when I commit code.

Had checked all the existing answers provided in different forums.But that doesnt work for me.

Upvotes: 1

Views: 960

Answers (1)

xveganxxxedgex
xveganxxxedgex

Reputation: 158

I ran into this problem as well, and this thread helped me resolve it. In my case, I needed to install identity-obj-proxy package and map it to the jest config:

npm install --save-dev identity-obj-proxy

package.json

"jest": {
    "moduleNameMapper": {
      "\\.(css|less)$": "identity-obj-proxy"
    }
  }

I hope this helps!

Upvotes: 1

Related Questions