[Unit Testing] Test async function with Jasmine
async with Function test Testing unit Jasmine
2023-09-14 09:00:49 时间
Most of time, when we want to test function call inside a promise, we can do:
it('Should be async', function(done) { someAsyncFunction().then(function(result) { expect(result).toBe(true); done(); }); });
It is important to call 'done()', otherwise, the code won't call the promise is finished.
相关文章
- [Functional Programming] mapReduce over Async operations with first success prediction (fromNode, alt, mapReduce, maybeToAsync)
- [Functional Programming] Capture Side Effects in a Task / Async
- [Node] Catch error for async await
- [Angular 2] Rendering an Observable Date with the Async and Date Pipes
- [Angular 2] Rendering an Observable with the Async Pipe
- java.lang.IllegalStateException: Calling [asyncError()] is not valid for a request with Async state [MUST_DISPATCH]
- [HTML 5] Understanding DOM loading event & 'async', 'defer' keyword
- [Vue @Component] Load Vue Async Components
- [Angular] New async 'as' syntax and ngIf.. else
- [Angular 2] Handle Reactive Async opreations in Service
- [Angular 2] Async Http
- @Async可以和@Transactional结合使用吗?
- nodejs async series 小白向
- 【Kotlin 协程】协程启动 ② ( 多协程控制 | launch 协程执行顺序控制 | Job#join() 函数 | async 协程执行顺序控制 | Deferred#await() 函数 )
- Promise - (七)初识async&await
- 有了 async/await 还需要学习 Promise 么?