Skip to content

Commit 8662d1a

Browse files
committed
test: Fix fetch tests for fetch-incapable browsers
1 parent 8783e19 commit 8662d1a

File tree

1 file changed

+23
-72
lines changed

1 file changed

+23
-72
lines changed

test/integration/test.js

Lines changed: 23 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ describe('integration', function() {
9494
);
9595
});
9696

97-
it('should generate a synthetic trace for captureException w/ non-errors', function(
98-
done
99-
) {
97+
it('should generate a synthetic trace for captureException w/ non-errors', function(done) {
10098
var iframe = this.iframe;
10199
iframeExecute(
102100
iframe,
@@ -117,9 +115,7 @@ describe('integration', function() {
117115
);
118116
});
119117

120-
it('should capture an Error object passed to Raven.captureException w/ maxMessageLength set (#647)', function(
121-
done
122-
) {
118+
it('should capture an Error object passed to Raven.captureException w/ maxMessageLength set (#647)', function(done) {
123119
var iframe = this.iframe;
124120
iframeExecute(
125121
iframe,
@@ -188,9 +184,7 @@ describe('integration', function() {
188184
);
189185
});
190186

191-
it('should not reject back-to-back errors with different stack traces', function(
192-
done
193-
) {
187+
it('should not reject back-to-back errors with different stack traces', function(done) {
194188
var iframe = this.iframe;
195189
iframeExecute(
196190
iframe,
@@ -239,9 +233,7 @@ describe('integration', function() {
239233
);
240234
});
241235

242-
it('should reject duplicate, back-to-back messages from captureMessage', function(
243-
done
244-
) {
236+
it('should reject duplicate, back-to-back messages from captureMessage', function(done) {
245237
var iframe = this.iframe;
246238
iframeExecute(
247239
iframe,
@@ -438,9 +430,7 @@ describe('integration', function() {
438430
);
439431
});
440432

441-
it('should catch an exception already caught [but rethrown] via Raven.captureException', function(
442-
done
443-
) {
433+
it('should catch an exception already caught [but rethrown] via Raven.captureException', function(done) {
444434
// unlike Raven.wrap which ALWAYS re-throws, we don't know if the user will
445435
// re-throw an exception passed to Raven.captureException, and so we cannot
446436
// automatically suppress the next error caught through window.onerror
@@ -496,9 +486,7 @@ describe('integration', function() {
496486
);
497487
});
498488

499-
it('should transparently remove event listeners from wrapped functions', function(
500-
done
501-
) {
489+
it('should transparently remove event listeners from wrapped functions', function(done) {
502490
var iframe = this.iframe;
503491

504492
iframeExecute(
@@ -588,9 +576,7 @@ describe('integration', function() {
588576
);
589577
});
590578

591-
it('should capture exceptions from XMLHttpRequest event handlers (e.g. onreadystatechange)', function(
592-
done
593-
) {
579+
it('should capture exceptions from XMLHttpRequest event handlers (e.g. onreadystatechange)', function(done) {
594580
var iframe = this.iframe;
595581

596582
iframeExecute(
@@ -692,9 +678,7 @@ describe('integration', function() {
692678
);
693679
});
694680

695-
it('should NOT denote XMLHttpRequests to the Sentry store endpoint as requiring breadcrumb capture', function(
696-
done
697-
) {
681+
it('should NOT denote XMLHttpRequests to the Sentry store endpoint as requiring breadcrumb capture', function(done) {
698682
var iframe = this.iframe;
699683
iframeExecute(
700684
iframe,
@@ -749,25 +733,18 @@ describe('integration', function() {
749733
assert.equal(breadcrumbs[0].data.url, breadcrumbUrl);
750734
} else {
751735
// otherwise we use a fetch polyfill based on xhr
752-
assert.equal(breadcrumbs.length, 2);
736+
assert.equal(breadcrumbs.length, 1);
753737

754738
assert.equal(breadcrumbs[0].type, 'http');
755-
assert.equal(breadcrumbs[0].category, 'fetch');
739+
assert.equal(breadcrumbs[0].category, 'xhr');
756740
assert.equal(breadcrumbs[0].data.method, 'GET');
757741
assert.equal(breadcrumbs[0].data.url, breadcrumbUrl);
758-
759-
assert.equal(breadcrumbs[1].type, 'http');
760-
assert.equal(breadcrumbs[1].category, 'xhr');
761-
assert.equal(breadcrumbs[1].data.method, 'GET');
762-
assert.equal(breadcrumbs[1].data.url, breadcrumbUrl);
763742
}
764743
}
765744
);
766745
});
767746

768-
it('should record a fetch request with Request obj instead of URL string', function(
769-
done
770-
) {
747+
it('should record a fetch request with Request obj instead of URL string', function(done) {
771748
var iframe = this.iframe;
772749

773750
iframeExecute(
@@ -801,17 +778,12 @@ describe('integration', function() {
801778
assert.ok(breadcrumbs[0].data.url.indexOf(breadcrumbUrl) !== -1);
802779
} else {
803780
// otherwise we use a fetch polyfill based on xhr
804-
assert.equal(breadcrumbs.length, 2);
781+
assert.equal(breadcrumbs.length, 1);
805782

806783
assert.equal(breadcrumbs[0].type, 'http');
807-
assert.equal(breadcrumbs[0].category, 'fetch');
784+
assert.equal(breadcrumbs[0].category, 'xhr');
808785
assert.equal(breadcrumbs[0].data.method, 'GET');
809786
assert.ok(breadcrumbs[0].data.url.indexOf(breadcrumbUrl) !== -1);
810-
811-
assert.equal(breadcrumbs[1].type, 'http');
812-
assert.equal(breadcrumbs[1].category, 'xhr');
813-
assert.equal(breadcrumbs[1].data.method, 'GET');
814-
assert.ok(breadcrumbs[1].data.url.indexOf(breadcrumbUrl) !== -1);
815787
}
816788
}
817789
);
@@ -851,25 +823,18 @@ describe('integration', function() {
851823
assert.ok(breadcrumbs[0].data.url.indexOf(breadcrumbUrl) !== -1);
852824
} else {
853825
// otherwise we use a fetch polyfill based on xhr
854-
assert.equal(breadcrumbs.length, 2);
826+
assert.equal(breadcrumbs.length, 1);
855827

856828
assert.equal(breadcrumbs[0].type, 'http');
857-
assert.equal(breadcrumbs[0].category, 'fetch');
829+
assert.equal(breadcrumbs[0].category, 'xhr');
858830
assert.equal(breadcrumbs[0].data.method, 'GET');
859831
assert.ok(breadcrumbs[0].data.url.indexOf(breadcrumbUrl) !== -1);
860-
861-
assert.equal(breadcrumbs[1].type, 'http');
862-
assert.equal(breadcrumbs[1].category, 'xhr');
863-
assert.equal(breadcrumbs[1].data.method, 'GET');
864-
assert.ok(breadcrumbs[1].data.url.indexOf(breadcrumbUrl) !== -1);
865832
}
866833
}
867834
);
868835
});
869836

870-
it('should record a mouse click on element WITH click handler present', function(
871-
done
872-
) {
837+
it('should record a mouse click on element WITH click handler present', function(done) {
873838
var iframe = this.iframe;
874839

875840
iframeExecute(
@@ -909,9 +874,7 @@ describe('integration', function() {
909874
);
910875
});
911876

912-
it('should record a mouse click on element WITHOUT click handler present', function(
913-
done
914-
) {
877+
it('should record a mouse click on element WITHOUT click handler present', function(done) {
915878
var iframe = this.iframe;
916879

917880
iframeExecute(
@@ -943,9 +906,7 @@ describe('integration', function() {
943906
);
944907
});
945908

946-
it('should only record a SINGLE mouse click for a tree of elements with event listeners', function(
947-
done
948-
) {
909+
it('should only record a SINGLE mouse click for a tree of elements with event listeners', function(done) {
949910
var iframe = this.iframe;
950911

951912
iframeExecute(
@@ -985,9 +946,7 @@ describe('integration', function() {
985946
);
986947
});
987948

988-
it('should bail out if accessing the `type` and `target` properties of an event throw an exception', function(
989-
done
990-
) {
949+
it('should bail out if accessing the `type` and `target` properties of an event throw an exception', function(done) {
991950
// see: https://github.com/getsentry/raven-js/issues/768
992951
var iframe = this.iframe;
993952

@@ -1022,9 +981,7 @@ describe('integration', function() {
1022981
);
1023982
});
1024983

1025-
it('should record consecutive keypress events into a single "input" breadcrumb', function(
1026-
done
1027-
) {
984+
it('should record consecutive keypress events into a single "input" breadcrumb', function(done) {
1028985
var iframe = this.iframe;
1029986

1030987
iframeExecute(
@@ -1095,9 +1052,7 @@ describe('integration', function() {
10951052
);
10961053
});
10971054

1098-
it('should flush keypress breadcrumb when input event occurs immediately after', function(
1099-
done
1100-
) {
1055+
it('should flush keypress breadcrumb when input event occurs immediately after', function(done) {
11011056
var iframe = this.iframe;
11021057

11031058
iframeExecute(
@@ -1149,9 +1104,7 @@ describe('integration', function() {
11491104
);
11501105
});
11511106

1152-
it('should record consecutive keypress events in a contenteditable into a single "input" breadcrumb', function(
1153-
done
1154-
) {
1107+
it('should record consecutive keypress events in a contenteditable into a single "input" breadcrumb', function(done) {
11551108
var iframe = this.iframe;
11561109

11571110
iframeExecute(
@@ -1186,9 +1139,7 @@ describe('integration', function() {
11861139
);
11871140
});
11881141

1189-
it('should record history.[pushState|replaceState] changes as navigation breadcrumbs', function(
1190-
done
1191-
) {
1142+
it('should record history.[pushState|replaceState] changes as navigation breadcrumbs', function(done) {
11921143
var iframe = this.iframe;
11931144

11941145
iframeExecute(

0 commit comments

Comments
 (0)