Skip to content

Commit

Permalink
test(opentelemetry-plugin-xml-http-request): header prop tests
Browse files Browse the repository at this point in the history
fix header propagation tests that were affected by added a preflight
span
  • Loading branch information
thgao committed Jun 18, 2020
1 parent 0898236 commit 7a88ba5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,15 @@ describe('xhr', () => {
describe('AND origin match with window.location', () => {
beforeEach(done => {
clearData();
// this won't generate a preflight span
const propagateTraceHeaderCorsUrls = [url];
prepareData(done, url, { propagateTraceHeaderCorsUrls });
prepareData(done, window.location.origin + '/xml-http-request.js', {
propagateTraceHeaderCorsUrls,
});
});

it('should set trace headers', () => {
const span: api.Span = exportSpy.args[1][0][0];
const span: api.Span = exportSpy.args[0][0][0];
assert.strictEqual(
requests[0].requestHeaders[X_B3_TRACE_ID],
span.context().traceId,
Expand Down Expand Up @@ -513,7 +516,8 @@ describe('xhr', () => {
);
});
it('should set trace headers', () => {
const span: api.Span = exportSpy.args[1][0][0];
// span at exportSpy.args[0][0][0] is the preflight span
const span: api.Span = exportSpy.args[1][0][0];
assert.strictEqual(
requests[0].requestHeaders[X_B3_TRACE_ID],
span.context().traceId,
Expand Down

0 comments on commit 7a88ba5

Please sign in to comment.