1

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.

1 Answer 1

1

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.