import { Hono } from 'hono' import * as Timing from './Timing.js' describe('middleware', () => { test('emits request and operation server timings', async () => { const app = new Hono<{ Variables: Timing.Variables }>() app.use('*', Timing.middleware()) app.get('/', async (c) => { await Timing.time(c, 'example.work', () => Promise.resolve()) return c.text('ok') }) const response = await app.request('/') const timing = response.headers.get('server-timing') expect(response.status).toMatchInlineSnapshot(`200`) expect(response.headers.get('content-type')).toMatchInlineSnapshot(`"text/plain;charset=UTF-8"`) expect(timing?.includes('example.work;dur=')).toMatchInlineSnapshot(`true`) expect(timing?.includes('request;dur=')).toMatchInlineSnapshot(`true`) }) })