Skip to content

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

test(network): add failing test for Set-Cookie in fulfill (#4988)

Yury Semikhatsky0bf7477c2433
diff --git a/test/page-request-fulfill.spec.ts b/test/page-request-fulfill.spec.ts
index 7a0563f51b..691951810a 100644
--- a/test/page-request-fulfill.spec.ts
+++ b/test/page-request-fulfill.spec.ts
@@ -177,3 +177,29 @@ it('should include the origin header', async ({page, server}) => {
expect(text).toBe('done');
expect(interceptedRequest.headers()['origin']).toEqual(server.PREFIX);
});
+
+it('should support Set-Cookie header', (test, { browserName }) => {
+ test.fixme(browserName === 'webkit');
+ test.fixme(browserName === 'firefox');
+}, async ({context, page, server}) => {
+ await page.route('https://example.com/', (route, request) => {
+ route.fulfill({
+ headers: {
+ 'Set-Cookie': 'name=value; domain=.example.com; Path=/'
+ },
+ contentType: 'text/html',
+ body: 'done'
+ });
+ });
+ await page.goto('https://example.com');
+ expect(await context.cookies()).toEqual([{
+ sameSite: 'None',
+ name: 'name',
+ value: 'value',
+ domain: '.example.com',
+ path: '/',
+ expires: -1,
+ httpOnly: false,
+ secure: false
+ }]);
+});