Skip to content

fix(test): correct assertions in zipkin browser export tests#6566

Merged
pichlermarc merged 1 commit intoopen-telemetry:mainfrom
embrace-io:overbalance/fix-zipkin-browser-tests
Apr 7, 2026
Merged

fix(test): correct assertions in zipkin browser export tests#6566
pichlermarc merged 1 commit intoopen-telemetry:mainfrom
embrace-io:overbalance/fix-zipkin-browser-tests

Conversation

@overbalance
Copy link
Copy Markdown
Contributor

@overbalance overbalance commented Apr 7, 2026

Which problem is this PR solving?

Several zipkin browser tests had assertions that silently passed without verifying anything. The tests appeared green but were not actually validating the behavior they claimed to test.

Short description of the changes

  • assert.ok(request.url, endpointUrl) was a no-op. assert.ok treats its second argument as a failure message, not a comparison value. The URL was never actually checked. Fixed to assert.strictEqual.

  • Environment variable test could never work in browser. The test set window.OTEL_EXPORTER_ZIPKIN_ENDPOINT expecting the exporter to read it, but window.OTEL_* support was removed in the 2.x release (Feb 2025). The browser getStringFromEnv() now unconditionally returns undefined, so the exporter silently fell through to the default URL (localhost:9411). The broken assert.ok masked this. Changed to use config.url, which is the only way to set a custom URL in the browser since 2.x.

  • globalErrorHandler tests asserted against the wrong code path. HTTP 400 responses trigger onreadystatechange (not xhr.onerror), so globalErrorHandler was never called. The old tests had no done callback, so the async assertions inside the export callback never ran. Rewritten to assert ExportResultCode.FAILED via the export callback with proper done handling.

  • Added two new tests for previously uncovered paths: sendBeacon returning false (browser refused to queue) and xhr.onerror network errors (DNS failure, CORS, connection refused) that call globalErrorHandler.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Browser tests pass in CI (karma/headless Chrome)
  • No regressions in existing zipkin exporter tests

Checklist:

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

@overbalance overbalance requested a review from a team as a code owner April 7, 2026 05:53
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.75%. Comparing base (1cf5ef3) to head (3dc73c4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6566      +/-   ##
==========================================
+ Coverage   95.74%   95.75%   +0.01%     
==========================================
  Files         371      371              
  Lines       12514    12514              
  Branches     2962     2962              
==========================================
+ Hits        11981    11983       +2     
+ Misses        533      531       -2     

see 1 file with indirect coverage changes

🚀 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.

@overbalance overbalance force-pushed the overbalance/fix-zipkin-browser-tests branch from b170d5a to 3dc73c4 Compare April 7, 2026 06:00
@pichlermarc pichlermarc added this pull request to the merge queue Apr 7, 2026
Merged via the queue into open-telemetry:main with commit d583a22 Apr 7, 2026
27 checks passed
@overbalance overbalance deleted the overbalance/fix-zipkin-browser-tests branch April 7, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants