message: fix(tests): Clear mocks in MetricsInstrumentation tests.
diff: @@ -173,6 +173,10 @@ describe('addResourceSpans', () => {
  });
  describe('MetricsInstrumentation', () => {
  + afterEach(() => {
  + jest.clearAllMocks();
  + });
  +
  it('does not initialize trackers when on node', () => {
  const trackers = ['_trackCLS', '_trackLCP', '_trackFID'].map(tracker =>
  jest.spyOn(MetricsInstrumentation.prototype as any, tracker),
  @@ -183,35 +187,38 @@ describe('MetricsInstrumentation', () => {
  trackers.forEach(tracker => expect(tracker).not.toBeCalled());
  });
  - it('does not initialize trackers when not on node but `global.document` is not available (in worker)', () => {
  - // window not necessary for this test, but it is here to exercise that it is absence of document that is checked
  - addDOMPropertiesToGlobal(['performance', 'addEventListener', 'window']);
  - const processBackup = global.process;
  + it('initializes trackers when not on node and `global.performance` and `global.document` are available.', () => {
  + addDOMPropertiesToGlobal(['performance', 'document', 'addEventListener', 'window']);
  +
  + const backup = global.process;
  global.process = undefined;
  - const documentBackup = global.document;
  - global.document = undefined;
  const trackers = ['_trackCLS', '_trackLCP', '_trackFID'].map(tracker =>
  jest.spyOn(MetricsInstrumentation.prototype as any, tracker),
  );
  +
  new MetricsInstrumentation();
  - global.process = processBackup;
  - global.document = documentBackup;
  + global.process = backup;
  - trackers.forEach(tracker => expect(tracker).not.toBeCalled());
  + trackers.forEach(tracker => expect(tracker).toBeCalled());
  });
  - it('initializes trackers when not on node and `global.performance` and `global.document` are available.', () => {
  - addDOMPropertiesToGlobal(['performance', 'document', 'addEventListener', 'window']);
  - const backup = global.process;
  + it('does not initialize trackers when not on node but `global.document` is not available (in worker)', () => {
  + // window not necessary for this test, but it is here to exercise that it is absence of document that is checked
  + addDOMPropertiesToGlobal(['performance', 'addEventListener', 'window']);
  +
  + const processBackup = global.process;
  global.process = undefined;
  + const documentBackup = global.document;
  + global.document = undefined;
  const trackers = ['_trackCLS', '_trackLCP', '_trackFID'].map(tracker =>
  jest.spyOn(MetricsInstrumentation.prototype as any, tracker),
  );
  new MetricsInstrumentation();
  - global.process = backup;
  + global.process = processBackup;
  + global.document = documentBackup;
  - trackers.forEach(tracker => expect(tracker).toBeCalled());
  + trackers.forEach(tracker => expect(tracker).not.toBeCalled());
  });
  });
  