From e0d5ded67a48f4973fd416fbc37d87e7aaa0dc10 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Tue, 21 Oct 2025 14:11:57 +0200 Subject: [PATCH] fix: indicate when request and response bodies are not available --- src/formatters/networkFormatter.ts | 6 ++---- tests/formatters/networkFormatter.test.ts | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/formatters/networkFormatter.ts b/src/formatters/networkFormatter.ts index b3466e8c..0d8189ba 100644 --- a/src/formatters/networkFormatter.ts +++ b/src/formatters/networkFormatter.ts @@ -68,8 +68,7 @@ export async function getFormattedResponseBody( return ``; } catch { - // buffer() call might fail with CDP exception, in this case we don't print anything in the context - return; + return ``; } } @@ -91,8 +90,7 @@ export async function getFormattedRequestBody( return `${getSizeLimitedString(fetchData, sizeLimit)}`; } } catch { - // fetchPostData() call might fail with CDP exception, in this case we don't print anything in the context - return; + return ``; } } diff --git a/tests/formatters/networkFormatter.test.ts b/tests/formatters/networkFormatter.test.ts index e9608f50..e22b0140 100644 --- a/tests/formatters/networkFormatter.test.ts +++ b/tests/formatters/networkFormatter.test.ts @@ -115,7 +115,7 @@ describe('networkFormatter', () => { assert.strictEqual(result, 'test'); }); - it('shows empty string when no postData available', async () => { + it('shows not available when no postData available', async () => { const request = getMockRequest({ hasPostData: false, }); @@ -164,7 +164,7 @@ describe('networkFormatter', () => { assert.strictEqual(result, 'some text that is lo... '); }); - it('shows nothing on exception', async () => { + it('shows not available on exception', async () => { const request = getMockRequest({ hasPostData: true, postData: undefined, @@ -173,7 +173,7 @@ describe('networkFormatter', () => { const result = await getFormattedRequestBody(request, 200); - assert.strictEqual(result, undefined); + assert.strictEqual(result, ''); }); }); @@ -232,7 +232,7 @@ describe('networkFormatter', () => { const result = await getFormattedResponseBody(response, 200); - assert.strictEqual(result, undefined); + assert.strictEqual(result, ''); }); }); });