From 81d66dd219f62bb24fc3ca684236bdddc4cc4267 Mon Sep 17 00:00:00 2001 From: Alexander Early Date: Sun, 16 Apr 2017 12:14:45 -0700 Subject: make tests less flakey. related to #1322 --- mocha_test/applyEach.js | 6 +++--- mocha_test/retry.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mocha_test/applyEach.js b/mocha_test/applyEach.js index 6138d3f..ca5ada3 100644 --- a/mocha_test/applyEach.js +++ b/mocha_test/applyEach.js @@ -11,21 +11,21 @@ describe('applyEach', function () { setTimeout(function () { call_order.push('one'); cb(null, 1); - }, 10); + }, 12); }; var two = function (val, cb) { expect(val).to.equal(5); setTimeout(function () { call_order.push('two'); cb(null, 2); - }, 5); + }, 2); }; var three = function (val, cb) { expect(val).to.equal(5); setTimeout(function () { call_order.push('three'); cb(null, 3); - }, 15); + }, 18); }; async.applyEach([one, two, three], 5, function (err, results) { assert(err === null, err + " passed instead of 'null'"); diff --git a/mocha_test/retry.js b/mocha_test/retry.js index 6185f3c..8a9f4da 100644 --- a/mocha_test/retry.js +++ b/mocha_test/retry.js @@ -69,7 +69,7 @@ describe("retry", function () { var start = Date.now(); async.retry({ times: times, interval: interval}, fn, function(err, result){ var duration = Date.now() - start; - expect(duration).to.be.above(interval * (times - 1) - 1); + expect(duration).to.be.above(interval * (times - 1) - times); assert.equal(callCount, 3, "did not retry the correct number of times"); assert.equal(err, error + times, "Incorrect error was returned"); assert.equal(result, erroredResult + times, "Incorrect result was returned"); @@ -90,7 +90,7 @@ describe("retry", function () { var start = Date.now(); async.retry({ times: times, interval: intervalFunc}, fn, function(err, result){ var duration = Date.now() - start; - expect(duration).to.be.above(299); + expect(duration).to.be.above(300 - times); assert.equal(callCount, 3, "did not retry the correct number of times"); assert.equal(err, error + times, "Incorrect error was returned"); assert.equal(result, erroredResult + times, "Incorrect result was returned"); @@ -227,7 +227,7 @@ describe("retry", function () { var start = Date.now(); async.retry({ interval: interval, errorFilter: errorTest }, fn, function(err, result){ var duration = Date.now() - start; - expect(duration).to.be.above(interval * (specialCount - 1) - 1); + expect(duration).to.be.above(interval * (specialCount - 1) - specialCount); assert.equal(callCount, specialCount, "did not retry the correct number of times"); assert.equal(err, special, "Incorrect error was returned"); assert.equal(result, erroredResult + specialCount, "Incorrect result was returned"); -- cgit v1.2.1