Skip to content

Commit 118b5c7

Browse files
authored
test(browser): Replace flakey integration test (#10075)
1 parent 644d697 commit 118b5c7

File tree

5 files changed

+56
-41
lines changed

5 files changed

+56
-41
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Sentry.captureMessage('a');
2+
3+
Sentry.captureException(new Error('test_simple_breadcrumb_error'));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { expect } from '@playwright/test';
2+
import type { Event } from '@sentry/types';
3+
4+
import { sentryTest } from '../../../../utils/fixtures';
5+
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';
6+
7+
sentryTest(
8+
'should capture recorded transactions as breadcrumbs for the following event sent',
9+
async ({ getLocalTestPath, page }) => {
10+
const url = await getLocalTestPath({ testDir: __dirname });
11+
12+
const events = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url });
13+
14+
const errorEvent = events.find(event => event.exception?.values?.[0].value === 'test_simple_breadcrumb_error')!;
15+
16+
expect(errorEvent.breadcrumbs).toHaveLength(1);
17+
expect(errorEvent.breadcrumbs?.[0]).toMatchObject({
18+
category: 'sentry.event',
19+
event_id: expect.any(String),
20+
level: expect.any(String),
21+
});
22+
},
23+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Sentry.captureEvent({
2+
event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2',
3+
message: 'someMessage',
4+
transaction: 'wat',
5+
type: 'transaction',
6+
});
7+
8+
Sentry.captureException(new Error('test_simple_breadcrumb_error'));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { expect } from '@playwright/test';
2+
import type { Event } from '@sentry/types';
3+
4+
import { sentryTest } from '../../../../utils/fixtures';
5+
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';
6+
7+
sentryTest(
8+
'should capture recorded transactions as breadcrumbs for the following event sent',
9+
async ({ getLocalTestPath, page }) => {
10+
const url = await getLocalTestPath({ testDir: __dirname });
11+
12+
const events = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url });
13+
14+
const errorEvent = events.find(event => event.exception?.values?.[0].value === 'test_simple_breadcrumb_error')!;
15+
16+
expect(errorEvent.breadcrumbs).toHaveLength(1);
17+
expect(errorEvent.breadcrumbs?.[0]).toMatchObject({
18+
category: 'sentry.transaction',
19+
message: expect.any(String),
20+
});
21+
},
22+
);

packages/browser/test/integration/suites/api.js

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,47 +20,6 @@ describe('API', function () {
2020
});
2121
});
2222

23-
it('should capture Sentry internal event as breadcrumbs for the following event sent', function () {
24-
return runInSandbox(sandbox, { manual: true }, function () {
25-
window.allowSentryBreadcrumbs = true;
26-
Sentry.captureMessage('a');
27-
Sentry.captureMessage('b');
28-
// For the loader
29-
Sentry.flush && Sentry.flush(2000);
30-
window.finalizeManualTest();
31-
}).then(function (summary) {
32-
assert.equal(summary.events.length, 2);
33-
assert.equal(summary.breadcrumbs.length, 2);
34-
assert.equal(summary.events[1].breadcrumbs[0].category, 'sentry.event');
35-
assert.equal(summary.events[1].breadcrumbs[0].event_id, summary.events[0].event_id);
36-
assert.equal(summary.events[1].breadcrumbs[0].level, summary.events[0].level);
37-
});
38-
});
39-
40-
it('should capture Sentry internal transaction as breadcrumbs for the following event sent', function () {
41-
return runInSandbox(sandbox, { manual: true }, function () {
42-
window.allowSentryBreadcrumbs = true;
43-
Sentry.captureEvent({
44-
event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2',
45-
message: 'someMessage',
46-
transaction: 'wat',
47-
type: 'transaction',
48-
});
49-
Sentry.captureMessage('c');
50-
// For the loader
51-
Sentry.flush && Sentry.flush(2000);
52-
window.finalizeManualTest();
53-
}).then(function (summary) {
54-
// We have a length of one here since transactions don't go through beforeSend
55-
// and we add events to summary in beforeSend
56-
assert.equal(summary.events.length, 1);
57-
assert.equal(summary.breadcrumbs.length, 2);
58-
assert.equal(summary.events[0].breadcrumbs[0].category, 'sentry.transaction');
59-
assert.isNotEmpty(summary.events[0].breadcrumbs[0].event_id);
60-
assert.isUndefined(summary.events[0].breadcrumbs[0].level);
61-
});
62-
});
63-
6423
it('should generate a synthetic trace for captureException w/ non-errors', function () {
6524
return runInSandbox(sandbox, function () {
6625
throwNonError();

0 commit comments

Comments
 (0)