@@ -84,23 +84,23 @@ describe('BaseClient', () => {
8484 const client = new TestClient ( { } ) ;
8585 const scope = new Scope ( ) ;
8686 scope . addBreadcrumb ( { message : 'hello' } , 100 ) ;
87- await client . addBreadcrumb ( { message : 'world' } , scope ) ;
87+ await client . addBreadcrumb ( { message : 'world' } , undefined , scope ) ;
8888 expect ( scope . getBreadcrumbs ( ) [ 1 ] . message ) . toBe ( 'world' ) ;
8989 } ) ;
9090
9191 test ( 'adds a timestamp to new breadcrumbs' , async ( ) => {
9292 const client = new TestClient ( { } ) ;
9393 const scope = new Scope ( ) ;
9494 scope . addBreadcrumb ( { message : 'hello' } , 100 ) ;
95- await client . addBreadcrumb ( { message : 'world' } , scope ) ;
95+ await client . addBreadcrumb ( { message : 'world' } , undefined , scope ) ;
9696 expect ( scope . getBreadcrumbs ( ) [ 1 ] . timestamp ) . toBeGreaterThan ( 1 ) ;
9797 } ) ;
9898
9999 test ( 'discards breadcrumbs beyond maxBreadcrumbs' , async ( ) => {
100100 const client = new TestClient ( { maxBreadcrumbs : 1 } ) ;
101101 const scope = new Scope ( ) ;
102102 scope . addBreadcrumb ( { message : 'hello' } , 100 ) ;
103- await client . addBreadcrumb ( { message : 'world' } , scope ) ;
103+ await client . addBreadcrumb ( { message : 'world' } , undefined , scope ) ;
104104 expect ( scope . getBreadcrumbs ( ) . length ) . toBe ( 1 ) ;
105105 expect ( scope . getBreadcrumbs ( ) [ 0 ] . message ) . toBe ( 'world' ) ;
106106 } ) ;
@@ -109,8 +109,8 @@ describe('BaseClient', () => {
109109 const client = new TestClient ( { } ) ;
110110 const scope = new Scope ( ) ;
111111 await Promise . all ( [
112- client . addBreadcrumb ( { message : 'hello' } , scope ) ,
113- client . addBreadcrumb ( { message : 'world' } , scope ) ,
112+ client . addBreadcrumb ( { message : 'hello' } , undefined , scope ) ,
113+ client . addBreadcrumb ( { message : 'world' } , undefined , scope ) ,
114114 ] ) ;
115115 expect ( scope . getBreadcrumbs ( ) ) . toHaveLength ( 2 ) ;
116116 } ) ;
@@ -119,25 +119,34 @@ describe('BaseClient', () => {
119119 const beforeBreadcrumb = jest . fn ( breadcrumb => breadcrumb ) ;
120120 const client = new TestClient ( { beforeBreadcrumb } ) ;
121121 const scope = new Scope ( ) ;
122- await client . addBreadcrumb ( { message : 'hello' } , scope ) ;
122+ await client . addBreadcrumb ( { message : 'hello' } , undefined , scope ) ;
123123 expect ( scope . getBreadcrumbs ( ) [ 0 ] . message ) . toBe ( 'hello' ) ;
124124 } ) ;
125125
126126 test ( 'calls beforeBreadcrumb and uses the new one' , async ( ) => {
127127 const beforeBreadcrumb = jest . fn ( ( ) => ( { message : 'changed' } ) ) ;
128128 const client = new TestClient ( { beforeBreadcrumb } ) ;
129129 const scope = new Scope ( ) ;
130- await client . addBreadcrumb ( { message : 'hello' } , scope ) ;
130+ await client . addBreadcrumb ( { message : 'hello' } , undefined , scope ) ;
131131 expect ( scope . getBreadcrumbs ( ) [ 0 ] . message ) . toBe ( 'changed' ) ;
132132 } ) ;
133133
134- test ( 'calls shouldAddBreadcrumb and discards the breadcrumb' , async ( ) => {
134+ test ( 'calls beforeBreadcrumb and discards the breadcrumb when returned null ' , async ( ) => {
135135 const beforeBreadcrumb = jest . fn ( ( ) => null ) ;
136136 const client = new TestClient ( { beforeBreadcrumb } ) ;
137137 const scope = new Scope ( ) ;
138- await client . addBreadcrumb ( { message : 'hello' } , scope ) ;
138+ await client . addBreadcrumb ( { message : 'hello' } , undefined , scope ) ;
139139 expect ( scope . getBreadcrumbs ( ) . length ) . toBe ( 0 ) ;
140140 } ) ;
141+
142+ test ( 'calls beforeBreadcrumb gets an access to a hint as a second argument' , async ( ) => {
143+ const beforeBreadcrumb = jest . fn ( ( breadcrumb , hint ) => ( { ...breadcrumb , data : hint . data } ) ) ;
144+ const client = new TestClient ( { beforeBreadcrumb } ) ;
145+ const scope = new Scope ( ) ;
146+ await client . addBreadcrumb ( { message : 'hello' } , { data : 'someRandomThing' } , scope ) ;
147+ expect ( scope . getBreadcrumbs ( ) [ 0 ] . message ) . toBe ( 'hello' ) ;
148+ expect ( scope . getBreadcrumbs ( ) [ 0 ] . data ) . toBe ( 'someRandomThing' ) ;
149+ } ) ;
141150 } ) ;
142151
143152 describe ( 'captures' , ( ) => {
0 commit comments