@@ -50,10 +50,48 @@ describe('Sentry Metro Serializer', () => {
5050 expect ( bundle . code ) . toEqual ( fs . readFileSync ( `${ __dirname } /fixtures/bundleWithPrelude.js.fixture` , 'utf8' ) ) ;
5151 expect ( bundle . map ) . toEqual ( fs . readFileSync ( `${ __dirname } /fixtures/bundleWithPrelude.js.fixture.map` , 'utf8' ) ) ;
5252 } ) ;
53+
54+ test ( 'works when shouldAddToIgnoreList is undefined' , async ( ) => {
55+ const serializer = createSentryMetroSerializer ( ) ;
56+ const args = mockMinSerializerArgs ( { shouldAddToIgnoreList : undefined } ) ;
57+
58+ const bundle = await serializer ( ...args ) ;
59+
60+ expect ( bundle ) . toBeDefined ( ) ;
61+ if ( typeof bundle !== 'string' ) {
62+ expect ( bundle . code ) . toBeDefined ( ) ;
63+ expect ( bundle . map ) . toBeDefined ( ) ;
64+ const debugId = determineDebugIdFromBundleSource ( bundle . code ) ;
65+ expect ( debugId ) . toMatch ( / ^ [ 0 - 9 a - f A - F ] { 8 } - [ 0 - 9 a - f A - F ] { 4 } - [ 0 - 9 a - f A - F ] { 4 } - [ 0 - 9 a - f A - F ] { 4 } - [ 0 - 9 a - f A - F ] { 12 } $ / ) ;
66+ }
67+ } ) ;
5368} ) ;
5469
55- function mockMinSerializerArgs ( ) : Parameters < MetroSerializer > {
70+ function mockMinSerializerArgs ( options ?: {
71+ shouldAddToIgnoreList ?: ( ( module : Module < MixedOutput > ) => boolean ) | undefined ;
72+ } ) : Parameters < MetroSerializer > {
5673 let modulesCounter = 0 ;
74+
75+ const baseOptions : Record < string , any > = {
76+ asyncRequireModulePath : 'asyncRequire' ,
77+ createModuleId : ( _filePath : string ) : number => modulesCounter ++ ,
78+ dev : false ,
79+ getRunModuleStatement : ( _moduleId : string | number ) : string => '' ,
80+ includeAsyncPaths : false ,
81+ modulesOnly : false ,
82+ processModuleFilter : ( _module : Module < MixedOutput > ) => true ,
83+ projectRoot : '/project/root' ,
84+ runBeforeMainModule : [ ] ,
85+ runModule : false ,
86+ serverRoot : '/server/root' ,
87+ } ;
88+
89+ if ( options && 'shouldAddToIgnoreList' in options ) {
90+ baseOptions . shouldAddToIgnoreList = options . shouldAddToIgnoreList ;
91+ } else {
92+ baseOptions . shouldAddToIgnoreList = ( _module : Module < MixedOutput > ) => false ;
93+ }
94+
5795 return [
5896 'index.js' ,
5997 [ ] ,
@@ -68,20 +106,7 @@ function mockMinSerializerArgs(): Parameters<MetroSerializer> {
68106 unstable_transformProfile : 'hermes-stable' ,
69107 } ,
70108 } ,
71- {
72- asyncRequireModulePath : 'asyncRequire' ,
73- createModuleId : ( _filePath : string ) : number => modulesCounter ++ ,
74- dev : false ,
75- getRunModuleStatement : ( _moduleId : string | number ) : string => '' ,
76- includeAsyncPaths : false ,
77- modulesOnly : false ,
78- processModuleFilter : ( _module : Module < MixedOutput > ) => true ,
79- projectRoot : '/project/root' ,
80- runBeforeMainModule : [ ] ,
81- runModule : false ,
82- serverRoot : '/server/root' ,
83- shouldAddToIgnoreList : ( _module : Module < MixedOutput > ) => false ,
84- } ,
109+ baseOptions as any ,
85110 ] ;
86111}
87112
0 commit comments