-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for function identifiers.
- Loading branch information
1 parent
e232a4e
commit 2490499
Showing
8 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function httpsCall() { | ||
webpackDevServer(); | ||
} | ||
|
||
const webpackDevServer = () => { | ||
Response.httpCode(); | ||
}; | ||
|
||
class Response { | ||
constructor() {} | ||
|
||
static httpCode(params) { | ||
throw new Error('test_err'); | ||
} | ||
} | ||
|
||
const decodeBlob = function() { | ||
(function readFile() { | ||
httpsCall(); | ||
})(); | ||
}; | ||
|
||
try { | ||
decodeBlob(); | ||
} catch (err) { | ||
Sentry.captureException(err); | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getSentryRequest } from '../../../utils/helpers'; | ||
|
||
sentryTest( | ||
'should parse function identifiers that contain protocol names correctly', | ||
async ({ getLocalTestPath, page, browserName }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getSentryRequest(page, url); | ||
|
||
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( | ||
browserName === 'chromium' | ||
? [ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'decodeBlob' }, | ||
{ function: 'readFile' }, | ||
{ function: 'httpsCall' }, | ||
{ function: 'webpackDevServer' }, | ||
{ function: 'Function.httpCode' }, | ||
] | ||
: browserName === 'firefox' | ||
? [ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'decodeBlob' }, | ||
{ function: 'readFile' }, | ||
{ function: 'httpsCall' }, | ||
{ function: 'webpackDevServer' }, | ||
{ function: 'httpCode' }, | ||
] | ||
: [ | ||
{ function: 'global code' }, | ||
{ function: '?' }, | ||
{ function: 'decodeBlob' }, | ||
{ function: 'readFile' }, | ||
{ function: 'httpsCall' }, | ||
{ function: 'webpackDevServer' }, | ||
{ function: 'httpCode' }, | ||
], | ||
); | ||
}, | ||
); | ||
|
||
sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getSentryRequest(page, url); | ||
|
||
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( | ||
Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), | ||
); | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function https() { | ||
webpack(); | ||
} | ||
|
||
const webpack = () => { | ||
File.http(); | ||
}; | ||
|
||
class File { | ||
constructor() {} | ||
|
||
static http(params) { | ||
throw new Error('test_err'); | ||
} | ||
} | ||
|
||
const blob = function() { | ||
(function file() { | ||
https(); | ||
})(); | ||
}; | ||
|
||
try { | ||
blob(); | ||
} catch (err) { | ||
Sentry.captureException(err); | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getSentryRequest } from '../../../utils/helpers'; | ||
|
||
sentryTest( | ||
'should parse function identifiers that are protocol names correctly', | ||
async ({ getLocalTestPath, page, browserName }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getSentryRequest(page, url); | ||
|
||
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( | ||
browserName === 'chromium' | ||
? [ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'blob' }, | ||
{ function: 'file' }, | ||
{ function: 'https' }, | ||
{ function: 'webpack' }, | ||
{ function: 'Function.http' }, | ||
] | ||
: browserName === 'firefox' | ||
? [ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'blob' }, | ||
{ function: 'file' }, | ||
{ function: 'https' }, | ||
{ function: 'webpack' }, | ||
{ function: 'http' }, | ||
] | ||
: [ | ||
{ function: 'global code' }, | ||
{ function: '?' }, | ||
{ function: 'blob' }, | ||
{ function: 'file' }, | ||
{ function: 'https' }, | ||
{ function: 'webpack' }, | ||
{ function: 'http' }, | ||
], | ||
); | ||
}, | ||
); | ||
|
||
sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getSentryRequest(page, url); | ||
|
||
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( | ||
Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
packages/integration-tests/suites/stacktraces/regular_fn_identifiers/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function foo() { | ||
bar(); | ||
} | ||
|
||
const bar = () => { | ||
Test.baz(); | ||
}; | ||
|
||
class Test { | ||
constructor() {} | ||
|
||
static baz(params) { | ||
throw new Error('test_err'); | ||
} | ||
} | ||
|
||
const qux = function() { | ||
(() => { | ||
(function() { | ||
foo(); | ||
})(); | ||
})(); | ||
}; | ||
|
||
try { | ||
qux(); | ||
} catch (err) { | ||
Sentry.captureException(err); | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getSentryRequest } from '../../../utils/helpers'; | ||
|
||
sentryTest('should parse function identifiers correctly', async ({ getLocalTestPath, page, browserName }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getSentryRequest(page, url); | ||
|
||
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( | ||
browserName === 'chromium' | ||
? [ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'qux' }, | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'foo' }, | ||
{ function: 'bar' }, | ||
{ function: 'Function.baz' }, | ||
] | ||
: browserName === 'firefox' | ||
? [ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'qux' }, | ||
{ function: 'qux/<' }, | ||
{ function: 'qux/</<' }, | ||
{ function: 'foo' }, | ||
{ function: 'bar' }, | ||
{ function: 'baz' }, | ||
] | ||
: [ | ||
{ function: 'global code' }, | ||
{ function: '?' }, | ||
{ function: 'qux' }, | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'foo' }, | ||
{ function: 'bar' }, | ||
{ function: 'baz' }, | ||
], | ||
); | ||
}); | ||
|
||
sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getSentryRequest(page, url); | ||
|
||
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( | ||
Array(8).fill({ filename: expect.stringMatching(/^file:\/?/) }), | ||
); | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/integration-tests/suites/stacktraces/template.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title></title> | ||
<script src="{{htmlWebpackPlugin.options.initialization}}"></script> | ||
</head> | ||
<body> | ||
<script src="{{htmlWebpackPlugin.options.subject}}"></script> | ||
</body> | ||
</html> |