From 7819bfec69b5dd3556454fc3b10024237a3846ca Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Thu, 19 Dec 2024 23:30:28 +0100 Subject: [PATCH] test: deflake test-esm-loader-hooks-inspect-brk Refs: https://github.com/nodejs/node/pull/54827 Refs: https://github.com/nodejs/node/pull/51560 PR-URL: https://github.com/nodejs/node/pull/56050 Reviewed-By: Antoine du Hamel --- .../test-esm-loader-hooks-inspect-brk.js | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-esm-loader-hooks-inspect-brk.js b/test/parallel/test-esm-loader-hooks-inspect-brk.js index 881bdfd2dd101a..251ebb230dcd31 100644 --- a/test/parallel/test-esm-loader-hooks-inspect-brk.js +++ b/test/parallel/test-esm-loader-hooks-inspect-brk.js @@ -10,23 +10,20 @@ const assert = require('assert'); const fixtures = require('../common/fixtures'); const { NodeInstance } = require('../common/inspector-helper.js'); -async function runIfWaitingForDebugger(session) { - const commands = [ - { 'method': 'Runtime.enable' }, - { 'method': 'Debugger.enable' }, - { 'method': 'Runtime.runIfWaitingForDebugger' }, - ]; - - await session.send(commands); - await session.waitForNotification('Debugger.paused'); -} - async function runTest() { const main = fixtures.path('es-module-loaders', 'register-loader.mjs'); const child = new NodeInstance(['--inspect-brk=0'], '', main); const session = await child.connectInspectorSession(); - await runIfWaitingForDebugger(session); + await session.send({ method: 'NodeRuntime.enable' }); + await session.waitForNotification('NodeRuntime.waitingForDebugger'); + await session.send([ + { 'method': 'Runtime.enable' }, + { 'method': 'Debugger.enable' }, + { 'method': 'Runtime.runIfWaitingForDebugger' }, + ]); + await session.send({ method: 'NodeRuntime.disable' }); + await session.waitForNotification('Debugger.paused'); await session.runToCompletion(); assert.strictEqual((await child.expectShutdown()).exitCode, 0); }