Skip to content

basalt / testing/src / TestApp

Class: TestApp<Res> ​

Defined in: testing/src/app.ts:216

Type Parameters ​

Res ​

Res extends TestResponse = LightMyRequestResponse

Constructors ​

Constructor ​

> new TestApp<Res>(app, driver?): TestApp<Res>

Defined in: testing/src/app.ts:221

Parameters ​

app ​

BasaltApp

driver? ​

ConnectedDriver

Returns ​

TestApp<Res>

Properties ​

app ​

> readonly app: BasaltApp

Defined in: testing/src/app.ts:221

Accessors ​

container ​

Get Signature ​

> get container(): Container

Defined in: testing/src/app.ts:225

Returns ​

Container

Methods ​

actingAs() ​

> actingAs(user): this

Defined in: testing/src/app.ts:244

Sets the default authenticated user for subsequent requests.

Parameters ​

user ​

TestActor

Returns ​

this


asTenant() ​

> asTenant(tenant): this

Defined in: testing/src/app.ts:250

Sets the default tenant for subsequent requests.

Parameters ​

tenant ​

string | { id: string; }

Returns ​

this


delete() ​

> delete(url, options?): Promise<Res>

Defined in: testing/src/app.ts:292

Parameters ​

url ​

string

options? ​

TestRequestOptions

Returns ​

Promise<Res>


get() ​

> get(url, options?): Promise<Res>

Defined in: testing/src/app.ts:280

Parameters ​

url ​

string

options? ​

TestRequestOptions

Returns ​

Promise<Res>


patch() ​

> patch(url, payload?, options?): Promise<Res>

Defined in: testing/src/app.ts:289

Parameters ​

url ​

string

payload? ​

unknown

options? ​

TestRequestOptions

Returns ​

Promise<Res>


post() ​

> post(url, payload?, options?): Promise<Res>

Defined in: testing/src/app.ts:283

Parameters ​

url ​

string

payload? ​

unknown

options? ​

TestRequestOptions

Returns ​

Promise<Res>


put() ​

> put(url, payload?, options?): Promise<Res>

Defined in: testing/src/app.ts:286

Parameters ​

url ​

string

payload? ​

unknown

options? ​

TestRequestOptions

Returns ​

Promise<Res>


request() ​

> request(method, url, options?): Promise<Res>

Defined in: testing/src/app.ts:255

Parameters ​

method ​

NonNullable<HTTPMethods | undefined>

url ​

string

options? ​

TestRequestOptions = {}

Returns ​

Promise<Res>


server() ​

> server(): Promise<FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>>

Defined in: testing/src/app.ts:238

The raw Fastify instance — only meaningful on the default adapter; on Express/Hono resolve the EXPRESS/HONO token from container instead.

Asynchronous because @basaltkit/fastify is an optional peer and is imported on demand. That is what stops a version skew from putting a second copy in the tree, with a second FASTIFY token that the application's fastifyPlugin never registered.

Returns ​

Promise<FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>>


shutdown() ​

> shutdown(): Promise<void>

Defined in: testing/src/app.ts:296

Returns ​

Promise<void>

Released under the MIT License.