chore: fix API name capitalisation with APIRequestContext (#10240)
This commit is contained in:
parent
38dcfd785c
commit
ac629afd46
|
|
@ -114,13 +114,22 @@ export function captureStackTrace(): ParsedStackTrace {
|
|||
for (let i = 0; i < parsedFrames.length - 1; i++) {
|
||||
if (parsedFrames[i].inClient && !parsedFrames[i + 1].inClient) {
|
||||
const frame = parsedFrames[i].frame;
|
||||
apiName = frame.function ? frame.function[0].toLowerCase() + frame.function.slice(1) : '';
|
||||
apiName = normalizeAPIName(frame.function);
|
||||
parsedFrames = parsedFrames.slice(i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeAPIName(name?: string): string {
|
||||
if (!name)
|
||||
return '';
|
||||
const match = name.match(/(API|JS|CDP|[A-Z])(.*)/);
|
||||
if (!match)
|
||||
return name;
|
||||
return match[1].toLowerCase() + match[2];
|
||||
}
|
||||
|
||||
// Hide all test runner and library frames in the user stack (event handlers produce them).
|
||||
parsedFrames = parsedFrames.filter((f, i) => {
|
||||
if (f.frame.file.startsWith(TEST_DIR_SRC) || f.frame.file.startsWith(TEST_DIR_LIB))
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ it('should throw on network error', async ({ context, server }) => {
|
|||
req.socket.destroy();
|
||||
});
|
||||
const error = await context.request.get(server.PREFIX + '/test').catch(e => e);
|
||||
expect(error.message).toContain('socket hang up');
|
||||
expect(error.message).toBe('apiRequestContext.get: socket hang up');
|
||||
});
|
||||
|
||||
it('should throw on network error after redirect', async ({ context, server }) => {
|
||||
|
|
@ -78,7 +78,7 @@ it('should throw on network error after redirect', async ({ context, server }) =
|
|||
req.socket.destroy();
|
||||
});
|
||||
const error = await context.request.get(server.PREFIX + '/redirect').catch(e => e);
|
||||
expect(error.message).toContain('socket hang up');
|
||||
expect(error.message).toBe('apiRequestContext.get: socket hang up');
|
||||
});
|
||||
|
||||
it('should throw on network error when sending body', async ({ context, server }) => {
|
||||
|
|
@ -92,7 +92,7 @@ it('should throw on network error when sending body', async ({ context, server }
|
|||
req.socket.destroy();
|
||||
});
|
||||
const error = await context.request.get(server.PREFIX + '/test').catch(e => e);
|
||||
expect(error.message).toContain(': aborted');
|
||||
expect(error.message).toBe('apiRequestContext.get: aborted');
|
||||
});
|
||||
|
||||
it('should throw on network error when sending body after redirect', async ({ context, server }) => {
|
||||
|
|
@ -107,7 +107,7 @@ it('should throw on network error when sending body after redirect', async ({ co
|
|||
req.socket.destroy();
|
||||
});
|
||||
const error = await context.request.get(server.PREFIX + '/redirect').catch(e => e);
|
||||
expect(error.message).toContain(': aborted');
|
||||
expect(error.message).toBe('apiRequestContext.get: aborted');
|
||||
});
|
||||
|
||||
it('should add session cookies to request', async ({ context, server }) => {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ it('should emit created and destroyed events', async function({ page }) {
|
|||
await page.evaluate(workerObj => workerObj.terminate(), workerObj);
|
||||
expect(await workerDestroyedPromise).toBe(worker);
|
||||
const error = await workerThisObj.getProperty('self').catch(error => error);
|
||||
expect(error.message).toMatch(/jSHandle.getProperty: (Worker was closed|Target closed)/);
|
||||
expect(error.message).toMatch(/jsHandle.getProperty: (Worker was closed|Target closed)/);
|
||||
});
|
||||
|
||||
it('should report console logs', async function({ page }) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue