-
-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocking setImmediate by default breaks Co #527
Comments
Just like @jonathanong asked for in the tj/co#139 issue, it would be greatly beneficial if you could provide a runnable test case that shows the issue. |
Kay, fair enough. I thought the report above was explanatory and obvious, but to speed things up: package.json: {
"dependencies": {
"mocha": ">= 1.18.2 < 2",
"co": ">= 3.1.0 < 4",
"sinon": ">= 1.9.1 < 2"
}
} index.js: var Sinon = require("sinon")
var co = require("co")
var NOON = new Date(2000, 0, 1, 12)
describe("Test with Sinon and Co", function() {
beforeEach(function() { this.time = Sinon.useFakeTimers(+NOON) })
afterEach(function() { this.time.restore() })
it("must not timeout", co(function*() {}))
}) Run it with:
Observe:
|
sinon.useFakeTimers(now, "setTimeout", "clearTimeout"); You can name the functions you want to fake - the default is all of 'em. |
Thanks. I was actually aware of this, that's why I added the last the bit at the end of "Now that generators with Co are used so liberally, this might require a better default.". As @yanickrochon pointed out, and I agree, that |
Actually, I would prefer mocking |
This is the corollary to tj/co#139:
I'm not sure who's problem this is, but Co v3.1.0 breaks when Sinon's fake timers are enabled, whereas v3.0.6 doesn't.
I found this when using co-mocha with Sinon and the following before blocks:
Now that generators with Co are used so liberally, this might require a better default.
The text was updated successfully, but these errors were encountered: