Integration tests with Firestore

744 views
Skip to first unread message

James Crowley

unread,
May 4, 2019, 10:28:42 AM5/4/19
to Firebase Google Group
Given the emulators only currently work for security rule tests, how do you folks run CI integration tests against firestore, such that they don’t clash when running builds across multiple branches?

In a non-firebase world, I’d just create a fresh database and drop it afterwards, but obviously doesn’t work when you can only have one. Do you prefix the table names everywhere? Or automate creating new google projects and dropping them again?

Thanks

James

Sam Stern

unread,
May 5, 2019, 4:28:43 PM5/5/19
to Firebase Google Group
Right now people commonly do one of a two things:

* Create a separate Firebase project for running tests against.  
* Run tests at a unique prefix path in the database.  For example in Firestore you could create a new root-level collection for each test execution and then treat that as the new database "root" for the remainder.  

That said we have some improvements coming to our emulators in the near future, look out for that soon!  It should help address your use case. 

Sam

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/9ecb63fa-c4e2-4b86-b4cb-89c5a5e54a3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Crowley

unread,
May 6, 2019, 11:42:04 AM5/6/19
to Firebase Google Group
Many thanks Sam. 

Re your second point, am I right in thinking you're proposing using a collection as essentially the top level 'database' and subcollections beneath? My understanding was there were still limitations re sub collections in that you couldn't treat them entirely as collections in themselves. Am I mistaken? If so I might explore this approach more.

Definitely looking forward to improvements in the emulators - if we can actually point our *running* JS web app at the emulator that would be super useful for offline development in general too, not just running tests.

Thanks

J


On Sunday, 5 May 2019 22:28:43 UTC+2, Sam Stern wrote:
Right now people commonly do one of a two things:

* Create a separate Firebase project for running tests against.  
* Run tests at a unique prefix path in the database.  For example in Firestore you could create a new root-level collection for each test execution and then treat that as the new database "root" for the remainder.  

That said we have some improvements coming to our emulators in the near future, look out for that soon!  It should help address your use case. 

Sam

From: James Crowley <james....@gmail.com>
Date: Sat, May 4, 2019, 7:28 AM
To: Firebase Google Group

Given the emulators only currently work for security rule tests, how do you folks run CI integration tests against firestore, such that they don’t clash when running builds across multiple branches?

In a non-firebase world, I’d just create a fresh database and drop it afterwards, but obviously doesn’t work when you can only have one. Do you prefix the table names everywhere? Or automate creating new google projects and dropping them again?

Thanks

James

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

Sam Stern

unread,
May 6, 2019, 12:47:36 PM5/6/19
to Firebase Google Group
Hi James,

To illustrate what I was saying (I typed my original reply on a phone).  Imagine your normal DB looks like this:

Users - /users/{userId}
Posts - /posts/{postId}

Then for testing you could create isolation by creating a subspace for each test run

Users (in test) - /tests/{testId}/users/{userId}
Posts (in test) - /tests/{testId}/posts/{postId}

I recently read a blog post about a Firestore developer speeding up their tests dramatically using this but I can't find the link now.  I will follow up if I find it!

- Sam

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Sam Stern

unread,
May 6, 2019, 1:23:41 PM5/6/19
to Firebase Google Group

James Crowley

unread,
May 11, 2019, 10:59:01 AM5/11/19
to fireba...@googlegroups.com
Thanks for the explanation and link Sam, much appreciated :)

Am I right in thinking the announced improvements to the firebase emulator at I/O doesn't change anything from my perspective? (ie web sdk can't point to it yet and nor can integration tests aside from security rules?)

Thanks

J

Sam Stern

unread,
May 11, 2019, 7:22:43 PM5/11/19
to Firebase Google Group
Hey James,

You're mostly correct.  The new emulators can't yet talk to the Web SDK in the browser because they can't speak WebChannel, but we're hoping to land that soon.  They can talk to Android or iOS clients directly or they can also talk to the JS client running in a Node environment since all of those use gRPC.  So if you can run your tests outside of the browser, you can do your integration tests against the emulator. 

In general our goal is to enable all Firebase testing scenarios to use the emulator, so keep an eye out for future improvements. 

- Sam

Carl-Gustaf Harroch

unread,
Jul 15, 2019, 9:39:57 PM7/15/19
to Firebase Google Group
Hi Sam,

Is there any place where I can follow the progress of the feature? Is the emulator develop in the open?

thanks,
Carl
J

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

Disclaimer: The information in this e-mail and any attachments is the property of Novoda Ltd and is confidential and may be legally privileged. This e-mail is intended solely for the person or organisation to which it is addressed. Any disclosure, copying or other use of the information by any person or organisation who is not the intended recipient is strictly prohibited and may be unlawful. If you have received this e-mail in error, please inform the sender immediately and delete/destroy this e-mail and any copies of it. Novoda Ltd has taken reasonable precautions to minimise the risk of any software viruses which may damage your systems, but we advise that you take the necessary steps to ensure that no virus contamination is suffered. Novoda Ltd does not accept any liability for any loss or damage caused by the transmission of any virus.

Novoda Ltd, Company No: 347444, Registered in Scotland Registered Office: C/O Alexander Sloan, 180 St Vincent Street, Glasgow G2 5SG.  VAT Registration Number  GB 984 2525 93

Sam Stern

unread,
Jul 16, 2019, 12:06:18 PM7/16/19
to Firebase Google Group
Hi Carl,

The Firestore emulator itself is not developed in the open, it's a JAR file we build internally that is downloaded by the Firebase CLI (which is open source).  We are getting much closer to web support for Firestore, there has been steady progress on getting a WebChannel implementation in Java.  I can't offer a hard timeline, but I hope to have good news soon!

- Sam

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

ca...@novoda.com

unread,
Jul 17, 2019, 10:00:21 AM7/17/19
to fireba...@googlegroups.com
Hi Sam, 
Thanks for the update, that is great news. Looking forward.
Regards,
Carl


For more options, visit https://groups.google.com/d/optout.


--
Regards, Carl-Gustaf Harroch | CTO @ Novoda.com
Tel: +44 (0) 7 725 721 005
Reply all
Reply to author
Forward
0 new messages