jeudi 24 septembre 2020

How to Fix Jest error : ReferenceError: regeneratorRuntime is not defined

I'm getting two errors with Jest using React:

Test suite failed to run
    ReferenceError: regeneratorRuntime is not defined
      18 | export const db = firebaseApp.firestore();
      19 | 
    > 20 | export const generateUserDocument = async (user, additionalData) => {
         |                                  ^
      21 |     if (!user) return;
      22 | 
      23 |     const userRef = db.doc(`users/${user.uid}`);

Jest encountered an unexpected token

This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.


Details:

SyntaxError: Unexpected token '.' import './Button.css'

This is my babelrc file

{
    "presets": [
        "@babel/env",
        "@babel/react"
    ],
    "plugins": [
        "@babel/plugin-proposal-class-properties"
    ]
}

How do I fix the issue since npm run test keeps failing with the above error message?

Aucun commentaire:

Enregistrer un commentaire