File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 11/* eslint-disable @typescript-eslint/unbound-method */
22import { createTransport , Scope } from '@sentry/core' ;
3- import { MockIntegration } from '@sentry/core/test/lib/sdk.test' ;
43import type { Client , Integration } from '@sentry/types' ;
54import { resolvedSyncPromise } from '@sentry/utils' ;
65
@@ -18,6 +17,14 @@ function getDefaultBrowserOptions(options: Partial<BrowserOptions> = {}): Browse
1817 } ;
1918}
2019
20+ export class MockIntegration implements Integration {
21+ public name : string ;
22+ public setupOnce : ( ) => void = jest . fn ( ) ;
23+ public constructor ( name : string ) {
24+ this . name = name ;
25+ }
26+ }
27+
2128jest . mock ( '@sentry/core' , ( ) => {
2229 const original = jest . requireActual ( '@sentry/core' ) ;
2330 return {
Original file line number Diff line number Diff line change @@ -196,17 +196,14 @@ export function startTransaction(
196196 * to create a monitor automatically when sending a check in.
197197 */
198198export function captureCheckIn ( checkIn : CheckIn , upsertMonitorConfig ?: MonitorConfig ) : string {
199- const capturedCheckIn =
200- checkIn . status !== 'in_progress' && checkIn . checkInId ? checkIn : { ...checkIn , checkInId : uuid4 ( ) } ;
201-
202199 const client = getCurrentHub ( ) . getClient ( ) ;
203200 if ( ! client ) {
204201 __DEBUG_BUILD__ && logger . warn ( 'Cannot capture check-in. No client defined.' ) ;
205202 } else if ( ! client . captureCheckIn ) {
206203 __DEBUG_BUILD__ && logger . warn ( 'Cannot capture check-in. Client does not support sending check-ins.' ) ;
207204 } else {
208- client . captureCheckIn ( capturedCheckIn , upsertMonitorConfig ) ;
205+ return client . captureCheckIn ( checkIn , upsertMonitorConfig ) ;
209206 }
210207
211- return capturedCheckIn . checkInId ;
208+ return uuid4 ( ) ;
212209}
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ describe('captureCheckIn', () => {
4747 } as unknown as Client ;
4848 } ) ;
4949
50- expect ( captureCheckIn ( { monitorSlug : 'gogogo' , status : 'in_progress' } ) ) . toStrictEqual ( expect . any ( String ) ) ;
50+ expect ( captureCheckIn ( { monitorSlug : 'gogogo' , status : 'in_progress' } ) ) . toStrictEqual ( 'some-id-wasd-1234' ) ;
5151 } ) ;
5252
5353 it ( 'returns an id when client is undefined' , ( ) => {
You can’t perform that action at this time.
0 commit comments