[英]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.