Utility for creating a valid configuration to use with the JSDOM environment.

Hierarchy

  • Configuration

Implements

Constructors

  • Create a configuration for use with the JSDOM environment.

    Parameters

    • getFileList: ((url, renderAPI, fetchFn) => Promise<string[]>)

      Callback that should return a promise for the list of JavaScript files the environment must execute in order to produce a result for the given render request.

        • (url, renderAPI, fetchFn): Promise<string[]>
        • Parameters

          • url: string
          • renderAPI: RenderAPI
          • fetchFn: ((url) => undefined | null | Promise<Buffer>)
              • (url): undefined | null | Promise<Buffer>
              • Parameters

                • url: string

                Returns undefined | null | Promise<Buffer>

          Returns Promise<string[]>

    • getResourceLoader: ((url, renderAPI) => CloseableResourceLoader)

      Callback that should return a JSDOM resource loader for the given request. We must call this per render so that logging is appropriately channeled for the request being made.

        • (url, renderAPI): CloseableResourceLoader
        • Parameters

          Returns CloseableResourceLoader

    • Optional afterEnvSetup: ((url, fileURLs, renderAPI, vmContext?) => Promise<undefined | null | ICloseable>)

      Callback to perform additional environment setup before the render occurs. This can optionally return an object that can add extra fields to the environment context for rendering code to access. This is useful if your render server wants to add some specific configuration, such as setting up some versions of Apollo for server-side rendering. Be careful; any functions you attach can be executed by the rendering code.

        • (url, fileURLs, renderAPI, vmContext?): Promise<undefined | null | ICloseable>
        • Parameters

          • url: string
          • fileURLs: readonly string[]
          • renderAPI: RenderAPI
          • Optional vmContext: any

          Returns Promise<undefined | null | ICloseable>

    • Optional registrationCallbackName: string = "__jsdom_env_register"

      The name of the function that the environment should expose for client code to register for rendering. This defaults to __jsdom_env_register.

    Returns Configuration

Properties

afterEnvSetup: ((url, fileURLs, renderAPI, vmContext?) => Promise<undefined | null | ICloseable>)

Type declaration

    • (url, fileURLs, renderAPI, vmContext?): Promise<undefined | null | ICloseable>
    • Parameters

      • url: string
      • fileURLs: readonly string[]
      • renderAPI: RenderAPI
      • Optional vmContext: any

      Returns Promise<undefined | null | ICloseable>

getFileList: ((url, renderAPI, fetchFn) => Promise<string[]>)

Type declaration

    • (url, renderAPI, fetchFn): Promise<string[]>
    • Parameters

      • url: string
      • renderAPI: RenderAPI
      • fetchFn: ((url) => undefined | null | Promise<Buffer>)
          • (url): undefined | null | Promise<Buffer>
          • Parameters

            • url: string

            Returns undefined | null | Promise<Buffer>

      Returns Promise<string[]>

getResourceLoader: ((url, renderAPI) => CloseableResourceLoader)

Type declaration

    • (url, renderAPI): CloseableResourceLoader
    • Parameters

      Returns CloseableResourceLoader

registrationCallbackName: string

Generated using TypeDoc