@mojojs/core
    Preparing search index...

    Class TestUserAgent

    Test user-agent class.

    Hierarchy (View Summary)

    Index
    _assert: typeof strict | TestContext | undefined = undefined
    _dom: DOM | undefined = undefined
    _finished: [number, string] | null | undefined = undefined
    _messages: AsyncIterableIterator<JSONValue, any, any> | undefined = undefined
    _res: UserAgentResponse | undefined = undefined
    _sse: SSEEvent | undefined = undefined
    _sseEvents: AsyncIterator<SSEEvent, any, any> | undefined = undefined
    _stack: StackUtils = ...
    _ws: WebSocket | undefined = undefined
    baseURL: string | URL | undefined

    Base URL to be used to resolve all relative request URLs with.

    body: Buffer = ...

    Current HTTP response content.

    cookieJar: CookieJar | null = ...

    Cookie jar to use.

    hooks: AsyncHooks = ...

    User-agent hooks.

    httpsTransport: HTTPSTransport = ...

    Transport backend to perform HTTPS requests with.

    httpTransport: HTTPTransport = ...

    Transport backend to perform HTTP requests with.

    maxRedirects: number

    Maximum number of redirects to follow, default to 0.

    name: string | undefined

    Name of user-agent to send with User-Agent header.

    server: Server | undefined = undefined

    Server to use for mock requests.

    wsTransport: WSTransport = ...

    Transport backend to use for WebSocket connections.

    • get _html(): DOM

      Returns DOM

    • get _sseIterator(): AsyncIterator<SSEEvent>

      Returns AsyncIterator<SSEEvent>

    • get sse(): SSEEvent

      Current Server-Sent Event. Note that this property is EXPERIMENTAL and might change without warning!

      Returns SSEEvent

    • get ws(): WebSocket

      Active WebSocket connection.

      Returns WebSocket

    • Parameters

      • values: Record<string, string | Upload> = {}

      Returns FormData

    • Parameters

      Returns void

    • Returns Promise<void>

    • Returns Promise<void>

    • Add a hook to extend the user-agent.

      Parameters

      • name: string
      • fn: UserAgentHook

      Returns this

    • Delegate assertion to test framework currently in use.

      Parameters

      • name: string
      • args: any[]
      • msg: string
      • skip: SkipFunction

      Returns void

    • Check response content for exact match.

      Parameters

      • body: string

      Returns this

    • Opposite of bodyIs.

      Parameters

      • body: string

      Returns this

    • Check response content for similar match.

      Parameters

      • regex: RegExp

      Returns this

    • Opposite of bodyLike.

      Parameters

      • regex: RegExp

      Returns this

    • Wait for WebSocket connection to be closed gracefully and check status.

      Parameters

      • code: number

      Returns Promise<void>

    • Close WebSocket connection gracefully.

      Parameters

      • code: number
      • reason: string

      Returns Promise<void>

    • Destroy all active keep-alive connections.

      Returns Promise<void>

    • Checks for existence of the CSS selectors first matching HTML/XML element.

      Parameters

      • selector: string

      Returns this

    • Opposite of elementExists.

      Parameters

      • selector: string

      Returns this

    • Perform a GET request and check for transport errors, but leave the response body for Server-Sent Events. Note that this method is EXPERIMENTAL and might change without warning!

      Parameters

      Returns Promise<TestUserAgent>

    • Check if response header exists.

      Parameters

      • name: string

      Returns this

    • Opposite of headerExists.

      Parameters

      • name: string

      Returns this

    • Check response header for exact match.

      Parameters

      • name: string
      • value: string

      Returns this

    • Opposite of headerIs.

      Parameters

      • name: string
      • value: string

      Returns this

    • Check response header for similar match.

      Parameters

      • name: string
      • regex: RegExp

      Returns this

    • Check if JSON response contains a value that can be identified using the given JSON Pointer.

      Parameters

      • pointer: string

      Returns this

    • Check the value extracted from JSON response using the given JSON Pointerr, which defaults to the root value if it is omitted.

      Parameters

      Returns this

    • Wait for next WebSocket message to arrive.

      Returns Promise<JSONValue>

    post

    • Perform a POST request and check for transport errors, but leave the response body for Server-Sent Events. Note that this method is EXPERIMENTAL and might change without warning!

      Parameters

      Returns Promise<TestUserAgent>

    • Send message or frame via WebSocket.

      Parameters

      • message: any

      Returns Promise<void>

    • Wait for Server-Sent Events connection to be closed by the server. Note that this method is EXPERIMENTAL and might change without warning!

      Returns Promise<TestUserAgent>

    • Close Server-Sent Events connection. Note that this method is EXPERIMENTAL and might change without warning!

      Returns Promise<TestUserAgent>

    • Check Server-Sent Event id for exact match. Note that this method is EXPERIMENTAL and might change without warning!

      Parameters

      • id: string | null

      Returns this

    • Opposite of sseIdIs. Note that this method is EXPERIMENTAL and might change without warning!

      Parameters

      • id: string | null

      Returns this

    • Wait for next Server-Sent Event to arrive. Note that this method is EXPERIMENTAL and might change without warning!

      Returns Promise<TestUserAgent>

    • Check Server-Sent Event text for exact match. Note that this method is EXPERIMENTAL and might change without warning!

      Parameters

      • text: string

      Returns this

    • Opposite of sseTextIs. Note that this method is EXPERIMENTAL and might change without warning!

      Parameters

      • text: string

      Returns this

    • Check Server-Sent Event text for similar match. Note that this method is EXPERIMENTAL and might change without warning!

      Parameters

      • regex: RegExp

      Returns this

    • Opposite of sseTextLike. Note that this method is EXPERIMENTAL and might change without warning!

      Parameters

      • regex: RegExp

      Returns this

    • Check Server-Sent Event type for exact match. Note that this method is EXPERIMENTAL and might change without warning!

      Parameters

      • type: string

      Returns this

    • Opposite of sseTypeIs. Note that this method is EXPERIMENTAL and might change without warning!

      Parameters

      • type: string

      Returns this

    • Check response status for exact match.

      Parameters

      • status: number

      Returns this

    • Stop mock server.

      Returns Promise<void>

    • Checks text content of the CSS selectors first matching HTML/XML element for similar match.

      Parameters

      • selector: string
      • regex: RegExp

      Returns this

    • Checks text content of the CSS selectors first matching HTML/XML element for no match.

      Parameters

      • selector: string
      • regex: RegExp

      Returns this

    • Check response Content-Type header for exact match.

      Parameters

      • value: string

      Returns this

    • Check response Content-Type header for similar match.

      Parameters

      • regex: RegExp

      Returns this

    • Open a WebSocket connection with transparent handshake.

      Parameters

      Returns Promise<void>

    • Check if YAML response contains a value that can be identified using the given JSON Pointer.

      Parameters

      • pointer: string

      Returns this

    • Check the value extracted from YAML response using the given JSON Pointerr, which defaults to the root value if it is omitted.

      Parameters

      Returns this