@@ -10,7 +10,6 @@ import {
1010 instrumentServerEntry ,
1111 instrumentHandleRequest ,
1212 instrumentHandleError ,
13- instrumentUnstableInstrumentations ,
1413} from '../../../src/react-router/codemods/server-entry' ;
1514
1615// @ts -expect-error - magicast is ESM and TS complains about that. It works though
@@ -668,63 +667,3 @@ export const unstable_instrumentations = [Sentry.createSentryServerInstrumentati
668667 expect ( count ) . toBe ( 1 ) ;
669668 } ) ;
670669} ) ;
671-
672- describe ( 'instrumentUnstableInstrumentations' , ( ) => {
673- let tmpDir : string ;
674-
675- beforeEach ( ( ) => {
676- tmpDir = path . join (
677- __dirname ,
678- 'fixtures' ,
679- 'tmp' ,
680- `unstable-instrumentations-${ Date . now ( ) } -${ Math . random ( )
681- . toString ( 36 )
682- . substring ( 2 , 11 ) } `,
683- ) ;
684- fs . mkdirSync ( tmpDir , { recursive : true } ) ;
685- } ) ;
686-
687- afterEach ( ( ) => {
688- if ( fs . existsSync ( tmpDir ) ) {
689- fs . rmSync ( tmpDir , { recursive : true } ) ;
690- }
691- } ) ;
692-
693- it ( 'should add unstable_instrumentations export to the end of the file' , async ( ) => {
694- const content = `
695- import { ServerRouter } from 'react-router';
696- import * as Sentry from '@sentry/react-router';
697-
698- export default function handleRequest() {}
699- ` ;
700- const tempFile = path . join ( tmpDir , 'entry.server.tsx' ) ;
701- fs . writeFileSync ( tempFile , content ) ;
702-
703- const mod = await loadFile ( tempFile ) ;
704- instrumentUnstableInstrumentations ( mod ) ;
705-
706- const modifiedCode = generateCode ( mod . $ast ) . code ;
707-
708- expect ( modifiedCode ) . toContain (
709- 'export const unstable_instrumentations = [Sentry.createSentryServerInstrumentation()];' ,
710- ) ;
711- } ) ;
712-
713- it ( 'should not add unstable_instrumentations if already present' , async ( ) => {
714- const content = `
715- import * as Sentry from '@sentry/react-router';
716-
717- export default function handleRequest() {}
718- export const unstable_instrumentations = [Sentry.createSentryServerInstrumentation()];
719- ` ;
720- const tempFile = path . join ( tmpDir , 'entry.server.tsx' ) ;
721- fs . writeFileSync ( tempFile , content ) ;
722-
723- const mod = await loadFile ( tempFile ) ;
724- const originalBodyLength = ( mod . $ast as any ) . body . length ;
725-
726- instrumentUnstableInstrumentations ( mod ) ;
727-
728- expect ( ( mod . $ast as any ) . body . length ) . toBe ( originalBodyLength ) ;
729- } ) ;
730- } ) ;
0 commit comments