node/test/parallel/test-performance-function-async.js
James M Snell ecc584251e
test: fixup flaky test-performance-function-async test
The time assertion was inaccurate. Just remove it as it's
not strictly necessary

PR-URL: https://github.com/nodejs/node/pull/37493
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2021-02-23 14:58:00 -08:00

40 lines
695 B
JavaScript

'use strict';
const common = require('../common');
const {
PerformanceObserver,
performance: {
timerify,
},
} = require('perf_hooks');
const assert = require('assert');
const {
setTimeout: sleep
} = require('timers/promises');
let check = false;
async function doIt() {
await sleep(100);
check = true;
return check;
}
const obs = new PerformanceObserver(common.mustCall((list) => {
const entry = list.getEntries()[0];
assert.strictEqual(entry.name, 'doIt');
assert(check);
obs.disconnect();
}));
obs.observe({ type: 'function' });
const timerified = timerify(doIt);
const res = timerified();
assert(res instanceof Promise);
res.then(common.mustCall(assert));