File size: 691 Bytes
bf48b89 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import { describe, expect, it } from 'vitest';
import { config } from '@/config';
import trace from '@/middleware/trace';
describe('trace middleware', () => {
it('skips tracing when debugInfo is disabled', async () => {
const originalDebug = config.debugInfo;
config.debugInfo = false;
let called = false;
const ctx = {
req: {
method: 'GET',
raw: new Request('http://localhost/test'),
},
};
const next = () => {
called = true;
};
await trace(ctx as any, next);
expect(called).toBe(true);
config.debugInfo = originalDebug;
});
});
|