From 284f76357f5ab16a10f1972861976164320598e5 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Wed, 9 Feb 2022 17:00:33 -0800 Subject: [PATCH] test: unflake browsertype-connect.spec (#11994) Consider the scenario: - First test starts a remote server, connects to it and does not close. - Remote server fixture stops the server in teardown. Meanwhile, the connected browser did not get notified about disconnect just yet. - Second test starts and sets up tracing in the old connected browser. - Tracing fails because the browser now realises it has disconnected. --- tests/config/browserTest.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/config/browserTest.ts b/tests/config/browserTest.ts index f7abcc2584..e75083cde9 100644 --- a/tests/config/browserTest.ts +++ b/tests/config/browserTest.ts @@ -97,8 +97,12 @@ const test = baseTest.extend await remoteServer._start(childProcess, browserType, options); return remoteServer; }); - if (remoteServer) + if (remoteServer) { await remoteServer.close(); + // Give any connected browsers a chance to disconnect to avoid + // poisoning next test with quasy-alive browsers. + await new Promise(f => setTimeout(f, 1000)); + } }, });