@@ -325,6 +325,16 @@ describe('trace', () => {
325325 expect ( getActiveSpan ( ) ) . toBe ( undefined ) ;
326326 } ) ;
327327
328+ it ( 'allows to pass parentSpan=null' , ( ) => {
329+ startSpan ( { name : 'GET users/[id' } , ( ) => {
330+ startSpan ( { name : 'child' , parentSpan : null } , span => {
331+ // Due to the way we propagate the scope in OTEL,
332+ // the parent_span_id is not actually undefined here, but comes from the propagation context
333+ expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( getCurrentScope ( ) . getPropagationContext ( ) . spanId ) ;
334+ } ) ;
335+ } ) ;
336+ } ) ;
337+
328338 it ( 'allows to force a transaction with forceTransaction=true' , async ( ) => {
329339 const client = getClient ( ) ! ;
330340 const transactionEvents : Event [ ] = [ ] ;
@@ -577,6 +587,17 @@ describe('trace', () => {
577587 expect ( getActiveSpan ( ) ) . toBe ( undefined ) ;
578588 } ) ;
579589
590+ it ( 'allows to pass parentSpan=null' , ( ) => {
591+ startSpan ( { name : 'outer' } , ( ) => {
592+ const span = startInactiveSpan ( { name : 'test span' , parentSpan : null } ) ;
593+
594+ // Due to the way we propagate the scope in OTEL,
595+ // the parent_span_id is not actually undefined here, but comes from the propagation context
596+ expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( getCurrentScope ( ) . getPropagationContext ( ) . spanId ) ;
597+ span . end ( ) ;
598+ } ) ;
599+ } ) ;
600+
580601 it ( 'allows to force a transaction with forceTransaction=true' , async ( ) => {
581602 const client = getClient ( ) ! ;
582603 const transactionEvents : Event [ ] = [ ] ;
@@ -856,6 +877,17 @@ describe('trace', () => {
856877 expect ( getActiveSpan ( ) ) . toBe ( undefined ) ;
857878 } ) ;
858879
880+ it ( 'allows to pass parentSpan=null' , ( ) => {
881+ startSpan ( { name : 'outer' } , ( ) => {
882+ startSpanManual ( { name : 'GET users/[id]' , parentSpan : null } , span => {
883+ // Due to the way we propagate the scope in OTEL,
884+ // the parent_span_id is not actually undefined here, but comes from the propagation context
885+ expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( getCurrentScope ( ) . getPropagationContext ( ) . spanId ) ;
886+ span . end ( ) ;
887+ } ) ;
888+ } ) ;
889+ } ) ;
890+
859891 it ( 'allows to force a transaction with forceTransaction=true' , async ( ) => {
860892 const client = getClient ( ) ! ;
861893 const transactionEvents : Event [ ] = [ ] ;
0 commit comments