Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
smitley committed Sep 14, 2022
commit 1925e3455148a9f0e013bae9f3e52d5a7fd7ab7f
3 changes: 2 additions & 1 deletion test/parallel/test-performance-measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}));
Expand Down