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