Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: unflake "should fail without credentials" (#27606)

Yury Semikhatsky80c408023e95
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 }) => {