ReferenceError: self is not defined on Jest tests firebase@10.12.3 #8365
Closed
Description
opened on Jul 15, 2024
Operating System
iOS 16+
Browser Version
Chrome latest
Firebase SDK Version
10.12.3
Firebase SDK Product:
Analytics, Auth, Firestore, Functions, Remote-Config
Describe your project's tooling
Ionic Stencil app with Jest
Describe the problem
Running Jest tests I got this error anywhere I had imported firebase, I'm using the emulator on jest. Here is my command:
"test.ci": "firebase emulators:exec --only firestore 'stencil test --spec --ci --coverage --exit'",
Rolling back to firebase@10.12.2 fixed the issue.
FAIL src/components/pages/sw-subscribe-success-page/sw-subscribe-success-page.spec.ts
● Test suite failed to run
ReferenceError: self is not defined
9 | import { Analytics, getAnalytics } from "firebase/analytics"
> 11 | import firebaseCompat from "firebase/compat/app"
| ^
12 | import "firebase/compat/auth"
13 | import "firebase/compat/firestore"
14 | import "firebase/compat/functions"
at Object.<anonymous> (node_modules/@firebase/app-compat/src/index.ts:26:21)
at Object.<anonymous> (node_modules/firebase/compat/app/dist/index.cjs.js:3:16)
at Object.require (src/global/firebase.ts:11:1)
at Object.require (src/global/native.ts:4:1)
at Object.require (src/global/workout-utils.ts:2:1)
at Object.require (src/reducers/edit-workout.ts:2:1)
at Object.require (src/reducers/index.ts:5:1)
at Object.require (src/store/index.ts:3:1)
at Object.require (src/components/pages/sw-subscribe-success-page/sw-subscribe-success-page.tsx:3:1)
at Object.<anonymous> (src/components/pages/sw-subscribe-success-page/sw-subscribe-success-page.spec.ts:1:1)
Steps and code to reproduce issue
For our app I can update from Firebase 10.12.2 to 10.12.3 to trigger the error. Rolling back to 10.12.2 fixes it.
Activity