[release] test/integration/goDebug.test.ts: use dc.on to wait for output event

dc.on calls the listener for every output event. This should fix the
flakiness of the cwd tests.

Updates golang/vscode-go#1439

Change-Id: I5a44708dc294561408335b3f8baff5cd1b63461a
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/318810
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
(cherry picked from commit 41c5ee930c78692d69ec084b38fd7507a72cfe9a)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/318892
diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts
index 73b9b5f..5ef2e2d 100644
--- a/test/integration/goDebug.test.ts
+++ b/test/integration/goDebug.test.ts
@@ -783,23 +783,13 @@
 
 		async function waitForHelloGoodbyeOutput(dc: DebugClient): Promise<DebugProtocol.Event> {
 			return await new Promise<DebugProtocol.Event>((resolve, reject) => {
-				const listen = () => {
-					dc.waitForEvent('output', 5_000)
-						.then((event) => {
-							// Run listen again to make sure we can get the next events.
-							listen();
-							if (event.body.output === 'Hello, World!\n' || event.body.output === 'Goodbye, World.\n') {
-								// Resolve when we have found the event that we want.
-								resolve(event);
-								return;
-							}
-						})
-						.catch((reason) => reject(reason));
-				};
-				// Start listening for an output event. Especially because
-				// logging is enabled in dlv-dap, there are many output events, and it is
-				// possible to miss them if we are not prepared to handle them.
-				listen();
+				dc.on('output', (event) => {
+					if (event.body.output === 'Hello, World!\n' || event.body.output === 'Goodbye, World.\n') {
+						// Resolve when we have found the event that we want.
+						resolve(event);
+						return;
+					}
+				});
 			});
 		}