Skip to content

tests(sdk-node, sdk-trace-node, sdk-trace-web): 6077 refactor test global providers#6319

Merged
pichlermarc merged 4 commits intoopen-telemetry:mainfrom
david-luna:6077-refactor-test-global-providers
Jan 20, 2026
Merged

tests(sdk-node, sdk-trace-node, sdk-trace-web): 6077 refactor test global providers#6319
pichlermarc merged 4 commits intoopen-telemetry:mainfrom
david-luna:6077-refactor-test-global-providers

Conversation

@david-luna
Copy link
Copy Markdown
Contributor

Which problem is this PR solving?

Refactor SDK tests to not assert on Proxy*Provider but do it in setGlobal*Provider calls.

Closes #6077

Short description of the changes

Type of change

  • Test Refactor

How Has This Been Tested?

  • ran tests with the new assertions

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been updated

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.46%. Comparing base (adbaa90) to head (b2c0806).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6319   +/-   ##
=======================================
  Coverage   95.46%   95.46%           
=======================================
  Files         317      317           
  Lines        9599     9599           
  Branches     2218     2218           
=======================================
  Hits         9164     9164           
  Misses        435      435           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks for working on it 🙌

The current assertions fit in with the rest of this test, but long-term it may be simpler to use sinon assertions. that's non-blocking though, could be a good-first-issue follow-up. 🙂

Comment on lines +144 to 147
assert.ok(
setGlobalTracerProviderSpy.called === false,
'tracer provider should not have changed'
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we could probably use

Sinon.assert.notCalled(setGlobalTracerProviderSpy);

for this type of assertion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept using assert so we keep the error message but I agree maybe it's not necessary.

Comment on lines +201 to +205
assert.strictEqual(setGlobalTracerProviderSpy.callCount, 1);
assert.ok(
setGlobalTracerProviderSpy.lastCall.args[0] instanceof
NodeTracerProvider
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we could probably use

Sinon.assert.calledOnceWithMatch(
        setGlobalTracerProviderSpy,
        (arg: any) => {
          return arg instanceof NodeTracerProvider;
        }
      );

for this type of assertion.

@pichlermarc pichlermarc added this pull request to the merge queue Jan 20, 2026
Merged via the queue into open-telemetry:main with commit 435aada Jan 20, 2026
30 checks passed
@david-luna david-luna deleted the 6077-refactor-test-global-providers branch January 20, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sdk-node] rewrite tests to spy on setGlobal*Provider instead of accessing Proxy*Provider

3 participants