简体   繁体   English

Firebase Jest auth.network-request-failed'错误

[英]Firebase Jest auth/network-request-failed' error

I'm trying to do Firebase testing Using Jest.我正在尝试使用 Jest 进行 Firebase 测试。 This is my test case.这是我的测试用例。

test('Test Firebase Connection', done => {
    let history = [];
    function callback(history) {
        expect(history[0]).toBe('/dashboard');
        done();
    }
    firebaseDAO.init('myEmail', 'mypassword', history);
    setTimeout(callback, 4000,history);
});

export const init = (username, passwordPassed, history) => {
    let historyData = history;
    const email = username;
    const password = passwordPassed;
    const auth = firebase.auth();
    const promise = auth.signInWithEmailAndPassword(email, password);

    promise.catch(e => console.log(e));
    promise.then(() => {historyData.push('/dashboard');});
};

When I run the test with Idea-Webstorm-Jest Plugin it Works.当我使用Idea-Webstorm-Jest插件运行测试时,它运行正常。 (Test passes.) But when I try with npm Test command. (测试通过。)但是当我尝试使用npm Test命令时。 Firebase gives me following Error. Firebase 给我以下错误。

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

So why it is fails when npm Test command runs?那么为什么运行npm Test命令会失败呢? Anyone can help me?任何人都可以帮助我吗? thanks in advance.提前致谢。

I had that problem too, i looked for google and i found that my input or button in html was in type:"submit" which made the page refresh, it's better to do type"button"我也有这个问题,我找了谷歌,我发现我在 html 中的输入或按钮是类型:“提交”,这使页面刷新,最好输入“按钮”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 错误:错误(auth.network-request-failed - Firebase error : Error (auth/network-request-failed Firebase 登录时出现“Auth.network-request-failed”错误的项目结果 - Firebase Project Results in "Auth/network-request-failed" error on login [FirebaseError: Firebase: 错误 (auth.network-request-failed) - [FirebaseError: Firebase: Error (auth/network-request-failed) 我在 React 中的 signInWithEmailAndPassword 中出现错误:Firebase: Error (auth/network-request-failed) - I am getting error in signInWithEmailAndPassword in React: Firebase: Error (auth/network-request-failed) React Native:尝试创建新用户时出现 firebase auth/network-request-failed 错误,但在登录时却没有? - React Native: firebase auth/network-request-failed error when trying to create a new user, but not on login? 尝试在客户端使用 Firebase 身份验证服务注册用户时出错。 Firebase:错误(auth.network-request-failed) - Error when trying to register a user using Firebase Auth service on the client side. Firebase: Error (auth/network-request-failed) Flutter Firebase [firebase_auth.network-request-failed] A.network error (such as timeout, interrupted connection or unreachable host)发生了 - Flutter Firebase [firebase_auth/network-request-failed] A network error (such as timeout, interrupted connection or unreachable host) has occurred 使用 Firebase Auth 进行身份验证时请求短信验证码失败 - SMS verification code request failed when authenticating using Firebase Auth 带有 Flutter、Firebase 的 sendSignInLinkToEmail Auth 抛出错误“[firebase_auth/missing-continue-uri] 必须在请求中提供继续 URL。” - sendSignInLinkToEmail with Flutter, Firebase Auth throws error "[firebase_auth/missing-continue-uri] A continue URL must be provided in the request." 如何模拟 firebase.auth.UserCredential 开玩笑? - How to mock firebase.auth.UserCredential jest?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM