Skip to content

Commit 3a3bf53

Browse files
committed
fix integration tests
1 parent 8e9ff8f commit 3a3bf53

File tree

7 files changed

+43
-38
lines changed

7 files changed

+43
-38
lines changed

packages/browser-integration-tests/suites/public-api/startSpan/error-async-reject/subject.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/browser-integration-tests/suites/public-api/startSpan/error-async-reject/template.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,18 @@
66
</head>
77
<body>
88
<button id="button1" type="button">Button 1</button>
9+
10+
<script>
11+
async function run() {
12+
await Sentry.startSpan({ name: 'parent_span', op: 'test' }, async () => {
13+
Promise.reject('Async Promise Rejection');
14+
});
15+
}
16+
17+
const button = document.getElementById('button1');
18+
button.addEventListener('click', async () => {
19+
await run();
20+
});
21+
</script>
922
</body>
1023
</html>

packages/browser-integration-tests/suites/public-api/startSpan/error-async-reject/test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ sentryTest(
1414
const url = await getLocalTestPath({ testDir: __dirname });
1515
const envelopePromise = getMultipleSentryEnvelopeRequests<Event>(page, 2);
1616

17-
const gotoPromise = page.goto(url);
18-
const clickPromise = page.getByText('Button 1').click();
17+
await page.goto(url);
1918

20-
const [_, events] = await Promise.all([gotoPromise, envelopePromise, clickPromise]);
19+
const clickPromise = page.getByText('Button 1').click();
2120

21+
const [, events] = await Promise.all([clickPromise, envelopePromise]);
2222
const [txn, err] = events[0]?.type === 'transaction' ? [events[0], events[1]] : [events[1], events[0]];
2323

2424
expect(txn).toMatchObject({ transaction: 'parent_span' });
2525

26-
expect(err?.exception?.values?.[0]?.value).toBe('[object Promise]');
26+
expect(err?.exception?.values?.[0]?.value).toBe(
27+
'Non-Error promise rejection captured with value: Async Promise Rejection',
28+
);
2729
},
2830
);

packages/browser-integration-tests/suites/public-api/startSpan/error-async-throw/subject.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/browser-integration-tests/suites/public-api/startSpan/error-async-throw/template.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,18 @@
66
</head>
77
<body>
88
<button id="button1" type="button">Button 1</button>
9+
10+
<script>
11+
async function run() {
12+
await Sentry.startSpan({ name: 'parent_span', op: 'test' }, async () => {
13+
throw new Error('Async Thrown Error');
14+
});
15+
}
16+
17+
const button = document.getElementById('button1');
18+
button.addEventListener('click', async () => {
19+
await run();
20+
});
21+
</script>
922
</body>
1023
</html>

packages/browser-integration-tests/suites/public-api/startSpan/error-async-throw/test.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,17 @@ sentryTest('should capture a thrown error within an async startSpan callback', a
88
if (shouldSkipTracingTest()) {
99
sentryTest.skip();
1010
}
11-
12-
page.on('pageerror', err => console.log('pageerror', err));
13-
page.on('console', msg => console.log('console', msg.text()));
11+
const envelopePromise = getMultipleSentryEnvelopeRequests<Event>(page, 2);
1412

1513
const url = await getLocalTestPath({ testDir: __dirname });
16-
const envelopePromise = getMultipleSentryEnvelopeRequests<Event>(page, 2);
14+
await page.goto(url);
1715

18-
const gotoPromise = page.goto(url);
1916
const clickPromise = page.getByText('Button 1').click();
2017

21-
console.log('before wait');
22-
23-
const [_, events] = await Promise.all([gotoPromise, envelopePromise, clickPromise]);
24-
25-
console.log('after wait');
26-
18+
// awaiting both events simultaneously to avoid race conditions
19+
const [, events] = await Promise.all([clickPromise, envelopePromise]);
2720
const [txn, err] = events[0]?.type === 'transaction' ? [events[0], events[1]] : [events[1], events[0]];
2821

2922
expect(txn).toMatchObject({ transaction: 'parent_span' });
30-
31-
expect(err?.exception?.values?.[0]?.value).toBe('[object Promise]');
23+
expect(err?.exception?.values?.[0]?.value).toBe('Async Thrown Error');
3224
});

packages/browser-integration-tests/suites/public-api/startSpan/init.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ import * as _ from '@sentry/tracing';
55
window.Sentry = Sentry;
66

77
Sentry.init({
8-
dsn: 'https://[email protected]/1337',
8+
// dsn: 'https://[email protected]/1337',
9+
dsn: 'https://[email protected]/4503942526795776',
910
tracesSampleRate: 1.0,
1011
normalizeDepth: 10,
1112
debug: true,
13+
beforeSend(event) {
14+
console.log('beforeSend', event);
15+
return event;
16+
},
1217
});

0 commit comments

Comments
 (0)