Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Test

The SuperDeno Test object extends the methods provided by superagent to provide a high-level abstraction for testing HTTP, while still allowing you to drop down to the lower-level API provided by superagent.

Hierarchy

Index

Constructors

constructor

Properties

Private #asserts

#asserts: any[]

Private #redirectList

#redirectList: string[]

Private #redirects

#redirects: number

Private #server

#server: ServerLike

Private #serverSetupPromise

#serverSetupPromise: Promise<void>

Private #urlSetupPromise

#urlSetupPromise: Promise<void>

app

app: string | ListenerLike | ServerLike

cookies

cookies: string

method

method: string

url

url: string

Methods

Private #assert

Private #assertBody

Private #assertFunction

Private #assertHeader

  • #assertHeader(header: { name: string; value: string | number | RegExp }, res: IResponse): Error | void

Private #assertStatus

Private #redirect

Private #setServerAddress

  • #setServerAddress(addressSetupPromiseResolver: () => void, path: string, host?: string, secure?: boolean): Promise<void>
  • Returns a URL, extracted from a server.

    Parameters

    • addressSetupPromiseResolver: () => void
        • (): void
        • Returns void

    • path: string
    • Optional host: string
    • Optional secure: boolean

    Returns Promise<void>

    URL address

abort

  • abort(): void

accept

  • accept(type: string): this

agent

  • agent(agent?: any): this

attach

  • attach(field: string, file: MultipartValueSingle, options?: string | { contentType?: string; filename?: string }): this

auth

  • auth(user: string, pass: string, options?: { type: "basic" | "auto" }): this
  • auth(token: string, options: { type: "bearer" }): this

buffer

  • buffer(val?: boolean): this

ca

  • ca(cert: any | any[]): this

catch

  • catch<TResult>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<IResponse | TResult>
  • Attaches a callback for only the rejection of the Promise.

    Type parameters

    • TResult = never

    Parameters

    • Optional onrejected: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null

      The callback to execute when the Promise is rejected.

    Returns Promise<IResponse | TResult>

    A Promise for the completion of the callback.

cert

  • cert(cert: any | any[]): this

clearTimeout

  • clearTimeout(): this

disableTLSCerts

  • disableTLSCerts(): this

end

expect

field

  • field(name: string, val: MultipartValue): this
  • field(fields: {}): this

get

  • get(field: string): string

http2

  • http2(enable?: boolean): this

key

  • key(cert: any | any[]): this

maxResponseSize

  • maxResponseSize(size: number): this

ok

  • ok(callback: (res: IResponse) => boolean): this

on

  • on(name: "error", handler: (err: any) => void): this
  • on(name: "progress", handler: (event: ProgressEvent) => void): this
  • on(name: "response", handler: (response: IResponse) => void): this
  • on(name: string, handler: (event: any) => void): this

parse

part

  • part(): this

pfx

  • pfx(cert: any | any[] | { passphrase: string; pfx: string | any }): this

pipe

  • pipe(stream: any, options?: object): any

query

  • query(val: object | string): this

redirects

  • redirects(n: number): this

responseType

  • responseType(type: string): this

retry

send

  • send(data?: string | object): this

serialize

set

  • set(field: object): this
  • set(field: string, val: string): this
  • set(field: "Cookie", val: string[]): this

then

  • then<TResult1, TResult2>(onfulfilled?: ((value: IResponse) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>
  • Attaches callbacks for the resolution and/or rejection of the Promise.

    Type parameters

    • TResult1 = IResponse

    • TResult2 = never

    Parameters

    • Optional onfulfilled: ((value: IResponse) => TResult1 | PromiseLike<TResult1>) | undefined | null

      The callback to execute when the Promise is resolved.

    • Optional onrejected: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null

      The callback to execute when the Promise is rejected.

    Returns Promise<TResult1 | TResult2>

    A Promise for the completion of which ever callback is executed.

timeout

  • timeout(ms: number | { deadline?: number; response?: number }): this

trustLocalhost

  • trustLocalhost(enabled?: boolean): this

type

  • type(val: string): this

unset

  • unset(field: string): this

use

withCredentials

  • withCredentials(): this

write

  • write(data: string | any, encoding?: string): boolean

Generated using TypeDoc