@@ -422,7 +422,7 @@ module.exports = (pkg) => {
422422 )
423423 } )
424424
425- t . test ( 'using multipler routers' , ( t ) => {
425+ t . test ( 'using multiple routers' , ( t ) => {
426426 t . beforeEach ( testSetup )
427427 t . afterEach ( tearDown )
428428 t . autoend ( )
@@ -546,23 +546,20 @@ module.exports = (pkg) => {
546546 nestedRouter . get ( '/:second' , function terminalMiddleware ( ctx ) {
547547 ctx . body = 'this is a test'
548548 } )
549- nestedRouter . get ( '/second' , function secondMiddleware ( ctx ) {
550- ctx . body = 'want this to set the name'
551- } )
552549 router . use ( '/:first' , nestedRouter . routes ( ) )
553550 app . use ( router . routes ( ) )
554551
555552 agent . on ( 'transactionFinished' , ( tx ) => {
556553 t . assertSegments ( tx . trace . root , [
557- 'WebTransaction/WebFrameworkUri/Koa/GET//:first/second' ,
554+ 'WebTransaction/WebFrameworkUri/Koa/GET//:first/: second' ,
558555 [
559556 'Nodejs/Middleware/Koa/appLevelMiddleware' ,
560557 [ 'Koa/Router: /' , [ getNestedSpanName ( 'terminalMiddleware' ) ] ]
561558 ]
562559 ] )
563560 t . equal (
564561 tx . name ,
565- 'WebTransaction/WebFrameworkUri/Koa/GET//:first/second' ,
562+ 'WebTransaction/WebFrameworkUri/Koa/GET//:first/: second' ,
566563 'should be named after last matched route'
567564 )
568565 t . end ( )
@@ -581,23 +578,20 @@ module.exports = (pkg) => {
581578 router . get ( '/:second' , function terminalMiddleware ( ctx ) {
582579 ctx . body = 'this is a test'
583580 } )
584- router . get ( '/second' , function secondMiddleware ( ctx ) {
585- ctx . body = 'want this to set the name'
586- } )
587581 router . prefix ( '/:first' )
588582 app . use ( router . routes ( ) )
589583
590584 agent . on ( 'transactionFinished' , ( tx ) => {
591585 t . assertSegments ( tx . trace . root , [
592- 'WebTransaction/WebFrameworkUri/Koa/GET//:first/second' ,
586+ 'WebTransaction/WebFrameworkUri/Koa/GET//:first/: second' ,
593587 [
594588 'Nodejs/Middleware/Koa/appLevelMiddleware' ,
595589 [ 'Koa/Router: /' , [ 'Nodejs/Middleware/Koa/terminalMiddleware//:first/:second' ] ]
596590 ]
597591 ] )
598592 t . equal (
599593 tx . name ,
600- 'WebTransaction/WebFrameworkUri/Koa/GET//:first/second' ,
594+ 'WebTransaction/WebFrameworkUri/Koa/GET//:first/: second' ,
601595 'should be named after the last matched path'
602596 )
603597 t . end ( )
@@ -607,6 +601,11 @@ module.exports = (pkg) => {
607601 } )
608602
609603 t . test ( 'using allowedMethods' , ( t ) => {
604+ // `@koa/[email protected] ` changed the allowedMethods middleware function from named to arrow function 605+ // update span name for assertions
606+ const allowedMethodsFnName = semver . gte ( pkgVersion , '13.0.0' )
607+ ? '<anonymous>'
608+ : 'allowedMethods'
610609 t . autoend ( )
611610
612611 t . test ( 'with throw: true' , ( t ) => {
@@ -622,7 +621,7 @@ module.exports = (pkg) => {
622621 agent . on ( 'transactionFinished' , ( tx ) => {
623622 t . assertSegments ( tx . trace . root , [
624623 'WebTransaction/WebFrameworkUri/Koa/GET/(method not allowed)' ,
625- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
624+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
626625 ] )
627626 t . equal (
628627 tx . name ,
@@ -645,7 +644,7 @@ module.exports = (pkg) => {
645644 agent . on ( 'transactionFinished' , ( tx ) => {
646645 t . assertSegments ( tx . trace . root , [
647646 'WebTransaction/WebFrameworkUri/Koa/GET/(not implemented)' ,
648- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
647+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
649648 ] )
650649 t . equal (
651650 tx . name ,
@@ -683,7 +682,7 @@ module.exports = (pkg) => {
683682 'WebTransaction/NormalizedUri/*' ,
684683 [
685684 'Nodejs/Middleware/Koa/errorHandler' ,
686- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
685+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
687686 ]
688687 ] )
689688 t . equal (
@@ -722,7 +721,7 @@ module.exports = (pkg) => {
722721 'WebTransaction/WebFrameworkUri/Koa/GET/(method not allowed)' ,
723722 [
724723 'Nodejs/Middleware/Koa/baseMiddleware' ,
725- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
724+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
726725 ]
727726 ] )
728727 t . equal (
@@ -753,7 +752,7 @@ module.exports = (pkg) => {
753752 agent . on ( 'transactionFinished' , ( tx ) => {
754753 t . assertSegments ( tx . trace . root , [
755754 'WebTransaction/WebFrameworkUri/Koa/GET/(method not allowed)' ,
756- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
755+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
757756 ] )
758757 t . equal (
759758 tx . name ,
@@ -777,7 +776,7 @@ module.exports = (pkg) => {
777776 agent . on ( 'transactionFinished' , ( tx ) => {
778777 t . assertSegments ( tx . trace . root , [
779778 'WebTransaction/WebFrameworkUri/Koa/GET/(not implemented)' ,
780- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
779+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
781780 ] )
782781 t . equal (
783782 tx . name ,
@@ -811,7 +810,7 @@ module.exports = (pkg) => {
811810 'WebTransaction/WebFrameworkUri/Koa/GET/(method not allowed)' ,
812811 [
813812 'Nodejs/Middleware/Koa/appLevelMiddleware' ,
814- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
813+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
815814 ]
816815 ] )
817816 t . equal (
@@ -845,7 +844,7 @@ module.exports = (pkg) => {
845844 'WebTransaction/WebFrameworkUri/Koa/GET/(not implemented)' ,
846845 [
847846 'Nodejs/Middleware/Koa/appLevelMiddleware' ,
848- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
847+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
849848 ]
850849 ] )
851850 t . equal (
0 commit comments