Firebase throws “auth/network-request-failed” on signInAnonymously() while running jest tests

I'm writing some tests for my app (is build with create-react-app) using firebase and I'm trying to anonymously login into my test database. But authentication fails. However all other firebase operations (CRUD) work just fine.

I can also login anonymously from my application that runs in a browser.

The code is very simple:

import firebase from 'firebase';
    .catch((err) => {

Gives me back this:

O {
  code: 'auth/network-request-failed',
  message: 'A network error (such as timeout, interrupted connection or unreachable host) has occurred.'

But I actually see users that appear in the Firebase console: enter image description here

Anonymous access is enabled: enter image description here

And here are my access rules. But it never comes to the point of dealing with rules since I can't login.

  "rules": {
    "users": {
      "$user_id": {
        ".read": "$user_id === auth.uid",
        ".write": "$user_id === auth.uid"

So what's going on? Are there any special things I need to do to make it work in command line? Or should I switch anything in the firebase console?

Maybe any hint on how can I debug it deeper?