Skip to content

Commit 8970f42

Browse files
committed
add integration test
1 parent e31ccc6 commit 8970f42

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
window.fetchCallCount = 0;
6+
window.spanEnded = false;
7+
8+
const originalWindowFetch = window.fetch;
9+
window.fetch = (...args) => {
10+
window.fetchCallCount++;
11+
return originalWindowFetch(...args);
12+
};
13+
14+
Sentry.init({
15+
dsn: 'https://[email protected]/1337',
16+
tracesSampleRate: 1.0,
17+
enabled: false,
18+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Sentry.startSpan({ name: 'standalone_segment_span', experimental: { standalone: true } }, () => {});
2+
3+
window.spanEnded = true;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { shouldSkipTracingTest } from '../../../../utils/helpers';
5+
6+
sentryTest("doesn't send a standalone span envelope if SDK is disabled", async ({ getLocalTestPath, page }) => {
7+
if (shouldSkipTracingTest()) {
8+
sentryTest.skip();
9+
}
10+
11+
const url = await getLocalTestPath({ testDir: __dirname });
12+
await page.goto(url);
13+
14+
// @ts-expect-error this exists in the test init/subject
15+
await page.waitForFunction(() => !!window.spanEnded);
16+
await page.waitForTimeout(2000);
17+
18+
// @ts-expect-error this exists in the test init
19+
const fetchCallCount = await page.evaluate(() => window.fetchCallCount);
20+
// We expect no fetch calls because the SDK is disabled
21+
expect(fetchCallCount).toBe(0);
22+
});

0 commit comments

Comments
 (0)