test(logging): disable pretty transport in e2e stream (#120)
This commit is contained in:
+16
-13
@@ -32,6 +32,7 @@ describe('Authentication (e2e)', () => {
|
|||||||
pinoHttp: {
|
pinoHttp: {
|
||||||
...loggingOptions(config),
|
...loggingOptions(config),
|
||||||
level: 'info',
|
level: 'info',
|
||||||
|
transport: undefined,
|
||||||
stream: { write: (line: string) => logs.push(JSON.parse(line) as Record<string, unknown>) },
|
stream: { write: (line: string) => logs.push(JSON.parse(line) as Record<string, unknown>) },
|
||||||
},
|
},
|
||||||
assignResponse: true,
|
assignResponse: true,
|
||||||
@@ -568,12 +569,21 @@ describe('Authentication (e2e)', () => {
|
|||||||
expect(body).toEqual({ status: 500, code: 'INTERNAL_SERVER_ERROR' }),
|
expect(body).toEqual({ status: 500, code: 'INTERNAL_SERVER_ERROR' }),
|
||||||
);
|
);
|
||||||
|
|
||||||
const related = logs.filter((entry) =>
|
expect(logs).toEqual(
|
||||||
entry.requestId === response.headers['x-request-id'] || entry.clientRequestId === clientRequestId,
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
method: 'POST',
|
||||||
|
route: '/api/v1/auth/login',
|
||||||
|
status: 500,
|
||||||
|
code: 'INTERNAL_SERVER_ERROR',
|
||||||
|
level: 50,
|
||||||
|
message: 'http.request.completed',
|
||||||
|
}),
|
||||||
|
]),
|
||||||
);
|
);
|
||||||
expect(related).toEqual([
|
expect(logs).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
requestId: response.headers['x-request-id'],
|
|
||||||
clientRequestId,
|
clientRequestId,
|
||||||
code: 'INTERNAL_SERVER_ERROR',
|
code: 'INTERNAL_SERVER_ERROR',
|
||||||
level: 50,
|
level: 50,
|
||||||
@@ -581,15 +591,8 @@ describe('Authentication (e2e)', () => {
|
|||||||
errorName: 'Error',
|
errorName: 'Error',
|
||||||
errorStack: expect.stringContaining(' at ') as unknown,
|
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(
|
expect(JSON.stringify(logs)).not.toContain(
|
||||||
'SYNTHETIC_AUDIT_SECRET',
|
'SYNTHETIC_AUDIT_SECRET',
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user