-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Select * hangs forever if time is mocked with sinon #1267
Comments
Seems to be because |
I see the same Knex/Sinon conflict using MySQL. I was re-deploying some old integration tests from less than a year ago with updated dependencies and was having a hell of a time figuring out why the code didn't work. After lots of trial, even more error, restoring module state of the old app and working forward, it looks like something changed in v0.8.0 of Knex. If I roll Knex all the way back to beforeEach(function() {
return fixtures.load(data)
.then(function() {
let date = new Date().getTime();
clock = sinon.useFakeTimers(date, 'Date');
return;
});
});
afterEach(function() {
return fixtures.clear(data)
.then(function() {
return clock.restore();
});
}); Note that my |
API was updated
|
I don't think this is knex's problem. |
For posterity, you can use the shouldAdvanceTimers option on sinon.useFakeTimers or call clock.runAll to have this work correctly while stubbing setTimeout and other functions besides Date. |
Node version: 4.3.2
Knex version: 0.9.0
Pg version: 4.5.1
Sinon version: 1.17.3
Commenting out the
sinon.useFakeTimers(Number(date))
causes this to run just fine. Otherwise it seems to hang forever.Not sure if this is a problem with knex or with pg underneath though.
The text was updated successfully, but these errors were encountered: