CapacitorGoogleAuth: SyntaxError: Cannot use import statement outside a module
Trying to use Ionic with react framework, and when running a basic debug test, I get the following error:
Jest encountered an unexpected token
Details:
C:\Users\<User>\Documents\GitHub\<appname>\node_modules\@codetrix-studio\capacitor-google-auth\dist\esm\index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { registerPlugin } from '@capacitor/core';
^^^^^^
SyntaxError: Cannot use import statement outside a module
1 | import { IonButton, IonContent, IonHeader,IonInput,IonLoading,IonPage, IonTitle, IonToolbar, IonIcon} from '@ionic/react';
> 2 | import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
| ^
3 | import { useEffect, useState } from 'react';
4 | import { loginUser } from '../firebaseConfig';
5 | import ExploreContainer from '../components/ExploreContainer';
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
at Object.<anonymous> (src/pages/Login.tsx:2:1)
This ONLY occurs when the capactior-google-auth plugin is used, when that’s taken out, the test runs fine, even though there are plenty of other code modules. Does anyone have any idea what’s causing this?
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 3
- Comments: 15
All the node modules. Some times jest holds a cache somewhere inside node modules and certain changes might corrupt it.
I’m not sure if you should keep your jest config inside babel config? use jest.config.js or package.json for that instead? https://jestjs.io/docs/configuration
Also seems that you are using
ts-jestas your transformer:"node_modules/variables/.+\\.(j|t)sx?$": "ts-jest"I don’t think that obeys babel config. You needbabel-jestfor that.