A started kernel application
String URL, InjectRequest object, or web Request
The inject response
import { inject } from '@setu-ts/testing';
// String shorthand (GET only)
const res = await inject(app, '/users');
// InjectRequest object
const res2 = await inject(app, {
method: 'POST',
url: '/users',
body: { name: 'test' },
});
// Web Request
const req = new Request('http://localhost/users', {
method: 'POST',
body: JSON.stringify({ name: 'test' }),
});
const res3 = await inject(app, req);
Free-function HTTP request injector with string,
InjectRequest, and web-standardRequestshorthand.A
stringis a URL-only shorthand ({ method: 'GET', url: request }). For non-GET methods, use theInjectRequestobject form directly. A web-standardRequestis normalized field-by-field and delegated toapp.inject()after reading its body. That read consumes the request, so aRequestcannot be injected twice, nor injected and then passed toapp.fetch()— the second call throws rather than silently sending no body. Build a separateRequestper call.