8

I have some tests for security rules and they prime up a dataset to the local Firestore emulator (using the @firebase/testing library, pretty much as described here). The tests mostly work, so I think the data really gets to Firestore.

But I cannot see it in the emulator UI.

http://localhost:4000/ > Firestore emulator > Go to emulator shows empty data

Related, I wonder what is the role of the ”project ID” parameter in emulation? It is required when setting up the Firebase app object, but where is it used? The emulator does not provide me a list of emulated projects, to pick from.

Confused.


Ways to replicate (as requested):

$ git clone git@github.com:akauppi/GroundLevel-es6-firebase-web.git
$ cd GroundLevel-es6-firebase-web/rules-test

# You only need to work in the rules-test subproject

$ npm install
...

In another terminal (same folder):

$ npm run start    # leave running...
$ npm run test:symbols

The tests should pass (one is skipped).

The running of the tests has primed data to the emulator, and it should still be there. Project id abc (see "Using session: abc" on the output).

http://localhost:4000/ > Go to emulator

Expected:

  • being able to select project abc
  • being able to see the primed data (btw. it's in data.js)

Actual:

  • there is no project id selection
  • there is no data

screenshot of Firestore emulator

I know too little to know, what's going on. Maybe @firebase/testing never reaches the emulator, and I should be using the normal Firebase client, instead?

akauppi
  • 17,018
  • 15
  • 95
  • 120
  • Found a discussion that tangents this one - especially the project ID. It seems they are fake when @firebase/testing is used. Is this so? https://github.com/firebase/firebase-tools/issues/1960 – akauppi Jul 22 '20 at 14:36
  • Please edit the question to show the code and procedure you're using that isn't working the way you expect. There should be enough information in the question so that anyone can reproduce what you see. – Doug Stevenson Jul 22 '20 at 15:27
  • @DougStevenson Fair, added – akauppi Jul 23 '20 at 08:12
  • Adding because this came up in my search for "firestore emulator not showing root nodes"; **check that you are running the latest emulator updates**. In my case I had sub-collections with empty parent documents, which were [not getting displayed in the UI](https://github.com/firebase/firebase-tools-ui/issues/273) of my few-months-old emulator installation. – Janaka Bandara Mar 01 '21 at 06:32

3 Answers3

14

The emulator UI only shows the active project, i.e. the one used in firebase use.

If tests use this project ID, their data is visible in the emulator. If they use some other, tests work but the emulator UI is out of the loop.

Not sure if this is by design or not. If you know a place in the documentation that addresses this, I'll be glad to mention it here.

firebase-tools 8.6.0

akauppi
  • 17,018
  • 15
  • 95
  • 120
1

I was using a fake project id for the emulator as same as the API key. I had to use my projectId to solve the issue. Thanks to this github issue.

when calling admin.initializeApp() you need to set the correct projectId, then the data will show up.

Mejan
  • 918
  • 13
  • 18
1

Today I bumped into this too.

For me the issue is that I had accidentally removed the .firebaserc file (which was gitignored) from the project.

As a result, the emulator UI would not show any Firestore documents at all.

Adding back the project with firebase use --add solved the problem.

But I wasted a bunch of time on this. One would hope that the emulator should throw a fatal error if any required configuration files are missing.

bizz84
  • 1,964
  • 21
  • 34