You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use Jasmine to test functions that use ES7 async await features. Jasmine although works for promises and async functions, it fails for ES7 async function. For example:
describe("async-test", () => {
it('should run test', (async function(done) {
var x = await fakeRequest();
expect(x).toBeDefined();
done();
}));
});
async function fakeRequest() {
let result = await another_request();
return result;
}
async function another_request(){
// returns promise resolution or some async function call return
}
it always gives this error:
async-test
✖ should run test
PhantomJS 2.1.1 (Mac OS X 0.0.0)
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. in config/karma-shim.js (line 98794)
ZoneAwareError@webpack:///~/zone.js/dist/zone.js:999:0 <- config/karma-shim.js:98794:28
How can I make it work. Jasmine works when I am only dealing with promises but as soon as ES7 come in, it stops working. How can I make it work with functions that use ES7 features?
I am running "jasmine-core": "^2.6.0","karma": "^1.6.0", "typescript": "~2.2.2" and Node 7.10.0
The text was updated successfully, but these errors were encountered:
Jasmine never truly supported async functions, since it would never actually await them. In 2.6, Jasmine will now throw an Error if something that is not a function is passed into it because users would accidentally pass in an async function() without a done parameter and Jasmine would just execute it as if it was synchronous, moving on to the next spec at the first await.
We're looking into fully supporting promises (via #1270 or something like it), which would then also hopefully allow async/await to work as expected.
The plan right now is to try to get Promise support, along with async functions into Jasmine itself in 2.7. With some of the issues from 2.6, I haven't been able to get too much further into this though.
I am trying to use Jasmine to test functions that use ES7 async await features. Jasmine although works for promises and async functions, it fails for ES7 async function. For example:
it always gives this error:
How can I make it work. Jasmine works when I am only dealing with promises but as soon as ES7 come in, it stops working. How can I make it work with functions that use ES7 features?
I am running
"jasmine-core": "^2.6.0","karma": "^1.6.0", "typescript": "~2.2.2" and Node 7.10.0
The text was updated successfully, but these errors were encountered: