@firebase/rules-unit-testing
stalls on dbRef.set()
with package.json
settings jest.preset:"jest-expo"
but succeeds with jest.preset:"ts-jest"
#8708
Labels
Operating System
Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
Environment (if applicable)
Expo, React Native
Firebase SDK Version
@firebase/[email protected]
Firebase SDK Product(s)
Database
Project Tooling
React-Native app managed with Expo for Android & iOS:
Minimal reproducible example
https://github.com/DrStoop/expoWithJestFirebaseDatabaseEmulator.git
Detailed Problem Description
Minimal reproducible example
https://github.com/DrStoop/expoWithJestFirebaseDatabaseEmulator.git
What platform(s) does this occur on?
Jest testing environment with
jest-expo
presetSummary
jest-expo
preset causesdbRef.set()
to stall when testing database rules with@firebase/rules-unit-testing
I am using firebase realtime database in my expo app and am writing database rules unit tests using
@firebase/rules-unit-testing
and the firebase emulator locally. I encountered the issue that the commandawait assertSucceeds(dbRef.set(5));
in__tests__/firebaseRealtimeDatabaseRules.test.ts
stalls (infinitely) in my test. I created a minimal reproducible example and could nail the cause of the stalling down to thejest.preset: "jest-expo"
inpackage.json
. The test passes without stalling when setting it tojest.preset: "ts-jest"
and it throws a timeout fail when set tojest.preset:"jest-expo"
(also with increases timeouts):I'm running the firebase database emulator with initial command:
jest-expo
presetlocalhost:9000
and initializes the database rules.dbRef.set(value)
method does not send thevalue
itself to the database and the database does not set any values, see emulator debug log:dbRef.set()
methods show the same issue.ts-jest
presetvalue
withdbRef.set(value)
, see database debug log:value
(5
) and displays it in the UI:Question
Why is the jest preset
"jest-expo"
interfering with@firebase/rules-unit-testing
and how can it be fixed? Or am I just missing something? Changing the preset to"ts-jest"
is not an option unless I would run database rules unit tests in isolation in a separate project (which is also not really an option).Thanks in advance!
Note
As this seems like a bug in the interface between an Expo preset
jest-expo
and the firebase emulator, I posted this issue already in the expo repository, but without getting feedback. So I'm hoping to get some hints from the firebase community here, THX!Environment
Expo Doctor Diagnostics
Steps and code to reproduce issue
Minimal reproducible example
https://github.com/DrStoop/expoWithJestFirebaseDatabaseEmulator.git
Steps
npm install
firebase emulators:start --only database --project database
npm run test
will fail as this issue describes due to the{"jest":{"preset": "jest-expo"}}
{"jest":{"preset": "ts-jest"}}
and kill & re-run the test withnpm run test
and the test will succeed without errors because it's not relying onjest-expo
preset anymoreThe text was updated successfully, but these errors were encountered: