-
-
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.
create test that actually failed previously
- Loading branch information
Showing
4 changed files
with
72 additions
and
12 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
.../browser-integration-tests/suites/public-api/startSpan/error-async-throw-ii/template.html
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,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title></title> | ||
</head> | ||
<body> | ||
<button id="button1" type="button">Button 1</button> | ||
|
||
<script type="module"> | ||
async function run() { | ||
Sentry.startSpan({ name: 'parent_span', op: 'test' }, async () => { | ||
console.log('throwing error') | ||
throw new Error('Async Thrown Error'); | ||
}); | ||
} | ||
|
||
const button = document.getElementById('button1'); | ||
button.addEventListener('click', () => { | ||
void run(); | ||
console.log('click'); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
27 changes: 27 additions & 0 deletions
27
packages/browser-integration-tests/suites/public-api/startSpan/error-async-throw-ii/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,27 @@ | ||
import { expect } from '@playwright/test'; | ||
import type { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers'; | ||
|
||
sentryTest( | ||
"should capture a thrown error within an async startSpan callback that's not awaited properly", | ||
async ({ getLocalTestPath, page }) => { | ||
if (shouldSkipTracingTest()) { | ||
sentryTest.skip(); | ||
} | ||
const envelopePromise = getMultipleSentryEnvelopeRequests<Event>(page, 2); | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
await page.goto(url); | ||
|
||
const clickPromise = page.getByText('Button 1').click(); | ||
|
||
// awaiting both events simultaneously to avoid race conditions | ||
const [, events] = await Promise.all([clickPromise, envelopePromise]); | ||
const [txn, err] = events[0]?.type === 'transaction' ? [events[0], events[1]] : [events[1], events[0]]; | ||
|
||
expect(txn).toMatchObject({ transaction: 'parent_span' }); | ||
expect(err?.exception?.values?.[0]?.value).toBe('Async Thrown Error'); | ||
}, | ||
); |
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
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