@@ -2,17 +2,9 @@ import request from 'supertest';
2
2
import { buildApp } from '../src/app.js' ;
3
3
4
4
describe ( 'fastify example integration' , ( ) => {
5
- const [ app ] = buildApp ( false ) ;
6
-
7
- beforeAll ( async ( ) => {
8
- await app . ready ( ) ;
9
- } ) ;
10
-
11
- afterAll ( async ( ) => {
12
- await app . close ( ) ;
13
- } ) ;
14
-
15
5
it ( 'sends GraphiQL' , async ( ) => {
6
+ const [ app ] = buildApp ( false ) ;
7
+ await app . ready ( ) ;
16
8
const response = await request ( app . server ) . get ( '/graphql' ) . set ( {
17
9
accept : 'text/html' ,
18
10
} ) ;
@@ -22,6 +14,8 @@ describe('fastify example integration', () => {
22
14
} ) ;
23
15
24
16
it ( 'handles query operation via POST' , async ( ) => {
17
+ const [ app ] = buildApp ( false ) ;
18
+ await app . ready ( ) ;
25
19
const response = await request ( app . server )
26
20
. post ( '/graphql' )
27
21
. set ( { 'content-type' : 'application/json' } )
@@ -44,6 +38,8 @@ describe('fastify example integration', () => {
44
38
} ) ;
45
39
46
40
it ( "exposes fastify's request and reply objects" , async ( ) => {
41
+ const [ app ] = buildApp ( false ) ;
42
+ await app . ready ( ) ;
47
43
const response = await request ( app . server )
48
44
. post ( '/graphql' )
49
45
. set ( { 'content-type' : 'application/json' } )
@@ -66,6 +62,8 @@ describe('fastify example integration', () => {
66
62
} ) ;
67
63
68
64
it ( 'handles query operation via GET' , async ( ) => {
65
+ const [ app ] = buildApp ( false ) ;
66
+ await app . ready ( ) ;
69
67
const response = await request ( app . server )
70
68
. get ( '/graphql' )
71
69
. query ( {
@@ -85,6 +83,8 @@ describe('fastify example integration', () => {
85
83
} ) ;
86
84
87
85
it ( 'handles mutation operation via POST' , async ( ) => {
86
+ const [ app ] = buildApp ( false ) ;
87
+ await app . ready ( ) ;
88
88
const response = await request ( app . server )
89
89
. post ( '/graphql' )
90
90
. set ( { 'content-type' : 'application/json' } )
@@ -107,6 +107,8 @@ describe('fastify example integration', () => {
107
107
} ) ;
108
108
109
109
it ( 'rejects mutation operation via GET with an useful error message' , async ( ) => {
110
+ const [ app ] = buildApp ( false ) ;
111
+ await app . ready ( ) ;
110
112
const response = await request ( app . server )
111
113
. get ( '/graphql' )
112
114
. query ( {
@@ -127,6 +129,8 @@ describe('fastify example integration', () => {
127
129
} ) ;
128
130
129
131
it ( 'handles subscription operations via GET' , async ( ) => {
132
+ const [ app ] = buildApp ( false ) ;
133
+ await app . ready ( ) ;
130
134
const response = await request ( app . server )
131
135
. get ( '/graphql' )
132
136
. set ( { accept : 'text/event-stream' } )
@@ -177,6 +181,8 @@ data"
177
181
` ) ;
178
182
} ) ;
179
183
it ( 'handles subscription operations via POST' , async ( ) => {
184
+ const [ app ] = buildApp ( false ) ;
185
+ await app . ready ( ) ;
180
186
const response = await request ( app . server )
181
187
. post ( '/graphql' )
182
188
. set ( {
@@ -230,6 +236,8 @@ data"
230
236
` ) ;
231
237
} ) ;
232
238
it ( 'should handle file uploads' , async ( ) => {
239
+ const [ app ] = buildApp ( false ) ;
240
+ await app . ready ( ) ;
233
241
const response = await request ( app . server )
234
242
. post ( '/graphql' )
235
243
. field (
@@ -252,6 +260,8 @@ data"
252
260
} ) ;
253
261
} ) ;
254
262
it ( 'request cancelation' , async ( ) => {
263
+ const [ app ] = buildApp ( false ) ;
264
+ await app . ready ( ) ;
255
265
const slowFieldResolverInvoked = createDeferred ( ) ;
256
266
const slowFieldResolverCanceled = createDeferred ( ) ;
257
267
const address = await app . listen ( {
0 commit comments