@@ -36,6 +36,7 @@ jest.mock('@sentry/browser', () => ({
36
36
37
37
beforeEach ( ( ) => {
38
38
mockStartChild . mockClear ( ) ;
39
+ mockFinish . mockClear ( ) ;
39
40
activeTransaction = new MockSpan ( { op : 'pageload' } ) ;
40
41
} ) ;
41
42
@@ -100,7 +101,9 @@ describe('withProfiler', () => {
100
101
} ) ;
101
102
102
103
it ( 'is not created if hasRenderSpan is false' , ( ) => {
103
- const ProfiledComponent = withProfiler ( ( ) => < h1 > Testing</ h1 > , { includeRender : false } ) ;
104
+ const ProfiledComponent = withProfiler ( ( ) => < h1 > Testing</ h1 > , {
105
+ includeRender : false ,
106
+ } ) ;
104
107
expect ( mockStartChild ) . toHaveBeenCalledTimes ( 0 ) ;
105
108
106
109
const component = render ( < ProfiledComponent /> ) ;
@@ -115,32 +118,33 @@ describe('withProfiler', () => {
115
118
const ProfiledComponent = withProfiler ( ( props : { num : number } ) => < div > { props . num } </ div > ) ;
116
119
const { rerender } = render ( < ProfiledComponent num = { 0 } /> ) ;
117
120
expect ( mockStartChild ) . toHaveBeenCalledTimes ( 1 ) ;
121
+ expect ( mockFinish ) . toHaveBeenCalledTimes ( 1 ) ;
118
122
119
123
// Dispatch new props
120
124
rerender ( < ProfiledComponent num = { 1 } /> ) ;
121
125
expect ( mockStartChild ) . toHaveBeenCalledTimes ( 2 ) ;
122
126
expect ( mockStartChild ) . toHaveBeenLastCalledWith ( {
123
127
data : { changedProps : [ 'num' ] } ,
124
128
description : `<${ UNKNOWN_COMPONENT } >` ,
125
- endTimestamp : expect . any ( Number ) ,
126
129
op : REACT_UPDATE_OP ,
127
130
startTimestamp : expect . any ( Number ) ,
128
131
} ) ;
129
-
132
+ expect ( mockFinish ) . toHaveBeenCalledTimes ( 2 ) ;
130
133
// New props yet again
131
134
rerender ( < ProfiledComponent num = { 2 } /> ) ;
132
135
expect ( mockStartChild ) . toHaveBeenCalledTimes ( 3 ) ;
133
136
expect ( mockStartChild ) . toHaveBeenLastCalledWith ( {
134
137
data : { changedProps : [ 'num' ] } ,
135
138
description : `<${ UNKNOWN_COMPONENT } >` ,
136
- endTimestamp : expect . any ( Number ) ,
137
139
op : REACT_UPDATE_OP ,
138
140
startTimestamp : expect . any ( Number ) ,
139
141
} ) ;
142
+ expect ( mockFinish ) . toHaveBeenCalledTimes ( 3 ) ;
140
143
141
144
// Should not create spans if props haven't changed
142
145
rerender ( < ProfiledComponent num = { 2 } /> ) ;
143
146
expect ( mockStartChild ) . toHaveBeenCalledTimes ( 3 ) ;
147
+ expect ( mockFinish ) . toHaveBeenCalledTimes ( 3 ) ;
144
148
} ) ;
145
149
146
150
it ( 'does not get created if hasUpdateSpan is false' , ( ) => {
0 commit comments