Stone.js API
    Preparing search index...

    Type Alias TestResponse<ResponseType>

    TestResponse: ResponseType & {
        html: () => string;
        json: <T = unknown>() => T;
        text: () => string;
    }

    An outgoing response with the readers a test always needs.

    content is the wire payload: a JSON string for an API, an HTML string for a rendered page. Every project ends up writing the same JSON.parse(response.content) helper; these are that helper, once, for both kinds of application.

    Type Parameters

    • ResponseType extends OutgoingResponse = OutgoingResponse

    Type Declaration

    • html: () => string

      The body as text. An alias for text, for when the body is a rendered page.

    • json: <T = unknown>() => T

      The body as data: parsed when it is a JSON string, returned as-is when it is already a value.

    • text: () => string

      The body as text.

      This is what a frontend app answers with: a rendered page is an HTML string, so an integration test asserts on it directly. For querying that HTML rather than matching it, parse it with whatever you already use (happy-dom, jsdom, Testing Library) — there is no assertion library here, on purpose.