Skip to content

Commit aae8ff6

Browse files
smitleyjuanarbol
authored andcommitted
test: fix test-performance-measure
Refs: #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 #42949 this is likely what happened. I have updated the assert.ok test to allow some variation in the test. PR-URL: #44637 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Akhil Marsonya <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 6881ecb commit aae8ff6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

test/parallel/test-performance-measure.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ const assert = require('assert');
55

66
const { PerformanceObserver, performance } = require('perf_hooks');
77
const DELAY = 1000;
8+
const ALLOWED_MARGIN = 10;
89

910
const expected = ['Start to Now', 'A to Now', 'A to B'];
1011
const obs = new PerformanceObserver(common.mustCall((items) => {
1112
items.getEntries().forEach(({ name, duration }) => {
12-
assert.ok(duration > DELAY);
13+
assert.ok(duration > (DELAY - ALLOWED_MARGIN));
1314
assert.strictEqual(expected.shift(), name);
1415
});
1516
}));

0 commit comments

Comments
 (0)