From 80c408023e9551b70b3d952302debaf955617212 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 13 Oct 2023 14:15:12 -0700 Subject: [PATCH] test: unflake "should fail without credentials" (#27606) Speculative fix. The test marked as failed => we reuse the browser without closing the context. --- tests/library/browsercontext-credentials.spec.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/library/browsercontext-credentials.spec.ts b/tests/library/browsercontext-credentials.spec.ts index d497321e5c..faa75183bd 100644 --- a/tests/library/browsercontext-credentials.spec.ts +++ b/tests/library/browsercontext-credentials.spec.ts @@ -30,9 +30,12 @@ it('should fail without credentials', async ({ browser, server, isChromiumHeaded server.setAuth('/empty.html', 'user', 'pass'); const context = await browser.newContext(); const page = await context.newPage(); - const response = await page.goto(server.EMPTY_PAGE); - expect(response.status()).toBe(401); - await context.close(); + try { + const response = await page.goto(server.EMPTY_PAGE); + expect(response.status()).toBe(401); + } finally { + await context.close(); + } }); it('should work with setHTTPCredentials', async ({ browser, server, isChromiumHeadedLike }) => {