@@ -707,18 +707,20 @@ describe('BaseClient', () => {
707
707
} ) ;
708
708
709
709
test ( 'calls beforeSend and log info about invalid return value' , ( ) => {
710
- expect . assertions ( 3 ) ;
711
- const beforeSend = jest . fn ( ( ) => undefined ) ;
712
- // @ts -ignore we need to test regular-js behavior
713
- const client = new TestClient ( { dsn : PUBLIC_DSN , beforeSend } ) ;
714
- const captureExceptionSpy = jest . spyOn ( client , 'captureException' ) ;
715
- const loggerErrorSpy = jest . spyOn ( logger , 'error' ) ;
716
- client . captureEvent ( { message : 'hello' } ) ;
717
- expect ( TestBackend . instance ! . event ) . toBeUndefined ( ) ;
718
- expect ( captureExceptionSpy ) . not . toBeCalled ( ) ;
719
- expect ( loggerErrorSpy ) . toBeCalledWith (
720
- new SentryError ( '`beforeSend` method has to return `null` or a valid event.' ) ,
721
- ) ;
710
+ const invalidValues = [ undefined , false , true , [ ] , 1 ] ;
711
+ expect . assertions ( invalidValues . length * 2 ) ;
712
+
713
+ for ( const val of invalidValues ) {
714
+ const beforeSend = jest . fn ( ( ) => val ) ;
715
+ // @ts -ignore we need to test regular-js behavior
716
+ const client = new TestClient ( { dsn : PUBLIC_DSN , beforeSend } ) ;
717
+ const loggerErrorSpy = jest . spyOn ( logger , 'error' ) ;
718
+ client . captureEvent ( { message : 'hello' } ) ;
719
+ expect ( TestBackend . instance ! . event ) . toBeUndefined ( ) ;
720
+ expect ( loggerErrorSpy ) . toBeCalledWith (
721
+ new SentryError ( '`beforeSend` method has to return `null` or a valid event.' ) ,
722
+ ) ;
723
+ }
722
724
} ) ;
723
725
724
726
test ( 'calls async beforeSend and uses original event without any changes' , done => {
0 commit comments