Documentation
    Preparing search index...

    Http server utils are used to start the AdonisJS HTTP server during testing. It provides methods to start and stop the server for integration testing.

    const testUtils = new TestUtils(app)
    const httpUtils = testUtils.httpServer()

    const closeServer = await httpUtils.start()
    // Make HTTP requests to test endpoints
    await closeServer() // Clean up
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Testing hook to start the HTTP server to listen for new request. The return value is a function to close the HTTP server.

      Parameters

      • OptionalserverCallback: (
            handler: (req: IncomingMessage, res: ServerResponse) => any,
        ) =>
            | Server<typeof IncomingMessage, typeof ServerResponse>
            | Server<typeof IncomingMessage, typeof ServerResponse>

        Optional callback to create custom HTTP server instance

      Returns Promise<() => Promise<void>>