@@ -565,6 +565,80 @@ describe('Toucan', () => {
565565 } ) ;
566566 } ) ;
567567
568+ describe ( 'captureCheckIn' , ( ) => {
569+ test ( `is sent` , async ( ) => {
570+ const toucan = new Toucan ( {
571+ dsn : VALID_DSN ,
572+ context,
573+ } ) ;
574+
575+ const checkInId = toucan . captureCheckIn ( {
576+ monitorSlug : 'my_job' ,
577+ status : 'in_progress' ,
578+ } ) ;
579+
580+ toucan . captureCheckIn ( {
581+ checkInId : checkInId ,
582+ monitorSlug : 'my_job' ,
583+ status : 'error' ,
584+ } ) ;
585+
586+ const waitUntilResults = await getMiniflareWaitUntil ( context ) ;
587+
588+ expect ( waitUntilResults . length ) . toBe ( 2 ) ;
589+ expect ( requests . length ) . toBe ( 2 ) ;
590+
591+ const requestBody = await requests [ 0 ] . envelopePayload ( ) ;
592+
593+ expect ( requestBody ) . toEqual ( {
594+ check_in_id : checkInId ,
595+ monitor_slug : 'my_job' ,
596+ status : 'in_progress' ,
597+ } ) ;
598+
599+ const requestBody2 = await requests [ 1 ] . envelopePayload ( ) ;
600+
601+ expect ( requestBody2 ) . toEqual ( {
602+ check_in_id : checkInId ,
603+ monitor_slug : 'my_job' ,
604+ status : 'error' ,
605+ } ) ;
606+
607+ expect ( requestBody . check_in_id ) . toBe ( requestBody2 . check_in_id ) ;
608+ } ) ;
609+
610+ test ( `is linked to errors` , async ( ) => {
611+ const toucan = new Toucan ( {
612+ dsn : VALID_DSN ,
613+ context,
614+ } ) ;
615+
616+ const checkInId = toucan . captureCheckIn ( {
617+ monitorSlug : 'my_job' ,
618+ status : 'in_progress' ,
619+ } ) ;
620+
621+ toucan . captureMessage ( 'test' ) ;
622+
623+ const waitUntilResults = await getMiniflareWaitUntil ( context ) ;
624+
625+ expect ( waitUntilResults . length ) . toBe ( 2 ) ;
626+ expect ( requests . length ) . toBe ( 2 ) ;
627+
628+ const checkInRequestBody = await requests [ 0 ] . envelopePayload ( ) ;
629+
630+ expect ( checkInRequestBody ) . toEqual ( {
631+ check_in_id : checkInId ,
632+ monitor_slug : 'my_job' ,
633+ status : 'in_progress' ,
634+ } ) ;
635+
636+ const errorRequestBody = await requests [ 1 ] . envelopePayload ( ) ;
637+
638+ expect ( errorRequestBody . contexts . monitor ) . toEqual ( { slug : 'my_job' } ) ;
639+ } ) ;
640+ } ) ;
641+
568642 describe ( 'addBreadcrumb' , ( ) => {
569643 test ( 'captures last 100 breadcrumbs by default' , async ( ) => {
570644 const toucan = new Toucan ( {
0 commit comments