Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/superdeno/mod.ts>Test

Super-agent driven library for testing Deno HTTP servers.
Latest
class Test
extends SuperRequest
import { Test } from "https://deno.land/x/superdeno@4.9.0/mod.ts";

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.

Constructors

new
Test(
app: string | ListenerLike | ServerLike,
method: string,
path: string,
host?: string,
secure?: boolean,
)

Properties

app: string | ListenerLike | ServerLike
url: string

Methods

end(callback?: CallbackHandler): this

Defer invoking superagent's .end() until the server is listening.

expect(callback: ExpectChecker): this

Expectations:

.expect(fn)

expect(status: number, callback?: CallbackHandler): this

Expectations:

.expect(200) .expect(200, fn)

expect(
status: number,
body: any,
callback?: CallbackHandler,
): this

Expectations:

.expect(200, body) .expect(200, body, fn)

expect(body: string | RegExp | Object, callback?: CallbackHandler): this

Expectations:

.expect('Some body') .expect(/Some body/i) .expect('Some body', fn)

expect(
field: string,
value: string | RegExp | number,
callback?: CallbackHandler,
): this

Expectations:

.expect('Content-Type', 'application/json') .expect('Content-Type', /application/g', fn)