@@ -216,6 +216,39 @@ describe('BrowserTracing', () => {
216
216
217
217
expect ( mockBeforeNavigation ) . toHaveBeenCalledTimes ( 1 ) ;
218
218
} ) ;
219
+
220
+ it ( "sets transaction name source to `'custom'` if name is changed" , ( ) => {
221
+ const mockBeforeNavigation = jest . fn ( ctx => ( {
222
+ ...ctx ,
223
+ name : 'newName' ,
224
+ } ) ) ;
225
+ createBrowserTracing ( true , {
226
+ beforeNavigate : mockBeforeNavigation ,
227
+ routingInstrumentation : customInstrumentRouting ,
228
+ } ) ;
229
+ const transaction = getActiveTransaction ( hub ) as IdleTransaction ;
230
+ expect ( transaction ) . toBeDefined ( ) ;
231
+ expect ( transaction . name ) . toBe ( 'newName' ) ;
232
+ expect ( transaction . metadata . source ) . toBe ( 'custom' ) ;
233
+
234
+ expect ( mockBeforeNavigation ) . toHaveBeenCalledTimes ( 1 ) ;
235
+ } ) ;
236
+
237
+ it ( "doesn't set transaction name source if name is not changed" , ( ) => {
238
+ const mockBeforeNavigation = jest . fn ( ctx => ( {
239
+ ...ctx ,
240
+ } ) ) ;
241
+ createBrowserTracing ( true , {
242
+ beforeNavigate : mockBeforeNavigation ,
243
+ routingInstrumentation : customInstrumentRouting ,
244
+ } ) ;
245
+ const transaction = getActiveTransaction ( hub ) as IdleTransaction ;
246
+ expect ( transaction ) . toBeDefined ( ) ;
247
+ expect ( transaction . name ) . toBe ( 'a/path' ) ;
248
+ expect ( transaction . metadata . source ) . toBeUndefined ( ) ;
249
+
250
+ expect ( mockBeforeNavigation ) . toHaveBeenCalledTimes ( 1 ) ;
251
+ } ) ;
219
252
} ) ;
220
253
221
254
it ( 'sets transaction context from sentry-trace header' , ( ) => {
0 commit comments