Skip to content

Commit 54e9001

Browse files
committed
Use --trace-promises to count promises created during sync ESM loading
1 parent 6d13ee4 commit 54e9001

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

test/es-module/test-esm-sync-import.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ describe('synchronous ESM loading', () => {
4444

4545
async function getPromiseCount(entry) {
4646
const { stdout, stderr, code } = await spawnPromisified(process.execPath, [
47-
'--require', fixtures.path('es-modules', 'promise-counter.cjs'),
47+
'--trace-promises',
4848
entry,
4949
]);
5050
assert.strictEqual(code, 0, `child failed:\nstdout: ${stdout}\nstderr: ${stderr}`);
51-
const match = stdout.match(/PROMISE_COUNT=(\d+)/);
52-
assert(match, `Expected PROMISE_COUNT in output, got: ${stdout}`);
53-
return Number(match[1]);
51+
return stderr.match(/created promise #/g)?.length ?? 0;
5452
}

test/fixtures/es-modules/promise-counter.cjs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)