Firebase emulators:exec errors when running a Jest test script
See original GitHub issue[REQUIRED] Environment info
firebase-tools: 7.10.0
Node version: v8.16.2
jest
version: 24.9.0
Platform: macOS Mojave 10.14.6
[REQUIRED] Test case
You don’t need actual test files to repro this bug - it occurs with or without actual files to test.
// package.json
{
"name": "firestore-bug-demo",
"version": "0.0.1",
"description": "example",
"scripts": {
"test": "jest -i"
},
"devDependencies": {
"jest": "^24.9.0"
}
}
[REQUIRED] Steps to reproduce
Run:
$ firebase emulators:exec --only firestore "npm run test"
[REQUIRED] Expected behavior
I expect that my test suite is run after the Firestore emulator starts up.
[REQUIRED] Actual behavior
It consistently errors out with the following logs:
$ firebase emulators:exec --only firestore "npm run test"
⚠ Could not find config (firebase.json) so using defaults.
i emulators: Starting emulators: firestore
⚠ No Firestore rules file specified in firebase.json, using default rules.
i firestore: Serving ALL traffic (including WebChannel) on http://localhost:8080
⚠ firestore: Support for WebChannel on a separate port (8081) is DEPRECATED and will go away soon. Please use port above instead.
i firestore: Emulator logging to firestore-debug.log
✔ firestore: Emulator started at http://localhost:8080
i firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
i Running script: npm run test
> firestore-bug-demo@0.0.1 test /Users/johngcook/Developer/projects/demo/tmp
> jest -i
/usr/local/bin/firebase[55942]: ../src/node_file.cc:1441:void node::fs::RealPath(const FunctionCallbackInfo<v8::Value> &): Assertion `(argc) >= (3)' failed.
1: 0x100ce8dad node::Abort() (.cold.1) [/usr/local/bin/firebase]
2: 0x10003abdd node_module_register [/usr/local/bin/firebase]
3: 0x100039d35 node::AddEnvironmentCleanupHook(v8::Isolate*, void (*)(void*), void*) [/usr/local/bin/firebase]
4: 0x10006e283 node::fs::RealPath(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/firebase]
5: 0x100215063 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/usr/local/bin/firebase]
6: 0x10021454e v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/firebase]
7: 0x100213c1a v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/firebase]
8: 0x3f9fc815be3d
9: 0x3f9fc81118d5
✔ Script exited successfully (code 0)
i Shutting down emulators.
i Stopping firestore emulator
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Firebase emulator leaking when using with Jest - Stack Overflow
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper...
Read more >Test your Cloud Firestore Security Rules | Firebase - Google
Use the @firebase/rules-unit-testing module to interact with the emulator that runs locally. If you get timeouts or ECONNREFUSED errors, double-check that the ...
Read more >Testing with Jest and firebase-functions-test - Reddit
I am running my test on my cloud functions locally and I make use of the locally running firestore emulator.
Read more >Firebase Trigger Functions Testing with JEST and Emulators
... 2: Writing Tests ] In this part we will be using the local Firebase Functions and Firestore emulators. Using Jest, we will...
Read more >Testing Firebase Functions with the emulators suite
If you don't get this error, make sure you've updated the environment variable and initialized firebase-functions-test without configuration.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the same issue, fixed by using
npx firebase emulators:exec
instead offirebase emulators:exec
andnpx jest
instead ofjest
ornpm run jest
Strangely this problem was fixed by removing the
firebase-cli
binary I installed with the auto-install script (curl -sL firebase.tools | bash
) and reinstallingfirebase-cli
with Homebrew.Based on the error logs there’s clearly some Node issue occurring when trying to run Jest since the error is thrown by the Node runtime. Does
firebase-cli
use whatever Node version is on a system’s PATH?