Skip to content

Commit eb3a90c

Browse files
cursoragentclaude
andcommitted
test: add tests for lazyLoadIntegration bundle name derivation logic
Add tests to verify the bundle name derivation logic works correctly for: - Standard integrations with Integration suffix (replay, feedback, etc.) - Hyphenated bundle names (replay-canvas, feedback-modal, etc.) - AI integrations without Integration suffix (instrumentAnthropicAiClient, etc.) These tests ensure the new derivation pattern produces correct CDN bundle URLs. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9065e37 commit eb3a90c

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

packages/browser/test/utils/lazyLoadIntegration.test.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,81 @@ describe('lazyLoadIntegration', () => {
8181
`https://browser.sentry-cdn.com/${SDK_VERSION}/httpclient.min.js`,
8282
);
8383
});
84+
85+
describe('bundle name derivation', () => {
86+
test.each([
87+
['replayIntegration', 'replay'],
88+
['feedbackIntegration', 'feedback'],
89+
['captureConsoleIntegration', 'captureconsole'],
90+
['contextLinesIntegration', 'contextlines'],
91+
['linkedErrorsIntegration', 'linkederrors'],
92+
['dedupeIntegration', 'dedupe'],
93+
['extraErrorDataIntegration', 'extraerrordata'],
94+
['graphqlClientIntegration', 'graphqlclient'],
95+
['httpClientIntegration', 'httpclient'],
96+
['reportingObserverIntegration', 'reportingobserver'],
97+
['rewriteFramesIntegration', 'rewriteframes'],
98+
['browserProfilingIntegration', 'browserprofiling'],
99+
['moduleMetadataIntegration', 'modulemetadata'],
100+
])('derives correct bundle name for %s', async (integrationName, expectedBundle) => {
101+
// @ts-expect-error For testing sake
102+
global.Sentry = {};
103+
104+
try {
105+
// @ts-expect-error Dynamic integration name for testing
106+
await lazyLoadIntegration(integrationName);
107+
} catch {
108+
// skip - we just want to verify the script URL
109+
}
110+
111+
expect(global.document.querySelector('script')?.src).toEqual(
112+
`https://browser.sentry-cdn.com/${SDK_VERSION}/${expectedBundle}.min.js`,
113+
);
114+
});
115+
116+
test.each([
117+
['replayCanvasIntegration', 'replay-canvas'],
118+
['feedbackModalIntegration', 'feedback-modal'],
119+
['feedbackScreenshotIntegration', 'feedback-screenshot'],
120+
])('derives correct hyphenated bundle name for %s', async (integrationName, expectedBundle) => {
121+
// @ts-expect-error For testing sake
122+
global.Sentry = {};
123+
124+
try {
125+
// @ts-expect-error Dynamic integration name for testing
126+
await lazyLoadIntegration(integrationName);
127+
} catch {
128+
// skip - we just want to verify the script URL
129+
}
130+
131+
expect(global.document.querySelector('script')?.src).toEqual(
132+
`https://browser.sentry-cdn.com/${SDK_VERSION}/${expectedBundle}.min.js`,
133+
);
134+
});
135+
136+
test.each([
137+
['instrumentAnthropicAiClient', 'instrumentanthropicaiclient'],
138+
['instrumentOpenAiClient', 'instrumentopenaiclient'],
139+
['instrumentGoogleGenAIClient', 'instrumentgooglegenaiclient'],
140+
['instrumentLangGraph', 'instrumentlanggraph'],
141+
['createLangChainCallbackHandler', 'createlangchaincallbackhandler'],
142+
])(
143+
'derives correct bundle name for AI integrations without Integration suffix: %s',
144+
async (integrationName, expectedBundle) => {
145+
// @ts-expect-error For testing sake
146+
global.Sentry = {};
147+
148+
try {
149+
// @ts-expect-error Dynamic integration name for testing
150+
await lazyLoadIntegration(integrationName);
151+
} catch {
152+
// skip - we just want to verify the script URL
153+
}
154+
155+
expect(global.document.querySelector('script')?.src).toEqual(
156+
`https://browser.sentry-cdn.com/${SDK_VERSION}/${expectedBundle}.min.js`,
157+
);
158+
},
159+
);
160+
});
84161
});

0 commit comments

Comments
 (0)