diff --git a/packages/fastify-core/src/__tests__/fastify-core.test.ts b/packages/fastify-core/src/__tests__/fastify-core.test.ts index 0fb60f5f..77e6233d 100644 --- a/packages/fastify-core/src/__tests__/fastify-core.test.ts +++ b/packages/fastify-core/src/__tests__/fastify-core.test.ts @@ -32,8 +32,8 @@ describe('createServiceApp', () => { expect(body.service).toBe('my-service'); expect(body.version).toBe('1.2.3'); expect(body.description).toBe('A test service'); - expect(body.timestamp).toBeTruthy(); - expect(body.requestId).toBeTruthy(); + expect(body.timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T/); + expect(body.requestId).toBe(res.headers['x-request-id']); await app.close(); }); @@ -72,6 +72,8 @@ describe('createServiceApp', () => { expect(res.headers['x-request-id']).toMatch( /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/ ); + const body = JSON.parse(res.payload); + expect(body.requestId).toBe(res.headers['x-request-id']); await app.close(); }); @@ -92,7 +94,7 @@ describe('createServiceApp', () => { expect(res.statusCode).toBe(404); const body = JSON.parse(res.payload); expect(body.error).toBe('User not found'); - expect(body.requestId).toBeTruthy(); + expect(body.requestId).toBe(res.headers['x-request-id']); await app.close(); }); @@ -114,7 +116,7 @@ describe('createServiceApp', () => { const body = JSON.parse(res.payload); expect(body.error).toBe('Validation failed'); expect(body.details).toEqual({ field: 'email' }); - expect(body.requestId).toBeTruthy(); + expect(body.requestId).toBe(res.headers['x-request-id']); await app.close(); }); @@ -134,7 +136,7 @@ describe('createServiceApp', () => { expect(res.statusCode).toBe(500); const body = JSON.parse(res.payload); expect(body.error).toBe('Internal server error'); - expect(body.requestId).toBeTruthy(); + expect(body.requestId).toBe(res.headers['x-request-id']); await app.close(); }); @@ -166,6 +168,8 @@ describe('createServiceApp', () => { expect(JSON.parse(before.payload)).toMatchObject({ status: 'not_ready', service: 'ready-test', + version: '1.0.0', + requestId: before.headers['x-request-id'], }); app.setReadyState(true); @@ -175,6 +179,8 @@ describe('createServiceApp', () => { expect(JSON.parse(after.payload)).toMatchObject({ status: 'ready', service: 'ready-test', + version: '1.0.0', + requestId: after.headers['x-request-id'], }); await app.close(); diff --git a/packages/react-auth/src/__tests__/react-auth.test.tsx b/packages/react-auth/src/__tests__/react-auth.test.tsx index e3c90aea..0c080713 100644 --- a/packages/react-auth/src/__tests__/react-auth.test.tsx +++ b/packages/react-auth/src/__tests__/react-auth.test.tsx @@ -67,8 +67,7 @@ describe('createAuthProvider', () => {