Files
outline/server/__mocks__/dd-trace.ts
T
Hemachandar 04c3d81b1f chore: Setup missing oxlint configs (#9862)
* shared

* server

* app

* remove vestigial eslintrc files

* update comment directives
2025-08-06 19:54:22 -04:00

40 lines
1.0 KiB
TypeScript

/* oxlint-disable @typescript-eslint/explicit-function-return-type */
import { Tracer } from "dd-trace";
// oxlint-disable-next-line @typescript-eslint/no-empty-function
const emptyFn = function () {};
const callableHandlers = {
get<T, P extends keyof T>(_target: T, _prop: P, _receiver: any): T[P] {
const newMock = new Proxy(emptyFn, callableHandlers);
return newMock as any as T[P];
},
apply<T extends (...args: any) => any, A extends Parameters<T>>(
_target: T,
_thisArg: any,
_args: A
): ReturnType<T> {
const newMock = new Proxy(emptyFn, callableHandlers);
return newMock as any as ReturnType<T>;
},
};
const callableMock = new Proxy(emptyFn, callableHandlers);
type MockTracer = Tracer & { isMock?: boolean };
export const mockTracer = new Proxy({} as MockTracer, {
get<K extends keyof MockTracer>(_target: Tracer, key: K) {
if (key === "isMock") {
return true;
}
if (key === "wrap") {
return (_: any, f: any) => f;
}
return callableMock;
},
});