Skip to content

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

test: try to unflake cookie test (#2310)

Dmitry Gozmanb17a73c1841e
diff --git a/test/cookies.spec.js b/test/cookies.spec.js
index 869868598f..8e1da20e10 100644
--- a/test/cookies.spec.js
+++ b/test/cookies.spec.js
@@ -88,12 +88,14 @@ describe('BrowserContext.cookies', function() {
});
it('should get multiple cookies', async({context, page, server}) => {
await page.goto(server.EMPTY_PAGE);
- await page.evaluate(() => {
+ const documentCookie = await page.evaluate(() => {
document.cookie = 'username=John Doe';
document.cookie = 'password=1234';
+ return document.cookie.split('; ').sort().join('; ');
});
const cookies = await context.cookies();
cookies.sort((a, b) => a.name.localeCompare(b.name));
+ expect(documentCookie).toBe('password=1234; username=John Doe');
expect(cookies).toEqual([
{
name: 'password',