|
1 | 1 | import type { Span } from '@sentry/types';
|
2 |
| -import { addBreadcrumb, getCurrentScope, setCurrentClient, startSpan, withIsolationScope, withScope } from '../../src'; |
| 2 | +import { |
| 3 | + Scope, |
| 4 | + addBreadcrumb, |
| 5 | + getCurrentScope, |
| 6 | + setCurrentClient, |
| 7 | + startSpan, |
| 8 | + withIsolationScope, |
| 9 | + withScope, |
| 10 | +} from '../../src'; |
3 | 11 | import { captureFeedback } from '../../src/feedback';
|
4 | 12 | import { TestClient, getDefaultTestClientOptions } from '../mocks/client';
|
5 | 13 |
|
@@ -448,4 +456,45 @@ describe('captureFeedback', () => {
|
448 | 456 | ],
|
449 | 457 | ]);
|
450 | 458 | });
|
| 459 | + |
| 460 | + test('it allows to pass a custom client', async () => { |
| 461 | + const client = new TestClient( |
| 462 | + getDefaultTestClientOptions({ |
| 463 | + dsn: 'https://dsn@ingest.f00.f00/1', |
| 464 | + enableSend: true, |
| 465 | + }), |
| 466 | + ); |
| 467 | + setCurrentClient(client); |
| 468 | + client.init(); |
| 469 | + |
| 470 | + const client2 = new TestClient( |
| 471 | + getDefaultTestClientOptions({ |
| 472 | + dsn: 'https://dsn@ingest.f00.f00/1', |
| 473 | + enableSend: true, |
| 474 | + defaultIntegrations: false, |
| 475 | + }), |
| 476 | + ); |
| 477 | + client2.init(); |
| 478 | + const scope = new Scope(); |
| 479 | + scope.setClient(client2); |
| 480 | + |
| 481 | + const mockTransport = jest.spyOn(client.getTransport()!, 'send'); |
| 482 | + const mockTransport2 = jest.spyOn(client2.getTransport()!, 'send'); |
| 483 | + |
| 484 | + const eventId = captureFeedback( |
| 485 | + { |
| 486 | + message: 'test', |
| 487 | + }, |
| 488 | + {}, |
| 489 | + scope, |
| 490 | + ); |
| 491 | + |
| 492 | + await client.flush(); |
| 493 | + await client2.flush(); |
| 494 | + |
| 495 | + expect(typeof eventId).toBe('string'); |
| 496 | + |
| 497 | + expect(mockTransport).not.toHaveBeenCalled(); |
| 498 | + expect(mockTransport2).toHaveBeenCalledTimes(1); |
| 499 | + }); |
451 | 500 | });
|
0 commit comments