Nock makes firebase throw network error #2408
-
Im trying to mock some firebase api calls using nock, but when I try to intercept any auth post request, nock makes firebase throw a network request failed error The application works normally this happens only in tests... i tried every header that i remember too nock('https://identitytoolkit.googleapis.com/v1', {
reqheaders: HEADERS,
})
.post(
`/accounts:signInWithPassword?key=${API_KEY}`
)
.reply(400); Error:
Versions
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
You're returning a 400. What is the expected behavior from the |
Beta Was this translation helpful? Give feedback.
-
https://firebase.google.com/docs/reference/rest/auth#section-sign-in-email-password
Everything seems to be fine with Nock and Firebase SDK, your test setup just needs some updates. |
Beta Was this translation helpful? Give feedback.
-
I found the problem, you need to mock the exact response for the API otherwise, firebase always throws the 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',
},
],
},
}); cc @mastermatt Thanks! |
Beta Was this translation helpful? Give feedback.
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?