omit timings
This commit is contained in:
parent
5d4f149c64
commit
f4a986e61a
|
|
@ -213,8 +213,10 @@ export class HarTracer {
|
||||||
harEntry.response.httpVersion = event.httpVersion;
|
harEntry.response.httpVersion = event.httpVersion;
|
||||||
harEntry.response.redirectURL = event.headers.location || '';
|
harEntry.response.redirectURL = event.headers.location || '';
|
||||||
|
|
||||||
|
if (!this._options.omitTiming) {
|
||||||
harEntry.timings = event.timings;
|
harEntry.timings = event.timings;
|
||||||
this._computeHarEntryTotalTime(harEntry);
|
this._computeHarEntryTotalTime(harEntry);
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < event.rawHeaders.length; i += 2) {
|
for (let i = 0; i < event.rawHeaders.length; i += 2) {
|
||||||
harEntry.response.headers.push({
|
harEntry.response.headers.push({
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ import type { Log } from '../../packages/trace/src/har';
|
||||||
import { parseHar } from '../config/utils';
|
import { parseHar } from '../config/utils';
|
||||||
const { createHttp2Server } = require('../../packages/playwright-core/lib/utils');
|
const { createHttp2Server } = require('../../packages/playwright-core/lib/utils');
|
||||||
|
|
||||||
async function pageWithHar(contextFactory: (options?: BrowserContextOptions) => Promise<BrowserContext>, testInfo: any, options: { outputPath?: string, content?: 'embed' | 'attach' | 'omit', omitContent?: boolean } = {}) {
|
async function pageWithHar(contextFactory: (options?: BrowserContextOptions) => Promise<BrowserContext>, testInfo: any, options: { outputPath?: string } & Partial<Pick<BrowserContextOptions['recordHar'], 'content' | 'omitContent' | 'mode'>> = {}) {
|
||||||
const harPath = testInfo.outputPath(options.outputPath || 'test.har');
|
const harPath = testInfo.outputPath(options.outputPath || 'test.har');
|
||||||
const context = await contextFactory({ recordHar: { path: harPath, content: options.content, omitContent: options.omitContent }, ignoreHTTPSErrors: true });
|
const context = await contextFactory({ recordHar: { path: harPath, ...options }, ignoreHTTPSErrors: true });
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
return {
|
return {
|
||||||
page,
|
page,
|
||||||
|
|
@ -833,6 +833,19 @@ it('should include API request', async ({ contextFactory, server }, testInfo) =>
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should respect minimal mode for API Requests', async ({ contextFactory, server }, testInfo) => {
|
||||||
|
const { page, getLog } = await pageWithHar(contextFactory, testInfo, { mode: 'minimal' });
|
||||||
|
const url = server.PREFIX + '/simple.json';
|
||||||
|
await page.request.post(url, {
|
||||||
|
headers: { cookie: 'a=b; c=d' },
|
||||||
|
data: { foo: 'bar' }
|
||||||
|
});
|
||||||
|
const { entries } = await getLog();
|
||||||
|
expect(entries).toHaveLength(1);
|
||||||
|
const [entry] = entries;
|
||||||
|
expect(entry.timings).toEqual({ receive: -1, send: -1, wait: -1 });
|
||||||
|
});
|
||||||
|
|
||||||
it('should include redirects from API request', async ({ contextFactory, server }, testInfo) => {
|
it('should include redirects from API request', async ({ contextFactory, server }, testInfo) => {
|
||||||
server.setRedirect('/redirect-me', '/simple.json');
|
server.setRedirect('/redirect-me', '/simple.json');
|
||||||
const { page, getLog } = await pageWithHar(contextFactory, testInfo);
|
const { page, getLog } = await pageWithHar(contextFactory, testInfo);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue