firebase-mock icon indicating copy to clipboard operation
firebase-mock copied to clipboard

Add support for messaging in Admin SDK

Open raman-nbg opened this issue 5 years ago • 9 comments

Currently Firebase messaging in the admin SDK is not supported. Are there any plans to add support for this?

In my case I need to test/mock multicast message (sendMulticast()).

raman-nbg avatar Dec 15 '19 19:12 raman-nbg

Hi @raman-nbg, any good PR to add support for mocking Firebase messaging in the admin SDK would be gladly accepted! Cheers.

dmurvihill avatar Dec 16 '19 02:12 dmurvihill

Ok, going to try this.

But one question about the implementation:

Messaging.send(message) (https://firebase.google.com/docs/reference/admin/node/admin.messaging.Messaging.html#send) takes a message as an argument. Should I validate this message according to https://firebase.google.com/docs/reference/admin/node/TokenMessage.html?

raman-nbg avatar Dec 16 '19 17:12 raman-nbg

Or should I implement it like described in erros.md?

raman-nbg avatar Dec 16 '19 18:12 raman-nbg

Anyone else interested in mocking admin FCM? @op? If so, I'd love to get your opinion.

Unless it makes a big difference in your workflow, @raman-nbg, I'd suggest preserving the pattern from errors.md and not bother with validating the message.

Note that the message will be a Message instance and not necessarily a TokenMessage!

dmurvihill avatar Dec 16 '19 18:12 dmurvihill

One more thing: we are migrating away from this repo in the near future; for now, if you could open your PR against https://github.com/dmurvihill/firebase-mock/, I will be publishing from there.

dmurvihill avatar Dec 16 '19 18:12 dmurvihill

Created PR: https://github.com/dmurvihill/firebase-mock/pull/43

raman-nbg avatar Dec 17 '19 00:12 raman-nbg

In the implementation you can see, that this is one is very simple. Messaging is stateless (send message, get result and forget about it) but the other components like firestore are stateful.

Messaging could also be mocked easily using sinon. But I think we should still add this feature. It's more convenient to have the same test behaviour for all firebase components.

raman-nbg avatar Dec 17 '19 00:12 raman-nbg

The change is arleady merged into master, but not release yet. Is there any plan to release a new version soon?

raman-nbg avatar Feb 02 '20 14:02 raman-nbg

Ping!

mull avatar Nov 30 '20 16:11 mull