rest-vir - v2.2.0
    Preparing search index...

    Function describeApi

    • Use this in conjunction with @augment-vir/test or the Node.js built-in test runner to run tests for an api and automatically kill the server when all tests have finished. The describe callback is passed a params object which includes a fetch function.

      See testApi for more control over how tests are run (but without automatic server shutdown).

      Type Parameters

      Parameters

      • __namedParameters: {
            api: Readonly<Api>;
            options?: PartialWithUndefined<
                PartialWithUndefined<
                    {
                        bodyLimit: number;
                        connectionTimeout: number;
                        host: string;
                        keepAliveTimeout: number;
                        lockPort: boolean;
                        port: number;
                        preventWorkerRespawn: boolean;
                        requestTimeout: number;
                        trustProxy?: string
                        | number
                        | boolean
                        | string[]
                        | null;
                        webSocketMaxPayload: number;
                        workerCount: number;
                    },
                >,
            >;
        }
        • api: Readonly<Api>

          The api to startup and send requests to.

        • Optionaloptions?: PartialWithUndefined<
              PartialWithUndefined<
                  {
                      bodyLimit: number;
                      connectionTimeout: number;
                      host: string;
                      keepAliveTimeout: number;
                      lockPort: boolean;
                      port: number;
                      preventWorkerRespawn: boolean;
                      requestTimeout: number;
                      trustProxy?: string
                      | number
                      | boolean
                      | string[]
                      | null;
                      webSocketMaxPayload: number;
                      workerCount: number;
                  },
              >,
          >

          Options for starting the api.

      • describeCallback: (
            params: {
                api: Readonly<Api>;
                connectWebSocket: ConnectTestWebSocket<Api>;
                fetchEndpoint: FetchTestEndpoint<Api>;
                getServer: () => Promise<
                    Readonly<
                        FastifyInstance<
                            RawServerDefault,
                            IncomingMessage,
                            ServerResponse<IncomingMessage>,
                            FastifyBaseLogger,
                            FastifyTypeProviderDefault,
                        >,
                    >,
                >;
            },
        ) => void
        | undefined

      Returns void

      import {describeApi} from '@rest-vir/host';
      import {it} from '@augment-vir/test';

      describeApi({api: myApi}, ({fetchEndpoint}) => {
      it('responds', async () => {
      const response = await fetchEndpoint(myEndpoint, HttpMethod.Get);
      });
      });