Stratal API Reference
    Preparing search index...

    Class TestHttpRequest

    TestHttpRequest

    Request builder with fluent API for configuring test HTTP requests.

    const response = await module.http
    .post('/api/v1/register')
    .withBody({ name: 'Test School' })
    .withHeaders({ 'X-Custom': 'value' })
    .send()
    const response = await module.http
    .get('/api/v1/profile')
    .actingAs({ id: user.id })
    .send()

    Hierarchy

    • Macroable
      • TestHttpRequest

    Indexable

    • [key: string | symbol]: unknown
    Index

    Constructors

    Properties

    actingAsUser: { id: string } | null = null
    authResolver:
        | ((module: TestingModule, user: { id: string }) => Promise<Headers>)
        | null = null
    body: unknown = null
    host: string | null = null
    localeConfig: { locale: string; strategy: DetectionStrategy } | null
    method: string
    path: string
    requestHeaders: Headers
    getterNames: Set<string | symbol>

    Names registered via getter() — used by hasMacro() and flushMacros().

    instanceMacros: Set<{ key: string | symbol; value: unknown }>

    Per-instance properties. Each entry is applied and bound to this inside the constructor so destructuring stays safe.

    macroNames: Set<string | symbol>

    Names registered via macro() — used by hasMacro() and flushMacros().

    Methods

    • Set the locale for this request. If strategy is not provided, resolves from the module's I18n configuration.

      Parameters

      • locale: string

        Locale code (e.g., 'en', 'fr')

      • Optionalstrategy: DetectionStrategy

        Detection strategy override

      Returns this

    • Remove all macros, instance properties, and getters registered on this class. Does not affect parent classes.

      Returns void

    • Register a computed getter on the class prototype.

      Type Parameters

      • T extends Constructor
      • K extends string | number | symbol

      Parameters

      • this: T
      • name: K

        Property name

      • accumulator: (this: InstanceType<T>) => InstanceType<T>[K]

        Function that computes the value (called with instance as this)

      • Optionalsingleton: boolean

        If true, cache the value after first access

      Returns void

    • Register a computed getter on the class prototype.

      Parameters

      • name: string | symbol

        Property name

      • accumulator: MacroFunction

        Function that computes the value (called with instance as this)

      • Optionalsingleton: boolean

        If true, cache the value after first access

      Returns void

    • Check if a macro, instance property, or getter is registered.

      Parameters

      • name: string | symbol

        Name to check

      Returns boolean

    • Register a per-instance property that is bound to this in the constructor. Safe for destructuring.

      When the name matches an existing property, the value type is auto-derived.

      Type Parameters

      • T extends Constructor
      • K extends string | number | symbol

      Parameters

      • this: T
      • name: K

        Property name

      • value: InstanceType<T>[K]

        Function (will be bound) or value

      Returns void

    • Register a per-instance property that is bound to this in the constructor. Safe for destructuring.

      When the name matches an existing property, the value type is auto-derived.

      Parameters

      • name: string | symbol

        Property name

      • value: unknown

        Function (will be bound) or value

      Returns void

    • Register a macro on the class prototype. Can override existing methods.

      When the name matches an existing property, the value type is auto-derived.

      Type Parameters

      • T extends Constructor
      • K extends string | number | symbol

      Parameters

      • this: T
      • name: K

        Method or property name

      • value: InstanceType<T>[K]

        Function or value to assign

      Returns void

    • Register a macro on the class prototype. Can override existing methods.

      When the name matches an existing property, the value type is auto-derived.

      Parameters

      • name: string | symbol

        Method or property name

      • value: unknown

        Function or value to assign

      Returns void