From b0d3cf15e8877a47973c844a2c843fa10921d0e3 Mon Sep 17 00:00:00 2001 From: Kasper Isager Date: Thu, 15 Feb 2024 10:30:09 +0100 Subject: [PATCH] Increase error margin on Windows --- test/helpers/index.js | 6 +++++- test/timeout.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/helpers/index.js b/test/helpers/index.js index 114fa77..0165616 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -1,6 +1,10 @@ +/* global Bare */ + const nil = new Int32Array(new SharedArrayBuffer(4)) -exports.isAround = function isAround (actual, expected, epsilon = 10) { +const isWindows = Bare.platform === 'win32' + +exports.isAround = function isAround (actual, expected, epsilon = isWindows ? 50 : 25) { return Math.abs(actual - expected) < epsilon } diff --git a/test/timeout.js b/test/timeout.js index 7f89e18..cb95ac5 100644 --- a/test/timeout.js +++ b/test/timeout.js @@ -30,7 +30,7 @@ test('setTimeout refresh', async function (t) { const timer = timers.setTimeout(function () { t.is(ticks, 6, 'was refreshed') - t.ok(isAround(Date.now() - started, 200), 'timers took ' + Math.abs(Date.now() - started) + 'ms') + t.ok(isAround(Date.now() - started, 200, 100), 'timers took ' + Math.abs(Date.now() - started) + 'ms') }, 50) let ticks = 0