From: Tim Wood Date: Tue, 6 Nov 2012 18:20:52 +0000 (-0800) Subject: fixing flaky test X-Git-Tag: 2.0.0~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0857cd56fcec6de35d14456dc1db311e6011172;p=thirdparty%2Fmoment.git fixing flaky test --- diff --git a/test/moment/utc.js b/test/moment/utc.js index 26a66a28c..60457f276 100644 --- a/test/moment/utc.js +++ b/test/moment/utc.js @@ -30,7 +30,11 @@ exports.utc = { "creating with utc" : function(test) { test.expect(7); - test.equal(moment.utc().valueOf(), moment().valueOf(), "Calling moment.utc() should default to the current time"); + var diff = moment.utc().valueOf() - moment().valueOf(); + diff = Math.abs(diff); + // we check the diff rather than equality because sometimes they are off by a millisecond + + test.ok(diff < 5, "Calling moment.utc() should default to the current time"); var m = moment.utc([2011, 1, 2, 3, 4, 5, 6]); test.equal(m.date(), 2, "the day should be correct for utc array");