Skip to content

Commit fd20fd0

Browse files
committed
Add integration tests for function identifiers.
1 parent e232a4e commit fd20fd0

File tree

8 files changed

+236
-0
lines changed

8 files changed

+236
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function httpsCall() {
2+
webpackDevServer();
3+
}
4+
5+
const webpackDevServer = () => {
6+
Response.httpCode();
7+
};
8+
9+
class Response {
10+
constructor() {}
11+
12+
static httpCode(params) {
13+
throw new Error('test_err');
14+
}
15+
}
16+
17+
const decodeBlob = function() {
18+
(function readFile() {
19+
httpsCall();
20+
})();
21+
};
22+
23+
try {
24+
decodeBlob();
25+
} catch (err) {
26+
Sentry.captureException(err);
27+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../utils/fixtures';
4+
import { getSentryRequest } from '../../../utils/helpers';
5+
6+
sentryTest(
7+
'should parse function identifiers that contain protocol names correctly',
8+
async ({ getLocalTestPath, page, browserName }) => {
9+
const url = await getLocalTestPath({ testDir: __dirname });
10+
11+
const eventData = await getSentryRequest(page, url);
12+
13+
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject(
14+
browserName === 'chromium'
15+
? [
16+
{ function: '?' },
17+
{ function: '?' },
18+
{ function: 'decodeBlob' },
19+
{ function: 'readFile' },
20+
{ function: 'httpsCall' },
21+
{ function: 'webpackDevServer' },
22+
{ function: 'Function.httpCode' },
23+
]
24+
: browserName === 'firefox'
25+
? [
26+
{ function: '?' },
27+
{ function: '?' },
28+
{ function: 'decodeBlob' },
29+
{ function: 'readFile' },
30+
{ function: 'httpsCall' },
31+
{ function: 'webpackDevServer' },
32+
{ function: 'httpCode' },
33+
]
34+
: [
35+
{ function: 'global code' },
36+
{ function: '?' },
37+
{ function: 'decodeBlob' },
38+
{ function: 'readFile' },
39+
{ function: 'httpsCall' },
40+
{ function: 'webpackDevServer' },
41+
{ function: 'httpCode' },
42+
],
43+
);
44+
},
45+
);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function https() {
2+
webpack();
3+
}
4+
5+
const webpack = () => {
6+
File.http();
7+
};
8+
9+
class File {
10+
constructor() {}
11+
12+
static http(params) {
13+
throw new Error('test_err');
14+
}
15+
}
16+
17+
const blob = function() {
18+
(function file() {
19+
https();
20+
})();
21+
};
22+
23+
try {
24+
blob();
25+
} catch (err) {
26+
Sentry.captureException(err);
27+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../utils/fixtures';
4+
import { getSentryRequest } from '../../../utils/helpers';
5+
6+
sentryTest(
7+
'should parse function identifiers that are protocol names correctly',
8+
async ({ getLocalTestPath, page, browserName }) => {
9+
const url = await getLocalTestPath({ testDir: __dirname });
10+
11+
const eventData = await getSentryRequest(page, url);
12+
13+
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject(
14+
browserName === 'chromium'
15+
? [
16+
{ function: '?' },
17+
{ function: '?' },
18+
{ function: 'blob' },
19+
{ function: 'file' },
20+
{ function: 'https' },
21+
{ function: 'webpack' },
22+
{ function: 'Function.http' },
23+
]
24+
: browserName === 'firefox'
25+
? [
26+
{ function: '?' },
27+
{ function: '?' },
28+
{ function: 'blob' },
29+
{ function: 'file' },
30+
{ function: 'https' },
31+
{ function: 'webpack' },
32+
{ function: 'http' },
33+
]
34+
: [
35+
{ function: 'global code' },
36+
{ function: '?' },
37+
{ function: 'blob' },
38+
{ function: 'file' },
39+
{ function: 'https' },
40+
{ function: 'webpack' },
41+
{ function: 'http' },
42+
],
43+
);
44+
},
45+
);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function foo() {
2+
bar();
3+
}
4+
5+
const bar = () => {
6+
Test.baz();
7+
};
8+
9+
class Test {
10+
constructor() {}
11+
12+
static baz(params) {
13+
throw new Error('test_err');
14+
}
15+
}
16+
17+
const qux = function() {
18+
(() => {
19+
(function() {
20+
foo();
21+
})();
22+
})();
23+
};
24+
25+
try {
26+
qux();
27+
} catch (err) {
28+
Sentry.captureException(err);
29+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../utils/fixtures';
4+
import { getSentryRequest } from '../../../utils/helpers';
5+
6+
sentryTest('should parse function identifiers correctly', async ({ getLocalTestPath, page, browserName }) => {
7+
const url = await getLocalTestPath({ testDir: __dirname });
8+
9+
const eventData = await getSentryRequest(page, url);
10+
11+
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject(
12+
browserName === 'chromium'
13+
? [
14+
{ function: '?' },
15+
{ function: '?' },
16+
{ function: 'qux' },
17+
{ function: '?' },
18+
{ function: '?' },
19+
{ function: 'foo' },
20+
{ function: 'bar' },
21+
{ function: 'Function.baz' },
22+
]
23+
: browserName === 'firefox'
24+
? [
25+
{ function: '?' },
26+
{ function: '?' },
27+
{ function: 'qux' },
28+
{ function: 'qux/<' },
29+
{ function: 'qux/</<' },
30+
{ function: 'foo' },
31+
{ function: 'bar' },
32+
{ function: 'baz' },
33+
]
34+
: [
35+
{ function: 'global code' },
36+
{ function: '?' },
37+
{ function: 'qux' },
38+
{ function: '?' },
39+
{ function: '?' },
40+
{ function: 'foo' },
41+
{ function: 'bar' },
42+
{ function: 'baz' },
43+
],
44+
);
45+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title></title>
6+
<script src="{{htmlWebpackPlugin.options.initialization}}"></script>
7+
</head>
8+
<body>
9+
<script src="{{htmlWebpackPlugin.options.subject}}"></script>
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)