简体   繁体   English

Firebase管理员:admin.auth()。delete(uid)在AVA test.after()中无法解析

[英]Firebase Admin: admin.auth().delete(uid) not resolving in AVA test.after()

Had a quick question about using AVA for testing with Firebase. 关于使用AVA与Firebase进行测试存在一个快速问题。 When using test.after.finally() with Firebase Admin to delete user accounts in test cleanup, the promise is not resolving or throwing an error. 在Firebase Admin中使用test.after.finally()删除测试清理中的用户帐户时,promise不会解决或引发错误。 There's a very strong chance that I am not doing the correct thing here and would love some input. 我很有可能在这里没有做正确的事情,并且会喜欢一些建议。

My Code: 我的代码:

test.after.always(async () => {
    internals.ids.forEach(async (id) => {
        await admin.database().ref(`users/${id}`).remove();
        await admin.auth().deleteUser(id);
    });
});

Where internals.ids is an array of ids that need to be cleaned up at the end of running all of the tests. 其中internals.ids是一组ID,需要在运行所有测试结束时清除它们。

This may or may not be related to the non-serial nature of AVA but I'm not 100% sure. 这可能与AVA的非串行性质有关,也可能无关,但我不确定100%。 If you need more information please let me know. 如果您需要更多信息,请告诉我。 Thanks! 谢谢!

Try this instead: 尝试以下方法:

for (const id of internals.ids) {
  await ...remove()
  await ...deleteUser(id)
}

Because you're using forEach() , the after hook isn't actually waiting for any of your removals / user deletions to complete, and the process likely hard exits before they do. 由于您使用的是forEach() ,因此after钩实际上并没有在等待任何删除/用户删除操作的完成,因此该过程很可能先退出。

暂无
暂无

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

相关问题 Firebase admin.auth()。getUser(uid)挂起(NodeJS) - Firebase admin.auth().getUser(uid) hangs (NodeJS) Firebase - TypeError: admin.auth(...).createUserWithEmailAndPassword 不是函数 - Firebase - TypeError: admin.auth(…).createUserWithEmailAndPassword is not a function Firebase功能错误<admin.auth is not a function at ..> - Firebase function error <admin.auth is not a function at ..> admin.auth().verifyIdToken(idToken) 错误:在 8.0.0 之后无法使用 firebase-admin 加载默认凭据 - admin.auth().verifyIdToken(idToken) Error: Could not load the default credentials whith firebase-admin after to 8.0.0 管理员firebase错误:“ admin.auth(...)。generatePasswordResetLink不是函数” - Error with admin firebase: “admin.auth(…).generatePasswordResetLink is not a function” admin.auth(...)。createSessionCookie不是函数 - admin.auth(…).createSessionCookie is not a function firebase是否对每个admin.auth()。verifyIdToken(idToken)发出网络请求? - Does firebase make a network request for every admin.auth().verifyIdToken(idToken)? 如何在 firebase 管理员中测试云功能 Auth Trigger? - How to test cloud functions Auth Trigger in firebase admin? Firebase管理员身份验证令牌被撤销 - Firebase Admin Auth Token Revoked [ERR_INVALID_ARG_TYPE]:第一个参数必须是字符串类型或缓冲区的实例。 使用 admin.auth().verifyIdToken 时 - [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer. when using admin.auth().verifyIdToken
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM