Skip to content

Nock makes firebase throw network error #2408

Discussion options

You must be logged in to vote

I found the problem, you need to mock the exact response for the API otherwise, firebase always throws the auth/network-request-failed, not the best idea to help developers debug, huh?

    nock('https://identitytoolkit.googleapis.com/v1')
      .post(
        `/accounts:signInWithPassword?key=${API_KEY}`,
        {
          email: 'invalid@email.com',
          password: 'invalid@email',
          returnSecureToken: true,
        }
      )
      .reply(400, {
        error: {
          code: 400,
          message: 'EMAIL_NOT_FOUND',
          errors: [
            {
              message: 'EMAIL_NOT_FOUND',
              domain: 'global',
              reason: 'invalid',
            },

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@wendelfreitas
Comment options

Comment options

You must be logged in to vote
3 replies
@wendelfreitas
Comment options

@mastermatt
Comment options

@wendelfreitas
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by wendelfreitas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants