Skip to content

Commit 42650ee

Browse files
mydeaclaude
andcommitted
test(cloudflare): Cover the module-injected listener with multiple factories
The prior test only exercised the init-time path with a Set of factories. Add a test that emits `orchestrion.module-injected` for a module holding a Set, so the late-registration listener's Set-unwrapping is covered with more than one factory too. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 059e699 commit 42650ee

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎packages/cloudflare/test/sdk.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,25 @@ describe('getDefaultIntegrations', () => {
358358
expect(client?.getIntegrationByName('Mysql')).toBeDefined();
359359
});
360360

361+
test('installs all integrations for a module registered after init via the module-injected event', async () => {
362+
const { mysqlIntegration, lruMemoizerIntegration } = await import('@sentry/server-utils');
363+
// `cacheClient: false` so this gets its own client rather than one a previous `init()` cached.
364+
const client = init({ cacheClient: false });
365+
expect(client?.getIntegrationByName('Mysql')).toBeUndefined();
366+
expect(client?.getIntegrationByName('LruMemoizer')).toBeUndefined();
367+
368+
// A module registering more than one integration (like `h3` → span + Server-Timing) evaluates
369+
// after init: store the Set of factories on the marker, then emit the event.
370+
globalThis.__SENTRY_ORCHESTRION__ = {
371+
bundler: new Set(['some-module']),
372+
integrations: new Map([['some-module', new Set([mysqlIntegration, lruMemoizerIntegration])]]),
373+
};
374+
client?.emit('orchestrion.module-injected', 'some-module');
375+
376+
expect(client?.getIntegrationByName('Mysql')).toBeDefined();
377+
expect(client?.getIntegrationByName('LruMemoizer')).toBeDefined();
378+
});
379+
361380
test('installs all integrations a single module registers', async () => {
362381
const { mysqlIntegration, lruMemoizerIntegration } = await import('@sentry/server-utils');
363382
// One module registering more than one integration (like `h3` → span + Server-Timing).

0 commit comments

Comments
 (0)