Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: unflake more cookies tests (#2333)
Dmitry Gozman0a8fa6e46c3e
diff --git a/test/cookies.spec.js b/test/cookies.spec.jsindex 8e1da20e10..56710db54e 100644--- a/test/cookies.spec.js+++ b/test/cookies.spec.js@@ -23,9 +23,11 @@ describe('BrowserContext.cookies', function() {});it('should get a cookie', async({context, page, server}) => {await page.goto(server.EMPTY_PAGE);- await page.evaluate(() => {+ const documentCookie = await page.evaluate(() => {document.cookie = 'username=John Doe';+ return document.cookie;});+ expect(documentCookie).toBe('username=John Doe');expect(await context.cookies()).toEqual([{name: 'username',value: 'John Doe',@@ -41,10 +43,12 @@ describe('BrowserContext.cookies', function() {await page.goto(server.EMPTY_PAGE);// @see https://en.wikipedia.org/wiki/Year_2038_problemconst date = +(new Date('1/1/2038'));- await page.evaluate(timestamp => {+ const documentCookie = await page.evaluate(timestamp => {const date = new Date(timestamp);document.cookie = `username=John Doe;expires=${date.toUTCString()}`;+ return document.cookie;}, date);+ expect(documentCookie).toBe('username=John Doe');expect(await context.cookies()).toEqual([{name: 'username',value: 'John Doe',@@ -171,10 +175,12 @@ describe('BrowserContext.addCookies', function() {await page.goto(server.EMPTY_PAGE);// @see https://en.wikipedia.org/wiki/Year_2038_problemconst date = +(new Date('1/1/2038'));- await page.evaluate(timestamp => {+ const documentCookie = await page.evaluate(timestamp => {const date = new Date(timestamp);document.cookie = `username=John Doe;expires=${date.toUTCString()}`;+ return document.cookie;}, date);+ expect(documentCookie).toBe('username=John Doe');const cookies = await context.cookies();await context.clearCookies();expect(await context.cookies()).toEqual([]);