11import type { Envelope , Transport , TransportMakeRequestResponse } from '@sentry/types' ;
22
3- import type { Replay as ReplayIntegration } from '../../src' ;
43import type { ReplayContainer } from '../../src/replay' ;
54import type { ReplayConfiguration } from '../../src/types' ;
65import type { TestClientOptions } from '../utils/TestClient' ;
@@ -46,32 +45,30 @@ class MockTransport implements Transport {
4645
4746export async function mockSdk ( { replayOptions, sentryOptions, autoStart = true } : MockSdkParams = { } ) : Promise < {
4847 replay : ReplayContainer ;
49- // eslint-disable-next-line deprecation/deprecation
50- integration : ReplayIntegration ;
48+ integration : typeof replayIntegration ;
5149} > {
52- // eslint-disable-next-line deprecation/deprecation
53- const { Replay } = await import ( '../../src' ) ;
50+ const { replayIntegration } = await import ( '../../src' ) ;
5451
5552 // Scope this to the test, instead of the module
5653 let _initialized = false ;
57- class TestReplayIntegration extends Replay {
58- protected get _isInitialized ( ) : boolean {
59- return _initialized ;
60- }
61- protected set _isInitialized ( value : boolean ) {
62- _initialized = value ;
63- }
6454
65- public setupOnce ( ) : void {
66- // do nothing
67- }
68-
69- public initialize ( ) : void {
70- return super . _initialize ( ) ;
71- }
55+ const testReplayIntegration = ( ...args : Parameters < typeof replayIntegration > ) => {
56+ const replayIntegrationInstance = replayIntegration ( ...args ) ;
57+ return {
58+ ...replayIntegrationInstance ,
59+ get _isInitialized ( ) {
60+ return _initialized ;
61+ } ,
62+ set _isInitialized ( value : boolean ) {
63+ _initialized = value ;
64+ } ,
65+ initialize ( ) {
66+ replayIntegrationInstance [ '_initialize' ] ( ) ;
67+ } ,
68+ } ;
7269 }
7370
74- const replayIntegration = new TestReplayIntegration ( {
71+ const replayIntegrationInstance = testReplayIntegration ( {
7572 stickySession : false ,
7673 minReplayDuration : 0 ,
7774 ...replayOptions ,
@@ -86,18 +83,18 @@ export async function mockSdk({ replayOptions, sentryOptions, autoStart = true }
8683 replaysSessionSampleRate : 1.0 ,
8784 replaysOnErrorSampleRate : 0.0 ,
8885 ...sentryOptions ,
89- integrations : [ replayIntegration ] ,
86+ integrations : [ replayIntegrationInstance ] ,
9087 } ) ;
9188
9289 // Instead of `setupOnce`, which is tricky to test, we call this manually here
93- replayIntegration [ '_setup' ] ( ) ;
90+ replayIntegrationInstance [ '_setup' ] ( ) ;
9491
9592 if ( autoStart ) {
9693 // Only exists in our mock
97- replayIntegration . initialize ( ) ;
94+ replayIntegrationInstance . initialize ( ) ;
9895 }
9996
100- const replay = replayIntegration [ '_replay' ] ! ;
97+ const replay = replayIntegrationInstance [ '_replay' ] ! ;
10198
10299 return { replay, integration : replayIntegration } ;
103100}
0 commit comments