0

I'm trying to use the ts-mockito library to mock the Open Telemetry object NodeTracerProvider, imported from @opentelementry/sdk-trace-node. However, it looks like the real object is being called rather than the mock object, as the log records exceptions ("Error: @opentelemetry/api: Attempted duplicate registration of API: trace") at @opentelemetry/sdk-trace-node/src/NodeTracerProvider.ts:68:11. I'm a beginner when it comes to Typescript and ts-mockito, so this could well be a very simple problem to fix. The test harness looks like this:

const mockNodeTracerProvider = mock(NodeTracerProvider);
when(mockNodeTracerProvider.register()).thenReturn();

All advice will be very gratefully received.

0 Answers0