zl程序教程

您现在的位置是:首页 >  前端

当前栏目

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