import { ApolloServer } from '../ApolloServer' ; import type { Config } from 'apollo-server-core' ; import testSuite , { schema as Schema , CreateAppOptions , } from 'apollo-server-integration-testsuite' ; describe ( 'integration:Hapi' , ( ) => { async function createApp ( options = { } ) { const { Server } = require ( '@hapi/hapi' ) ; const app = new Server ( { host : 'localhost' , } ) ; const server = new ApolloServer ( ( options . graphqlOptions as Config ) || { schema : Schema } ) ; await server . start ( ) ; await server . applyMiddleware ( { app , } ) ; await app . start ( ) ; return app . listener ; } async function destroyApp ( app ) { if ( ! app || ! app . close ) { return ; } await new Promise ( ( resolve ) => app . close ( resolve ) ) ; } testSuite ( { createApp , destroyApp , integrationName : 'hapi' } ) ; } ) ;