1
1
import { createRunner } from '../../../../utils/runner' ;
2
+ import { describe , test , expect } from 'vitest'
2
3
3
4
// Graphql Instrumentation emits some spans by default on server start
4
5
const EXPECTED_START_SERVER_TRANSACTION = {
5
6
transaction : 'Test Server Start' ,
6
7
} ;
7
8
8
9
describe ( 'GraphQL/Apollo Tests > useOperationNameForRootSpan' , ( ) => {
9
- test ( 'useOperationNameForRootSpan works with single query operation' , done => {
10
+ test ( 'useOperationNameForRootSpan works with single query operation' , async ( ) => {
10
11
const EXPECTED_TRANSACTION = {
11
12
transaction : 'GET /test-graphql (query GetHello)' ,
12
13
spans : expect . arrayContaining ( [
@@ -24,13 +25,14 @@ describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => {
24
25
] ) ,
25
26
} ;
26
27
27
- createRunner ( __dirname , 'scenario-query.js' )
28
+ await createRunner ( __dirname , 'scenario-query.js' )
28
29
. expect ( { transaction : EXPECTED_START_SERVER_TRANSACTION } )
29
30
. expect ( { transaction : EXPECTED_TRANSACTION } )
30
- . start ( done ) ;
31
+ . start ( )
32
+ . completed ( ) ;
31
33
} ) ;
32
34
33
- test ( 'useOperationNameForRootSpan works with single mutation operation' , done => {
35
+ test ( 'useOperationNameForRootSpan works with single mutation operation' , async ( ) => {
34
36
const EXPECTED_TRANSACTION = {
35
37
transaction : 'GET /test-graphql (mutation TestMutation)' ,
36
38
spans : expect . arrayContaining ( [
@@ -50,13 +52,14 @@ describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => {
50
52
] ) ,
51
53
} ;
52
54
53
- createRunner ( __dirname , 'scenario-mutation.js' )
55
+ await createRunner ( __dirname , 'scenario-mutation.js' )
54
56
. expect ( { transaction : EXPECTED_START_SERVER_TRANSACTION } )
55
57
. expect ( { transaction : EXPECTED_TRANSACTION } )
56
- . start ( done ) ;
58
+ . start ( )
59
+ . completed ( ) ;
57
60
} ) ;
58
61
59
- test ( 'useOperationNameForRootSpan ignores an invalid root span' , done => {
62
+ test ( 'useOperationNameForRootSpan ignores an invalid root span' , async ( ) => {
60
63
const EXPECTED_TRANSACTION = {
61
64
transaction : 'test span name' ,
62
65
spans : expect . arrayContaining ( [
@@ -74,13 +77,14 @@ describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => {
74
77
] ) ,
75
78
} ;
76
79
77
- createRunner ( __dirname , 'scenario-invalid-root-span.js' )
80
+ await createRunner ( __dirname , 'scenario-invalid-root-span.js' )
78
81
. expect ( { transaction : EXPECTED_START_SERVER_TRANSACTION } )
79
82
. expect ( { transaction : EXPECTED_TRANSACTION } )
80
- . start ( done ) ;
83
+ . start ( )
84
+ . completed ( ) ;
81
85
} ) ;
82
86
83
- test ( 'useOperationNameForRootSpan works with single query operation without name' , done => {
87
+ test ( 'useOperationNameForRootSpan works with single query operation without name' , async ( ) => {
84
88
const EXPECTED_TRANSACTION = {
85
89
transaction : 'GET /test-graphql (query)' ,
86
90
spans : expect . arrayContaining ( [
@@ -97,13 +101,14 @@ describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => {
97
101
] ) ,
98
102
} ;
99
103
100
- createRunner ( __dirname , 'scenario-no-operation-name.js' )
104
+ await createRunner ( __dirname , 'scenario-no-operation-name.js' )
101
105
. expect ( { transaction : EXPECTED_START_SERVER_TRANSACTION } )
102
106
. expect ( { transaction : EXPECTED_TRANSACTION } )
103
- . start ( done ) ;
107
+ . start ( )
108
+ . completed ( ) ;
104
109
} ) ;
105
110
106
- test ( 'useOperationNameForRootSpan works with multiple query operations' , done => {
111
+ test ( 'useOperationNameForRootSpan works with multiple query operations' , async ( ) => {
107
112
const EXPECTED_TRANSACTION = {
108
113
transaction : 'GET /test-graphql (query GetHello, query GetWorld)' ,
109
114
spans : expect . arrayContaining ( [
@@ -132,21 +137,23 @@ describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => {
132
137
] ) ,
133
138
} ;
134
139
135
- createRunner ( __dirname , 'scenario-multiple-operations.js' )
140
+ await createRunner ( __dirname , 'scenario-multiple-operations.js' )
136
141
. expect ( { transaction : EXPECTED_START_SERVER_TRANSACTION } )
137
142
. expect ( { transaction : EXPECTED_TRANSACTION } )
138
- . start ( done ) ;
143
+ . start ( )
144
+ . completed ( ) ;
139
145
} ) ;
140
146
141
- test ( 'useOperationNameForRootSpan works with more than 5 query operations' , done => {
147
+ test ( 'useOperationNameForRootSpan works with more than 5 query operations' , async ( ) => {
142
148
const EXPECTED_TRANSACTION = {
143
149
transaction :
144
150
'GET /test-graphql (query GetHello1, query GetHello2, query GetHello3, query GetHello4, query GetHello5, +4)' ,
145
151
} ;
146
152
147
- createRunner ( __dirname , 'scenario-multiple-operations-many.js' )
153
+ await createRunner ( __dirname , 'scenario-multiple-operations-many.js' )
148
154
. expect ( { transaction : EXPECTED_START_SERVER_TRANSACTION } )
149
155
. expect ( { transaction : EXPECTED_TRANSACTION } )
150
- . start ( done ) ;
156
+ . start ( )
157
+ . completed ( ) ;
151
158
} ) ;
152
159
} ) ;
0 commit comments