@@ -14,40 +14,51 @@ export function defineLambdaTestSuite<Event, Response>(
14
14
shouldBase64Encode : boolean ,
15
15
) => ( req : IncomingMessage , res : ServerResponse ) => void ,
16
16
) {
17
- for ( const shouldBase64Encode of [ true , false ] ) {
18
- describe ( ` With base64 encoding ${
19
- shouldBase64Encode ? 'enabled' : 'disabled'
20
- } ` , ( ) => {
21
- defineIntegrationTestSuite ( async function (
22
- serverOptions : ApolloServerOptions < BaseContext > ,
23
- testOptions ?: CreateServerForIntegrationTestsOptions ,
24
- ) {
25
- const httpServer = createServer ( ) ;
26
- const server = new ApolloServer ( {
27
- ...serverOptions ,
28
- } ) ;
17
+ describe . each ( [ true , false ] ) (
18
+ ' With base64 encoding set to %s' ,
19
+ ( shouldBase64Encode ) => {
20
+ defineIntegrationTestSuite (
21
+ async function (
22
+ serverOptions : ApolloServerOptions < BaseContext > ,
23
+ testOptions ?: CreateServerForIntegrationTestsOptions ,
24
+ ) {
25
+ const httpServer = createServer ( ) ;
26
+ const server = new ApolloServer ( {
27
+ ...serverOptions ,
28
+ } ) ;
29
29
30
- const handler = startServerAndCreateLambdaHandler ( server , testOptions ) ;
30
+ const handler = startServerAndCreateLambdaHandler (
31
+ server ,
32
+ testOptions ,
33
+ ) ;
31
34
32
- httpServer . addListener ( 'request' , mockServerFactory ( handler as Handler < Event , Response > , shouldBase64Encode ) ) ;
35
+ httpServer . addListener (
36
+ 'request' ,
37
+ mockServerFactory (
38
+ handler as Handler < Event , Response > ,
39
+ shouldBase64Encode ,
40
+ ) ,
41
+ ) ;
33
42
34
- await new Promise < void > ( ( resolve ) => {
35
- httpServer . listen ( { port : 0 } , resolve ) ;
36
- } ) ;
37
-
38
- return {
39
- server,
40
- url : urlForHttpServer ( httpServer ) ,
41
- async extraCleanup ( ) {
42
- await new Promise < void > ( ( resolve ) => {
43
- httpServer . close ( ( ) => resolve ( ) ) ;
44
- } ) ;
45
- } ,
46
- } ;
47
- } , {
48
- serverIsStartedInBackground : true ,
49
- noIncrementalDelivery : true ,
50
- } ) ;
51
- } ) ;
52
- }
43
+ await new Promise < void > ( ( resolve ) => {
44
+ httpServer . listen ( { port : 0 } , resolve ) ;
45
+ } ) ;
46
+
47
+ return {
48
+ server,
49
+ url : urlForHttpServer ( httpServer ) ,
50
+ async extraCleanup ( ) {
51
+ await new Promise < void > ( ( resolve ) => {
52
+ httpServer . close ( ( ) => resolve ( ) ) ;
53
+ } ) ;
54
+ } ,
55
+ } ;
56
+ } ,
57
+ {
58
+ serverIsStartedInBackground : true ,
59
+ noIncrementalDelivery : true ,
60
+ } ,
61
+ ) ;
62
+ } ,
63
+ ) ;
53
64
}
0 commit comments