@@ -422,7 +422,7 @@ module.exports = (pkg) => {
422
422
)
423
423
} )
424
424
425
- t . test ( 'using multipler routers' , ( t ) => {
425
+ t . test ( 'using multiple routers' , ( t ) => {
426
426
t . beforeEach ( testSetup )
427
427
t . afterEach ( tearDown )
428
428
t . autoend ( )
@@ -546,23 +546,20 @@ module.exports = (pkg) => {
546
546
nestedRouter . get ( '/:second' , function terminalMiddleware ( ctx ) {
547
547
ctx . body = 'this is a test'
548
548
} )
549
- nestedRouter . get ( '/second' , function secondMiddleware ( ctx ) {
550
- ctx . body = 'want this to set the name'
551
- } )
552
549
router . use ( '/:first' , nestedRouter . routes ( ) )
553
550
app . use ( router . routes ( ) )
554
551
555
552
agent . on ( 'transactionFinished' , ( tx ) => {
556
553
t . assertSegments ( tx . trace . root , [
557
- 'WebTransaction/WebFrameworkUri/Koa/GET//:first/second' ,
554
+ 'WebTransaction/WebFrameworkUri/Koa/GET//:first/: second' ,
558
555
[
559
556
'Nodejs/Middleware/Koa/appLevelMiddleware' ,
560
557
[ 'Koa/Router: /' , [ getNestedSpanName ( 'terminalMiddleware' ) ] ]
561
558
]
562
559
] )
563
560
t . equal (
564
561
tx . name ,
565
- 'WebTransaction/WebFrameworkUri/Koa/GET//:first/second' ,
562
+ 'WebTransaction/WebFrameworkUri/Koa/GET//:first/: second' ,
566
563
'should be named after last matched route'
567
564
)
568
565
t . end ( )
@@ -581,23 +578,20 @@ module.exports = (pkg) => {
581
578
router . get ( '/:second' , function terminalMiddleware ( ctx ) {
582
579
ctx . body = 'this is a test'
583
580
} )
584
- router . get ( '/second' , function secondMiddleware ( ctx ) {
585
- ctx . body = 'want this to set the name'
586
- } )
587
581
router . prefix ( '/:first' )
588
582
app . use ( router . routes ( ) )
589
583
590
584
agent . on ( 'transactionFinished' , ( tx ) => {
591
585
t . assertSegments ( tx . trace . root , [
592
- 'WebTransaction/WebFrameworkUri/Koa/GET//:first/second' ,
586
+ 'WebTransaction/WebFrameworkUri/Koa/GET//:first/: second' ,
593
587
[
594
588
'Nodejs/Middleware/Koa/appLevelMiddleware' ,
595
589
[ 'Koa/Router: /' , [ 'Nodejs/Middleware/Koa/terminalMiddleware//:first/:second' ] ]
596
590
]
597
591
] )
598
592
t . equal (
599
593
tx . name ,
600
- 'WebTransaction/WebFrameworkUri/Koa/GET//:first/second' ,
594
+ 'WebTransaction/WebFrameworkUri/Koa/GET//:first/: second' ,
601
595
'should be named after the last matched path'
602
596
)
603
597
t . end ( )
@@ -607,6 +601,11 @@ module.exports = (pkg) => {
607
601
} )
608
602
609
603
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'
610
609
t . autoend ( )
611
610
612
611
t . test ( 'with throw: true' , ( t ) => {
@@ -622,7 +621,7 @@ module.exports = (pkg) => {
622
621
agent . on ( 'transactionFinished' , ( tx ) => {
623
622
t . assertSegments ( tx . trace . root , [
624
623
'WebTransaction/WebFrameworkUri/Koa/GET/(method not allowed)' ,
625
- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
624
+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
626
625
] )
627
626
t . equal (
628
627
tx . name ,
@@ -645,7 +644,7 @@ module.exports = (pkg) => {
645
644
agent . on ( 'transactionFinished' , ( tx ) => {
646
645
t . assertSegments ( tx . trace . root , [
647
646
'WebTransaction/WebFrameworkUri/Koa/GET/(not implemented)' ,
648
- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
647
+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
649
648
] )
650
649
t . equal (
651
650
tx . name ,
@@ -683,7 +682,7 @@ module.exports = (pkg) => {
683
682
'WebTransaction/NormalizedUri/*' ,
684
683
[
685
684
'Nodejs/Middleware/Koa/errorHandler' ,
686
- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
685
+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
687
686
]
688
687
] )
689
688
t . equal (
@@ -722,7 +721,7 @@ module.exports = (pkg) => {
722
721
'WebTransaction/WebFrameworkUri/Koa/GET/(method not allowed)' ,
723
722
[
724
723
'Nodejs/Middleware/Koa/baseMiddleware' ,
725
- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
724
+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
726
725
]
727
726
] )
728
727
t . equal (
@@ -753,7 +752,7 @@ module.exports = (pkg) => {
753
752
agent . on ( 'transactionFinished' , ( tx ) => {
754
753
t . assertSegments ( tx . trace . root , [
755
754
'WebTransaction/WebFrameworkUri/Koa/GET/(method not allowed)' ,
756
- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
755
+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
757
756
] )
758
757
t . equal (
759
758
tx . name ,
@@ -777,7 +776,7 @@ module.exports = (pkg) => {
777
776
agent . on ( 'transactionFinished' , ( tx ) => {
778
777
t . assertSegments ( tx . trace . root , [
779
778
'WebTransaction/WebFrameworkUri/Koa/GET/(not implemented)' ,
780
- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
779
+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
781
780
] )
782
781
t . equal (
783
782
tx . name ,
@@ -811,7 +810,7 @@ module.exports = (pkg) => {
811
810
'WebTransaction/WebFrameworkUri/Koa/GET/(method not allowed)' ,
812
811
[
813
812
'Nodejs/Middleware/Koa/appLevelMiddleware' ,
814
- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
813
+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
815
814
]
816
815
] )
817
816
t . equal (
@@ -845,7 +844,7 @@ module.exports = (pkg) => {
845
844
'WebTransaction/WebFrameworkUri/Koa/GET/(not implemented)' ,
846
845
[
847
846
'Nodejs/Middleware/Koa/appLevelMiddleware' ,
848
- [ 'Koa/Router: /' , [ ' Nodejs/Middleware/Koa/allowedMethods' ] ]
847
+ [ 'Koa/Router: /' , [ ` Nodejs/Middleware/Koa/${ allowedMethodsFnName } ` ] ]
849
848
]
850
849
] )
851
850
t . equal (
0 commit comments