firebase / firebase-functions-test

MIT License
231 stars 48 forks source link

ECONNREFUSED when using clearFirestoreData on Node 18 #190

Open ericvera opened 1 year ago

ericvera commented 1 year ago

There is already a fix for this issue, but I could not find a related bug. (Pull request #184).

The problem is that node 18 and node 16 handle localhost differently. The code is hardcoded to use localhost which no longer works.

In addition to that it seems to load the process env variable to define the emulator host too soon which the pull request also addresses.

Version info

firebase-functions-test: 3.0.0

firebase-functions: 4.2.0

firebase-admin: 11.5.0

Node: v18.13.0

Test case

Using node 18+ attempt to run

await firestoreFunctionsTest.firestore.clearFirestoreData({ projectId: 'project-id', })

Expected behavior

It works.

Actual behavior

Fails with ECONNREFUSED ::1:8080.