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'));
expect(events.map(sanitize).filter(Boolean)).toEqual([
{
type: 'before',
callId: 0,
callId: expect.any(Number),
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'));
expect(events.map(sanitize).filter(Boolean)).toEqual([
{
type: 'before',
callId: 6,
callId: expect.any(Number),
apiName: 'page.evaluateHandle'
},
{
type: 'after',
callId: 6,
callId: expect.any(Number),
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) {