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: API request trace has postData (#15041)
Yury Semikhatsky4f5954c302f7
diff --git a/tests/library/tracing.spec.ts b/tests/library/tracing.spec.tsindex 5863854635..17dd3ba9df 100644--- a/tests/library/tracing.spec.ts+++ b/tests/library/tracing.spec.ts@@ -477,7 +477,7 @@ test('should record global request trace', async ({ request, context, server },}));});-test('should store global request traces separately', async ({ request, context, server, playwright }, testInfo) => {+test('should store global request traces separately', async ({ request, server, playwright }, testInfo) => {const request2 = await playwright.request.newContext();await Promise.all([(request as any)._tracing.start({ snapshots: true }),@@ -514,6 +514,29 @@ test('should store global request traces separately', async ({ request, context,}});+test('should store postData for global request', async ({ request, server }, testInfo) => {+ testInfo.annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/15031' });+ await (request as any)._tracing.start({ snapshots: true });+ const url = server.PREFIX + '/simple.json';+ await request.post(url, {+ data: 'test'+ });+ const tracePath = testInfo.outputPath('trace.zip');+ await (request as any)._tracing.stop({ path: tracePath });++ const trace = await parseTrace(tracePath);+ const actions = trace.events.filter(e => e.type === 'resource-snapshot');+ expect(actions).toHaveLength(1);+ const req = actions[0].snapshot.request;+ console.log(JSON.stringify(req, null, 2));+ expect(req.postData?._sha1).toBeTruthy();+ expect(req).toEqual(expect.objectContaining({+ method: 'POST',+ url+ }));+});++function expectRed(pixels: Buffer, offset: number) {const r = pixels.readUInt8(offset);const g = pixels.readUInt8(offset + 1);