Skip to content

Commit 0898236

Browse files
committed
test(opentelemetry-plugin-xml-http-request): ignored urls
added test for when request url is an ignored url from plugin config
1 parent 595ee85 commit 0898236

File tree

1 file changed

+21
-8
lines changed
  • packages/opentelemetry-plugin-xml-http-request/test

1 file changed

+21
-8
lines changed

packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts

+21-8
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,7 @@ describe('xhr', () => {
152152
spyEntries.restore();
153153
};
154154

155-
prepareData = (
156-
done: any,
157-
fileUrl: string,
158-
propagateTraceHeaderCorsUrls?: any
159-
) => {
155+
prepareData = (done: any, fileUrl: string, config?: any) => {
160156
sandbox = sinon.createSandbox();
161157
const fakeXhr = sandbox.useFakeXMLHttpRequest();
162158
fakeXhr.onCreate = function (xhr: any) {
@@ -179,9 +175,7 @@ describe('xhr', () => {
179175

180176
spyEntries = sandbox.stub(performance, 'getEntriesByType');
181177
spyEntries.withArgs('resource').returns(resources);
182-
xmlHttpRequestPlugin = new XMLHttpRequestPlugin(
183-
propagateTraceHeaderCorsUrls
184-
);
178+
xmlHttpRequestPlugin = new XMLHttpRequestPlugin(config);
185179
webTracerProviderWithZone = new WebTracerProvider({
186180
logLevel: LogLevel.ERROR,
187181
plugins: [xmlHttpRequestPlugin],
@@ -460,6 +454,25 @@ describe('xhr', () => {
460454
);
461455
});
462456

457+
describe('when url is ignored', () => {
458+
beforeEach(done => {
459+
clearData();
460+
const propagateTraceHeaderCorsUrls = url;
461+
prepareData(done, url, {
462+
propagateTraceHeaderCorsUrls,
463+
ignoreUrls: [propagateTraceHeaderCorsUrls],
464+
});
465+
});
466+
467+
it('should NOT create any span', () => {
468+
assert.strictEqual(
469+
exportSpy.args.length,
470+
0,
471+
"span shouldn't be exported"
472+
);
473+
});
474+
});
475+
463476
describe('AND origin match with window.location', () => {
464477
beforeEach(done => {
465478
clearData();

0 commit comments

Comments
 (0)