-
Notifications
You must be signed in to change notification settings - Fork 100
Drop support for Node.js 4.x + update dependencies #126
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
Conversation
bajtos
commented
Jun 12, 2018
- Drop support for Node 4.x
- Travis: add Node.js 8.x + 10.x to the build matrix
- Disable package-lock feature of npm
- Update eslint + config to latest
- Update Mocha and Chai to latest
- Update strong-globalize to 4.x
- Update msgpack5 to 4.x
Node 4.x is no longer maintained by Node.js project.
This adds support for Timestamp extension type: https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type
| beforeEach(createPostInTx(post, TIMEOUT)); | ||
|
|
||
| it('should report timeout', function(done) { | ||
| setTimeout(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test did not make any sense to me. The original code:
it('should report timeout', function(done) {
setTimeout(function() {
Post.find({where: {title: 't3'}}, {transaction: currentTx},
function(err, posts) {
if (err) return done(err);
expect(posts.length).to.be.eql(1);
done();
});
}, 300);
done();
});Notice the done() callback is called immediately after setTimeout, before setTimeout fires. As a result, the test was marked as passed by mocha and because the remaining tests finished before the timeout fired, the process exited.
Mocha no longer exits the process when tests finish, in which case the setTimeout callback has time to be fired and fails with an error - this error is reported outside of any test case though. What a mess!
I rewrote the test as follows, I hope I captured author's intent correctly (ping @raymondfeng):
it('should report timeout', function(done) {
// wait until the "create post" transaction times out
setTimeout(runTheTest, TIMEOUT * 3);
function runTheTest() {
Post.find({where: {title: 't3'}}, {transaction: currentTx},
function(err, posts) {
expect(err).to.match(/transaction.*not active/);
done();
});
}
});There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
jannyHou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bajtos LGTM 👍 just one nitpick about the test
|
|
||
| // If the event is not fired quickly enough, then the test can | ||
| // quickly fail - no need to wait full two seconds (Mocha's default) | ||
| this.timeout(TIMEOUT * 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: wouldn't it be set before test 'should report timeout'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timeout function must be called from the test/hook that it is supposed to apply to. See https://mochajs.org/#timeouts
If called before the test (it call), it would apply to the entire test suite (describe block).