@@ -84,23 +84,23 @@ describe('BaseClient', () => {
84
84
const client = new TestClient ( { } ) ;
85
85
const scope = new Scope ( ) ;
86
86
scope . addBreadcrumb ( { message : 'hello' } , 100 ) ;
87
- await client . addBreadcrumb ( { message : 'world' } , scope ) ;
87
+ await client . addBreadcrumb ( { message : 'world' } , undefined , scope ) ;
88
88
expect ( scope . getBreadcrumbs ( ) [ 1 ] . message ) . toBe ( 'world' ) ;
89
89
} ) ;
90
90
91
91
test ( 'adds a timestamp to new breadcrumbs' , async ( ) => {
92
92
const client = new TestClient ( { } ) ;
93
93
const scope = new Scope ( ) ;
94
94
scope . addBreadcrumb ( { message : 'hello' } , 100 ) ;
95
- await client . addBreadcrumb ( { message : 'world' } , scope ) ;
95
+ await client . addBreadcrumb ( { message : 'world' } , undefined , scope ) ;
96
96
expect ( scope . getBreadcrumbs ( ) [ 1 ] . timestamp ) . toBeGreaterThan ( 1 ) ;
97
97
} ) ;
98
98
99
99
test ( 'discards breadcrumbs beyond maxBreadcrumbs' , async ( ) => {
100
100
const client = new TestClient ( { maxBreadcrumbs : 1 } ) ;
101
101
const scope = new Scope ( ) ;
102
102
scope . addBreadcrumb ( { message : 'hello' } , 100 ) ;
103
- await client . addBreadcrumb ( { message : 'world' } , scope ) ;
103
+ await client . addBreadcrumb ( { message : 'world' } , undefined , scope ) ;
104
104
expect ( scope . getBreadcrumbs ( ) . length ) . toBe ( 1 ) ;
105
105
expect ( scope . getBreadcrumbs ( ) [ 0 ] . message ) . toBe ( 'world' ) ;
106
106
} ) ;
@@ -109,8 +109,8 @@ describe('BaseClient', () => {
109
109
const client = new TestClient ( { } ) ;
110
110
const scope = new Scope ( ) ;
111
111
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 ) ,
114
114
] ) ;
115
115
expect ( scope . getBreadcrumbs ( ) ) . toHaveLength ( 2 ) ;
116
116
} ) ;
@@ -119,25 +119,34 @@ describe('BaseClient', () => {
119
119
const beforeBreadcrumb = jest . fn ( breadcrumb => breadcrumb ) ;
120
120
const client = new TestClient ( { beforeBreadcrumb } ) ;
121
121
const scope = new Scope ( ) ;
122
- await client . addBreadcrumb ( { message : 'hello' } , scope ) ;
122
+ await client . addBreadcrumb ( { message : 'hello' } , undefined , scope ) ;
123
123
expect ( scope . getBreadcrumbs ( ) [ 0 ] . message ) . toBe ( 'hello' ) ;
124
124
} ) ;
125
125
126
126
test ( 'calls beforeBreadcrumb and uses the new one' , async ( ) => {
127
127
const beforeBreadcrumb = jest . fn ( ( ) => ( { message : 'changed' } ) ) ;
128
128
const client = new TestClient ( { beforeBreadcrumb } ) ;
129
129
const scope = new Scope ( ) ;
130
- await client . addBreadcrumb ( { message : 'hello' } , scope ) ;
130
+ await client . addBreadcrumb ( { message : 'hello' } , undefined , scope ) ;
131
131
expect ( scope . getBreadcrumbs ( ) [ 0 ] . message ) . toBe ( 'changed' ) ;
132
132
} ) ;
133
133
134
- test ( 'calls shouldAddBreadcrumb and discards the breadcrumb' , async ( ) => {
134
+ test ( 'calls beforeBreadcrumb and discards the breadcrumb when returned null ' , async ( ) => {
135
135
const beforeBreadcrumb = jest . fn ( ( ) => null ) ;
136
136
const client = new TestClient ( { beforeBreadcrumb } ) ;
137
137
const scope = new Scope ( ) ;
138
- await client . addBreadcrumb ( { message : 'hello' } , scope ) ;
138
+ await client . addBreadcrumb ( { message : 'hello' } , undefined , scope ) ;
139
139
expect ( scope . getBreadcrumbs ( ) . length ) . toBe ( 0 ) ;
140
140
} ) ;
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
+ } ) ;
141
150
} ) ;
142
151
143
152
describe ( 'captures' , ( ) => {
0 commit comments