何时在angular中使用waitForAsync [英] When to use waitForAsync in angular

查看:229
本文介绍了何时在angular中使用waitForAsync的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从文档中我们可以阅读:

From documentation we can read:

waitForAsync(fn: Function): (done: any) => any

在异步测试区域中包装测试功能.测试将 在该区域内的所有异步调用时自动完成 完成.可用于包装注入调用.

Wraps a test function in an asynchronous test zone. The test will automatically complete when all asynchronous calls within this zone are done. Can be used to wrap an inject call.

我不明白,什么时候使用waitForAsync函数? waitForAsync与(asyncfakeAsync)之间有什么区别?

I could not understand, when to use waitForAsync function? What's the difference between waitForAsync vs (async or fakeAsync)?

推荐答案

在Angular 10.1.0中,waitForAsync()替换了async()

In Angular 10.1.0, waitForAsync() has replaced async() to avoid confusion, but is otherwise exactly the same. Any documentation you see that discusses using async() will also apply to waitForAsync(). async() has been marked as deprecated and will be removed entirely in version 12.

这篇关于何时在angular中使用waitForAsync的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆