Skip to content

Commit 7f4f9d7

Browse files
committed
skip xhr tests in non-chromium
1 parent 0ada693 commit 7f4f9d7

File tree

4 files changed

+112
-102
lines changed
  • packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr

4 files changed

+112
-102
lines changed

packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/contentLengthHeader/test.ts

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,66 @@ import { sentryTest } from '../../../../../utils/fixtures';
44
import { envelopeRequestParser, waitForErrorRequest } from '../../../../../utils/helpers';
55
import { shouldSkipReplayTest } from '../../../../../utils/replayHelpers';
66

7-
sentryTest('parses response_body_size from Content-Length header if available', async ({ getLocalTestPath, page }) => {
8-
if (shouldSkipReplayTest()) {
9-
sentryTest.skip();
10-
}
7+
sentryTest(
8+
'parses response_body_size from Content-Length header if available',
9+
async ({ getLocalTestPath, page, browserName }) => {
10+
// These are a bit flaky on non-chromium browsers
11+
if (shouldSkipReplayTest() || browserName !== 'chromium') {
12+
sentryTest.skip();
13+
}
1114

12-
await page.route('**/foo', route => {
13-
return route.fulfill({
14-
status: 200,
15-
body: JSON.stringify({
16-
userNames: ['John', 'Jane'],
17-
}),
18-
headers: {
19-
'Content-Type': 'application/json',
20-
'Content-Length': '789',
21-
},
15+
await page.route('**/foo', route => {
16+
return route.fulfill({
17+
status: 200,
18+
body: JSON.stringify({
19+
userNames: ['John', 'Jane'],
20+
}),
21+
headers: {
22+
'Content-Type': 'application/json',
23+
'Content-Length': '789',
24+
},
25+
});
2226
});
23-
});
2427

25-
const requestPromise = waitForErrorRequest(page);
26-
const url = await getLocalTestPath({ testDir: __dirname });
27-
await page.goto(url);
28+
const requestPromise = waitForErrorRequest(page);
29+
const url = await getLocalTestPath({ testDir: __dirname });
30+
await page.goto(url);
2831

29-
await page.evaluate(() => {
30-
/* eslint-disable */
31-
const xhr = new XMLHttpRequest();
32+
await page.evaluate(() => {
33+
/* eslint-disable */
34+
const xhr = new XMLHttpRequest();
3235

33-
xhr.open('GET', 'http://localhost:7654/foo');
34-
xhr.setRequestHeader('Accept', 'application/json');
35-
xhr.setRequestHeader('Content-Type', 'application/json');
36-
xhr.setRequestHeader('Cache', 'no-cache');
37-
xhr.send();
36+
xhr.open('GET', 'http://localhost:7654/foo');
37+
xhr.setRequestHeader('Accept', 'application/json');
38+
xhr.setRequestHeader('Content-Type', 'application/json');
39+
xhr.setRequestHeader('Cache', 'no-cache');
40+
xhr.send();
3841

39-
xhr.addEventListener('readystatechange', function () {
40-
if (xhr.readyState === 4) {
41-
// @ts-ignore Sentry is a global
42-
setTimeout(() => Sentry.captureException('test error', 0));
43-
}
42+
xhr.addEventListener('readystatechange', function () {
43+
if (xhr.readyState === 4) {
44+
// @ts-ignore Sentry is a global
45+
setTimeout(() => Sentry.captureException('test error', 0));
46+
}
47+
});
48+
/* eslint-enable */
4449
});
45-
/* eslint-enable */
46-
});
4750

48-
const request = await requestPromise;
49-
const eventData = envelopeRequestParser(request);
51+
const request = await requestPromise;
52+
const eventData = envelopeRequestParser(request);
5053

51-
expect(eventData.exception?.values).toHaveLength(1);
54+
expect(eventData.exception?.values).toHaveLength(1);
5255

53-
expect(eventData?.breadcrumbs?.length).toBe(1);
54-
expect(eventData!.breadcrumbs![0]).toEqual({
55-
timestamp: expect.any(Number),
56-
category: 'xhr',
57-
type: 'http',
58-
data: {
59-
method: 'GET',
60-
response_body_size: 789,
61-
status_code: 200,
62-
url: 'http://localhost:7654/foo',
63-
},
64-
});
65-
});
56+
expect(eventData?.breadcrumbs?.length).toBe(1);
57+
expect(eventData!.breadcrumbs![0]).toEqual({
58+
timestamp: expect.any(Number),
59+
category: 'xhr',
60+
type: 'http',
61+
data: {
62+
method: 'GET',
63+
response_body_size: 789,
64+
status_code: 200,
65+
url: 'http://localhost:7654/foo',
66+
},
67+
});
68+
},
69+
);

packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/noContentLengthHeader/test.ts

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,66 @@ import { sentryTest } from '../../../../../utils/fixtures';
44
import { envelopeRequestParser, waitForErrorRequest } from '../../../../../utils/helpers';
55
import { shouldSkipReplayTest } from '../../../../../utils/replayHelpers';
66

7-
sentryTest('captures response_body_size without Content-Length header', async ({ getLocalTestPath, page }) => {
8-
if (shouldSkipReplayTest()) {
9-
sentryTest.skip();
10-
}
7+
sentryTest(
8+
'captures response_body_size without Content-Length header',
9+
async ({ getLocalTestPath, page, browserName }) => {
10+
// These are a bit flaky on non-chromium browsers
11+
if (shouldSkipReplayTest() || browserName !== 'chromium') {
12+
sentryTest.skip();
13+
}
1114

12-
await page.route('**/foo', route => {
13-
return route.fulfill({
14-
status: 200,
15-
body: JSON.stringify({
16-
userNames: ['John', 'Jane'],
17-
}),
18-
headers: {
19-
'Content-Type': 'application/json',
20-
'Content-Length': '',
21-
},
15+
await page.route('**/foo', route => {
16+
return route.fulfill({
17+
status: 200,
18+
body: JSON.stringify({
19+
userNames: ['John', 'Jane'],
20+
}),
21+
headers: {
22+
'Content-Type': 'application/json',
23+
'Content-Length': '',
24+
},
25+
});
2226
});
23-
});
2427

25-
const requestPromise = waitForErrorRequest(page);
26-
const url = await getLocalTestPath({ testDir: __dirname });
27-
await page.goto(url);
28+
const requestPromise = waitForErrorRequest(page);
29+
const url = await getLocalTestPath({ testDir: __dirname });
30+
await page.goto(url);
2831

29-
await page.evaluate(() => {
30-
/* eslint-disable */
31-
const xhr = new XMLHttpRequest();
32+
await page.evaluate(() => {
33+
/* eslint-disable */
34+
const xhr = new XMLHttpRequest();
3235

33-
xhr.open('GET', 'http://localhost:7654/foo');
34-
xhr.setRequestHeader('Accept', 'application/json');
35-
xhr.setRequestHeader('Content-Type', 'application/json');
36-
xhr.setRequestHeader('Cache', 'no-cache');
37-
xhr.send();
36+
xhr.open('GET', 'http://localhost:7654/foo');
37+
xhr.setRequestHeader('Accept', 'application/json');
38+
xhr.setRequestHeader('Content-Type', 'application/json');
39+
xhr.setRequestHeader('Cache', 'no-cache');
40+
xhr.send();
3841

39-
xhr.addEventListener('readystatechange', function () {
40-
if (xhr.readyState === 4) {
41-
// @ts-ignore Sentry is a global
42-
setTimeout(() => Sentry.captureException('test error', 0));
43-
}
42+
xhr.addEventListener('readystatechange', function () {
43+
if (xhr.readyState === 4) {
44+
// @ts-ignore Sentry is a global
45+
setTimeout(() => Sentry.captureException('test error', 0));
46+
}
47+
});
48+
/* eslint-enable */
4449
});
45-
/* eslint-enable */
46-
});
4750

48-
const request = await requestPromise;
49-
const eventData = envelopeRequestParser(request);
51+
const request = await requestPromise;
52+
const eventData = envelopeRequestParser(request);
5053

51-
expect(eventData.exception?.values).toHaveLength(1);
54+
expect(eventData.exception?.values).toHaveLength(1);
5255

53-
expect(eventData?.breadcrumbs?.length).toBe(1);
54-
expect(eventData!.breadcrumbs![0]).toEqual({
55-
timestamp: expect.any(Number),
56-
category: 'xhr',
57-
type: 'http',
58-
data: {
59-
method: 'GET',
60-
response_body_size: 29,
61-
status_code: 200,
62-
url: 'http://localhost:7654/foo',
63-
},
64-
});
65-
});
56+
expect(eventData?.breadcrumbs?.length).toBe(1);
57+
expect(eventData!.breadcrumbs![0]).toEqual({
58+
timestamp: expect.any(Number),
59+
category: 'xhr',
60+
type: 'http',
61+
data: {
62+
method: 'GET',
63+
response_body_size: 29,
64+
status_code: 200,
65+
url: 'http://localhost:7654/foo',
66+
},
67+
});
68+
},
69+
);

packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/nonTextBody/test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { sentryTest } from '../../../../../utils/fixtures';
44
import { envelopeRequestParser, waitForErrorRequest } from '../../../../../utils/helpers';
55
import { shouldSkipReplayTest } from '../../../../../utils/replayHelpers';
66

7-
sentryTest('calculates body sizes for non-string bodies', async ({ getLocalTestPath, page }) => {
8-
if (shouldSkipReplayTest()) {
7+
sentryTest('calculates body sizes for non-string bodies', async ({ getLocalTestPath, page, browserName }) => {
8+
// These are a bit flaky on non-chromium browsers
9+
if (shouldSkipReplayTest() || browserName !== 'chromium') {
910
sentryTest.skip();
1011
}
1112

packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/xhr/requestBody/test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { sentryTest } from '../../../../../utils/fixtures';
44
import { envelopeRequestParser, waitForErrorRequest } from '../../../../../utils/helpers';
55
import { shouldSkipReplayTest } from '../../../../../utils/replayHelpers';
66

7-
sentryTest('captures request_body_size when body is sent', async ({ getLocalTestPath, page }) => {
8-
if (shouldSkipReplayTest()) {
7+
sentryTest('captures request_body_size when body is sent', async ({ getLocalTestPath, page, browserName }) => {
8+
// These are a bit flaky on non-chromium browsers
9+
if (shouldSkipReplayTest() || browserName !== 'chromium') {
910
sentryTest.skip();
1011
}
1112

0 commit comments

Comments
 (0)