chore: make tracing before/after test more robust (#24136)

This commit is contained in:
Pavel Feldman 2023-07-10 18:36:15 -07:00 committed by GitHub
parent 36588ba98e
commit e234a6a037
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -735,32 +735,40 @@ test('should not emit after w/o before', async ({ browserType, mode }, testInfo)
} }
}; };
let call1: number;
{ {
const { events } = await parseTraceRaw(testInfo.outputPath('trace1.zip')); const { events } = await parseTraceRaw(testInfo.outputPath('trace1.zip'));
expect(events.map(sanitize).filter(Boolean)).toEqual([ expect(events.map(sanitize).filter(Boolean)).toEqual([
{ {
type: 'before', type: 'before',
callId: 0, callId: expect.any(Number),
apiName: 'page.evaluate' apiName: 'page.evaluate'
} }
]); ]);
call1 = events.map(sanitize).filter(Boolean)[0].callId;
} }
let call2before: number;
let call2after: number;
{ {
const { events } = await parseTraceRaw(testInfo.outputPath('trace2.zip')); const { events } = await parseTraceRaw(testInfo.outputPath('trace2.zip'));
expect(events.map(sanitize).filter(Boolean)).toEqual([ expect(events.map(sanitize).filter(Boolean)).toEqual([
{ {
type: 'before', type: 'before',
callId: 6, callId: expect.any(Number),
apiName: 'page.evaluateHandle' apiName: 'page.evaluateHandle'
}, },
{ {
type: 'after', type: 'after',
callId: 6, callId: expect.any(Number),
apiName: undefined apiName: undefined
} }
]); ]);
call2before = events.map(sanitize).filter(Boolean)[0].callId;
call2after = events.map(sanitize).filter(Boolean)[1].callId;
} }
expect(call2before).toBeGreaterThan(call1);
expect(call2after).toBe(call2before);
}); });
function expectRed(pixels: Buffer, offset: number) { function expectRed(pixels: Buffer, offset: number) {