Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmitley <brandon.smitley@gmail.com>2022-09-14 20:36:55 +0300
committerMichael Dawson <mdawson@devrus.com>2022-09-16 23:51:06 +0300
commit092889779834f48299ec5459e0ae4fe4f3359a70 (patch)
tree566a3eb552fe4921a9c9366338c851d56d27981f
parent325f54966e6cd85a123448af68c04b5d1a55b663 (diff)
test: fix test-performance-measure
Refs: https://github.com/nodejs/node/issues/42949 Looking at the documentation for setTimeout (https://nodejs.org/api/timers.html#settimeoutcallback-delay-args) there is no guarantee that setTimeout won't complete early. From the failure of https://github.com/nodejs/node/issues/42949 this is likely what happened. I have updated the assert.ok test to allow some variation in the test. PR-URL: https://github.com/nodejs/node/pull/44637 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
-rw-r--r--test/parallel/test-performance-measure.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/test/parallel/test-performance-measure.js b/test/parallel/test-performance-measure.js
index e9aaca72bdd..949258f96e1 100644
--- a/test/parallel/test-performance-measure.js
+++ b/test/parallel/test-performance-measure.js
@@ -5,11 +5,12 @@ const assert = require('assert');
const { PerformanceObserver, performance } = require('perf_hooks');
const DELAY = 1000;
+const ALLOWED_MARGIN = 10;
const expected = ['Start to Now', 'A to Now', 'A to B'];
const obs = new PerformanceObserver(common.mustCall((items) => {
items.getEntries().forEach(({ name, duration }) => {
- assert.ok(duration > DELAY);
+ assert.ok(duration > (DELAY - ALLOWED_MARGIN));
assert.strictEqual(expected.shift(), name);
});
}));