From 5cf0efd8133a3cf60f74404eedf236811d2820e4 Mon Sep 17 00:00:00 2001 From: Sergey Krylov Date: Sat, 24 Oct 2026 14:54:23 +0300 Subject: [PATCH] test(logging): disable pretty transport in e2e stream (#120) --- test/app.e2e-spec.ts | 45 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts index b751f6f..5b2f4ab 100644 --- a/test/app.e2e-spec.ts +++ b/test/app.e2e-spec.ts @@ -32,6 +32,7 @@ describe('Authentication (e2e)', () => { pinoHttp: { ...loggingOptions(config), level: 'info', + transport: undefined, stream: { write: (line: string) => logs.push(JSON.parse(line) as Record) }, }, assignResponse: true, @@ -568,28 +569,30 @@ describe('Authentication (e2e)', () => { expect(body).toEqual({ status: 500, code: 'INTERNAL_SERVER_ERROR' }), ); - const related = logs.filter((entry) => - entry.requestId === response.headers['x-request-id'] || entry.clientRequestId === clientRequestId, + expect(logs).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + method: 'POST', + route: '/api/v1/auth/login', + status: 500, + code: 'INTERNAL_SERVER_ERROR', + level: 50, + message: 'http.request.completed', + }), + ]), + ); + expect(logs).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + clientRequestId, + code: 'INTERNAL_SERVER_ERROR', + level: 50, + message: 'http.request.unhandled', + errorName: 'Error', + errorStack: expect.stringContaining(' at ') as unknown, + }), + ]), ); - expect(related).toEqual([ - expect.objectContaining({ - requestId: response.headers['x-request-id'], - clientRequestId, - code: 'INTERNAL_SERVER_ERROR', - level: 50, - message: 'http.request.unhandled', - errorName: 'Error', - errorStack: expect.stringContaining(' at ') as unknown, - }), - expect.objectContaining({ - requestId: response.headers['x-request-id'], - clientRequestId, - status: 500, - code: 'INTERNAL_SERVER_ERROR', - level: 50, - message: 'http.request.completed', - }), - ]); expect(JSON.stringify(logs)).not.toContain( 'SYNTHETIC_AUDIT_SECRET', );