Here's a summary what I've found so far in the category of "tools for testing Firebase (particularly Realtime Database) code without using a real live Firebase database connection". I'm pretty much only concerned with JavaScript (client side and Node).
firebase-server tries to be a complete replacement for the Realtime Database backend that you can run yourself for local testing. It seems to have some mechanism for doing authentication, but I haven't figured out how to use it. It tries to enforce database rules (using targaryen; see below), but I'm not sure if that currently works since
apparently it is using an out-of-date version of targaryen. (That wouldn't be very useful without some kind of authentication anyway.) You can, however, use it with no authentication or rules; it just allows all reads and writes.
Your local firebase-server instance runs as an actual server in a separate process, and you have to either set up a hosts file to point a domain name at it, or do some bizarre hacking to make the Firebase client connect to "localhost:5555".
MockFirebase looks like it would have been really valuable, but it hasn't been updated since October 2015 and
doesn't support the 3.x API. (Firebase-server may have originally been a wrapper around MockFirebase, but I think it was changed at some point and is now a wrapper around the standard Firebase client library running in offline mode.)
A possible alternative to firebase-server and MockFirebase would be to simply use the official client library and put it in offline mode, but this doesn't work in many cases. For example, if you need to test code that does something like this:
db.ref('path').set(1)
.then(() => {
doSomething();
});
it won't work in offline mode, because the promise returned by
set() will never resolve.
Another alternative is, of course, to inject your own custom mocks into the code you're testing, which I believe is what Kato was suggesting for "real" unit tests.
targaryen looks pretty invaluable for testing database rules offline, assuming it duplicates Firebase's behavior accurately.