@@ -256,12 +256,50 @@ describe('Angular Tracing', () => {
256256
257257 describe ( 'TraceDirective' , ( ) => {
258258 it ( 'should create an instance' , ( ) => {
259- const directive = new TraceDirective ( ) ;
259+ const directive = new TraceDirective ( { } as unknown as any ) ;
260260 expect ( directive ) . toBeTruthy ( ) ;
261261 } ) ;
262262
263+ it ( 'should create a child tracingSpan on init (WIP)' , async ( ) => {
264+ const customStartTransaction = jest . fn ( defaultStartTransaction ) ;
265+
266+ @Component ( {
267+ selector : 'app-component' ,
268+ template : `<app-child trace></app-child>` ,
269+ } )
270+ class AppComponent {
271+ public constructor ( ) { }
272+ }
273+
274+ @Component ( {
275+ selector : 'app-child' ,
276+ template : `<p>Hi</p>` ,
277+ } )
278+ class ChildComponent {
279+ public constructor ( ) { }
280+ }
281+
282+ const env = await TestEnv . setup ( {
283+ components : [ AppComponent , ChildComponent , TraceDirective ] ,
284+ defaultComponent : AppComponent ,
285+ customStartTransaction,
286+ useTraceService : false ,
287+ } ) ;
288+
289+ transaction . startChild = jest . fn ( ) ;
290+
291+ //directive.ngOnInit();
292+
293+ expect ( transaction . startChild ) . toHaveBeenCalledWith ( {
294+ op : 'ui.angular.init' ,
295+ description : '<unknown>' ,
296+ } ) ;
297+
298+ env . destroy ( ) ;
299+ } ) ;
300+
263301 it ( 'should create a child tracingSpan on init' , async ( ) => {
264- const directive = new TraceDirective ( ) ;
302+ // const directive = new TraceDirective({} as unknown as any );
265303 const customStartTransaction = jest . fn ( defaultStartTransaction ) ;
266304
267305 const env = await TestEnv . setup ( {
@@ -272,7 +310,7 @@ describe('Angular Tracing', () => {
272310
273311 transaction . startChild = jest . fn ( ) ;
274312
275- directive . ngOnInit ( ) ;
313+ // directive.ngOnInit();
276314
277315 expect ( transaction . startChild ) . toHaveBeenCalledWith ( {
278316 op : 'ui.angular.init' ,
@@ -283,7 +321,7 @@ describe('Angular Tracing', () => {
283321 } ) ;
284322
285323 it ( 'should use component name as span description' , async ( ) => {
286- const directive = new TraceDirective ( ) ;
324+ const directive = new TraceDirective ( { } as unknown as any ) ;
287325 const finishMock = jest . fn ( ) ;
288326 const customStartTransaction = jest . fn ( defaultStartTransaction ) ;
289327
@@ -309,7 +347,7 @@ describe('Angular Tracing', () => {
309347 } ) ;
310348
311349 it ( 'should finish tracingSpan after view init' , async ( ) => {
312- const directive = new TraceDirective ( ) ;
350+ const directive = new TraceDirective ( { } as unknown as any ) ;
313351 const finishMock = jest . fn ( ) ;
314352 const customStartTransaction = jest . fn ( defaultStartTransaction ) ;
315353
0 commit comments