firebase / firebase-functions-test

MIT License
232 stars 48 forks source link

How to test.wrap(fn, [?]) to call as anonymous client? #90

Open SrBrahma opened 3 years ago

SrBrahma commented 3 years ago

Version info

firebase-functions-test:"0.2.3"

firebase-functions:"3.11.0"

firebase-admin:"9.1.1"

I can make an authed call test by using test.wrap(fn)(data, {auth: uid: 'anyUid'}), but I also need to test for anonymous authentication call. How can I do it? Is it possible?

Sorry for questioning here, but emailing firebase for those more advanced questions takes some time and some emails for them to understand the point.

taeold commented 2 years ago

Hi @SrBrahma. I'm not sure what is being asked here - can you clarify for us?

For wrapped functions allows you to pass arbitrary javascript object under the auth property. So in your unit test, you can pass whatever property you are using to support calls from anonymous users.

It would help to have an example for the test case you are considering.

SrBrahma commented 2 years ago

As far as I remember, I was needing back then a way to test function made by anon authed users, so I needed a way to be a anon authed user when calling the function, in a test env.

I personally don't need this anymore as I am no longer deving this app and my current one doesn't have anon users.