From 7a88ba55b3f315e127ca7acef4f800eae80d7a99 Mon Sep 17 00:00:00 2001 From: Tina Gao Date: Thu, 11 Jun 2020 15:09:06 -0400 Subject: [PATCH] test(opentelemetry-plugin-xml-http-request): header prop tests fix header propagation tests that were affected by added a preflight span --- .../test/xhr.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts index f0cb6075ef0..d498876c63b 100644 --- a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts +++ b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts @@ -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, @@ -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,