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

x/superoak/deps.ts>Test

HTTP assertions for Oak made easy via SuperDeno. 🐿 🦕
Latest
class Test
extends SuperRequest
import { Test } from "https://deno.land/x/superoak@4.8.1/deps.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)