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
{{ message }}
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.
Foounit has waitFor and waitForTimeout keywords for doing asynchronous testing. But these aren't good for the simple use case of running a simple function once. What I'm doing is mocking ajax calls. Here's a simplified example.
var fakeAjax = {
send: function(req) {
var fakexhr;
foounit.setTimeout(function() {
req.success && req.success('data', 'success', fakeXHR);
}, 10);
}
}
The problem comes in when I want to put expect statements inside the success function. Since setTimeout isn't test aware, the errors propagate to the top of the runtime but do not make the test fail. Here's the simplest test for this issue.
foounit.add(function (kw){ with (kw){
describe('waitFor', function() {
it('fails if timeout throws', function() {
var end = false;
foounit.setTimeout(function() {
end = true;
expect(false).to(beTrue);
}, 100);
waitFor(function() {
expect(end).to(beTrue);
}, 1000);
});
});
}});
This test passes, but the expect in setTimeout should be caught and cause it to fail.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Foounit has waitFor and waitForTimeout keywords for doing asynchronous testing. But these aren't good for the simple use case of running a simple function once. What I'm doing is mocking ajax calls. Here's a simplified example.
The problem comes in when I want to put expect statements inside the success function. Since setTimeout isn't test aware, the errors propagate to the top of the runtime but do not make the test fail. Here's the simplest test for this issue.
This test passes, but the expect in setTimeout should be caught and cause it to fail.
The text was updated successfully, but these errors were encountered: