For AI agents: the complete documentation index is available at https://scriptedalchemy.github.io/agent-bundle/zh/llms.txt, the full documentation bundle is available at https://scriptedalchemy.github.io/agent-bundle/zh/llms-full.txt, and this page is available as Markdown at https://scriptedalchemy.github.io/agent-bundle/zh/api/rstest.md.
跳至主要内容
  • 简体中文
  • Module: rstest

    Info

    API 参考仅提供英文版本;正文与英文站点相同。

    Interfaces

    AgentBundleBrowserRstestConfig

    Properties

    browser

    browser: object

    enabled

    enabled: true

    headless

    headless: true

    provider

    provider: "playwright"

    providerOptions

    providerOptions: object

    providerOptions.launch

    launch: object

    providerOptions.launch.channel

    channel: "chrome"

    viewport

    viewport: object

    viewport.height

    height: 900

    viewport.width

    width: 1440

    include

    include: string[]

    resolve

    resolve: object

    Routes the reserved agent-bundle/meta specifier to the generated identity module.

    alias

    alias: object

    Index Signature

    [specifier: string]: string

    setupFiles

    setupFiles: string[]

    source?

    optional source?: object

    tsconfigPath

    tsconfigPath: string

    tools

    tools: object

    rspack

    rspack: object

    rspack.resolve

    resolve: object

    rspack.resolve.extensionAlias

    extensionAlias: object

    rspack.resolve.extensionAlias..js

    .js: string[]

    rspack.resolve.extensionAlias..jsx

    .jsx: string[]

    swc

    swc: object

    swc.jsc

    jsc: object

    swc.jsc.transform

    transform: object

    swc.jsc.transform.react

    react: object

    swc.jsc.transform.react.runtime

    runtime: "automatic"


    AgentBundleBrowserRstestOptions

    Properties

    configPath?

    readonly optional configPath?: string

    Explicit Agent Bundle configuration path; discovered from root when omitted.

    include?

    readonly optional include?: readonly string[]

    Test files for the browser-app level; defaults to tests/browser-app/**.

    root?

    readonly optional root?: string

    Project root; defaults to the working directory Rstest was started in.

    setupFiles?

    readonly optional setupFiles?: readonly string[]

    Extra setup files, appended after the generated browser registry.

    target?

    readonly optional target?: string

    Mounts every app as this host: the preview profile and the binding's target the page sees. By default each app mounts as its first declared target that the project also selects. The apps themselves are compiled once for the project's whole selection, as the build stages them (#555) — the host is projection context for the harness, never part of the compiled bytes (#592).


    AgentBundleRstestConfig

    The Rstest configuration for the route-unit proof level. Mutable array and literal member types keep the result directly assignable to Rstest's own config type without this package depending on @rstest/core.

    Properties

    include

    include: string[]

    pool

    pool: object

    execArgv

    execArgv: string[]

    type

    type: "forks"

    resolve

    resolve: object

    Routes the reserved agent-bundle/meta specifier to the generated identity module.

    alias

    alias: object

    Index Signature

    [specifier: string]: string

    setupFiles

    setupFiles: string[]

    source?

    optional source?: object

    tsconfigPath

    tsconfigPath: string

    testEnvironment

    testEnvironment: "node"

    tools

    tools: object

    rspack

    rspack: object

    rspack.resolve

    resolve: object

    rspack.resolve.conditionNames

    conditionNames: string[]

    swc

    swc: object

    swc.jsc

    jsc: object

    swc.jsc.transform

    transform: object

    swc.jsc.transform.react

    react: object

    swc.jsc.transform.react.runtime

    runtime: "automatic"


    AgentBundleRstestOptions

    Properties

    configPath?

    readonly optional configPath?: string

    Explicit Agent Bundle configuration path; discovered from root when omitted.

    include?

    readonly optional include?: readonly string[]

    Test files for the route-unit level; defaults to tests/route-unit/**.

    root?

    readonly optional root?: string

    Project root; defaults to the working directory Rstest was started in.

    setupFiles?

    readonly optional setupFiles?: readonly string[]

    Extra setup files, appended after the generated route registry.


    AgentBundleTestManifest

    What the compiler tells the test harness about one project: the route and MCP App inventories, the project identity its generated servers advertise, the selected targets, and the compiler's own diagnostics. Artifact descriptors arrive with the stage that can honestly prove them.

    Properties

    apps

    readonly apps: Readonly<Record<string, TestableAppDescriptor>>

    Collision-checked MCP App declarations from the same compiler pass.

    cliCommands

    readonly cliCommands: readonly CompiledCliCommand[]

    The collision-checked routed-CLI command graph (#102 stage 2) from the same pass, so the CLI dispatch level drives the product's own dispatcher over the product's own commands instead of resolving argv itself. Empty when the project compiles no src/cli/** commands.

    configPath?

    readonly optional configPath?: string

    The absolute config path the compiler pass evaluated.

    diagnostics

    readonly diagnostics: readonly Diagnostic[]

    Diagnostics from the same pass, so a harness failure can name a compiler cause.

    digest

    readonly digest: string

    The route graph digest: project-relative route identity, equal on every machine.

    eventRuntimeServerId?

    readonly optional eventRuntimeServerId?: string

    Generated MCP server that owns the shared event runtime, when event routes and a generated server coexist.

    layouts

    readonly layouts: readonly TestableLayoutDescriptor[]

    Conventional layouts from the same pass, ordered by id; empty when the project declares none.

    plugin

    readonly plugin: TestManifestPluginIdentity

    Plugin name and version, as the generated MCP server reports them in initialize.

    projectRoot

    readonly projectRoot: string

    proofLevel

    readonly proofLevel: AgentTestProofLevel

    The level the manifest and its registered loaders alone supply; every other level stamps its own.

    providers?

    readonly optional providers?: readonly TestableProviderDescriptor[]

    Conventional request context providers, in the execution order every generated request scope uses; the harness mounts them automatically unless a test passes context.providers. Absent when the project declares none.

    routes

    readonly routes: Readonly<Record<string, TestableRouteDescriptor>>

    scripts

    readonly scripts: readonly TestableScriptDescriptor[]

    The conventional src/scripts/* modules from the same pass, collision- checked by name, so the script-dispatch level runs the product's own script contract instead of guessing at file extensions. Empty when the project compiles no conventional scripts.

    state?

    readonly optional state?: TestableStateDescriptor

    Conventional project state mounted automatically for manifest route renders.

    targets

    readonly targets: readonly string[]

    Host targets the project selected. Route-unit rendering is target-neutral; these name the projection surfaces a later proof level owns.


    TestableProviderDescriptor

    One conventional src/providers/<name>.ts context provider the harness mounts for every manifest request scope, exactly as the generated entries do (#313). key is the camel-cased request-context key.

    Properties

    id

    readonly id: string

    key

    readonly key: string

    name

    readonly name: string

    relativePath

    readonly relativePath: string

    Project-relative POSIX path of the provider module.

    source

    readonly source: string

    Absolute provider module path.


    TestableRouteDescriptor

    One compiled route the harness can address, with the identity its diagnostics report.

    Properties

    config

    readonly config: Readonly<Record<string, unknown>>

    The route module's statically extracted config export; {} when absent.

    event?

    readonly optional event?: "session/start" | "tool/before" | "tool/after" | "stop" | "agent/start" | "agent/stop" | "workspace/open" | "session/end" | "prompt/submit" | "tool/failure" | "compact/before" | "compact/after" | "permission/request" | "permission/denied" | "stop/failure" | "file/change" | "config/change" | "task/create" | "task/complete" | "agent/idle" | "model-switch/before" | "model-switch/after"

    Canonical event identity; present only for event routes.

    id

    readonly id: string

    kind

    readonly kind: CompiledRouteKind

    relativePath

    readonly relativePath: string

    Project-relative POSIX path of the route module.

    serverId?

    readonly optional serverId?: string

    The owning MCP server id (mcp:<name>); MCP route kinds only.

    source

    readonly source: string

    Absolute route module path.


    TestableStateDescriptor

    The conventional state module the generated route-unit registry can load.

    Properties

    id

    readonly id: string

    lifetime

    readonly lifetime: "request" | "process" | "workspace-durable"

    relativePath

    readonly relativePath: string

    source

    readonly source: string

    Variables

    agentBundleBrowserRstest

    const agentBundleBrowserRstest: (options?) => Promise<AgentBundleBrowserRstestConfig>

    Parameters

    options?

    AgentBundleBrowserRstestOptions

    Returns

    Promise<AgentBundleBrowserRstestConfig>


    agentBundleRstest

    const agentBundleRstest: (options?) => Promise<AgentBundleRstestConfig>

    Builds the Rstest configuration for a consumer project's route-unit tests.

    One compiler pass runs here — the same preparation the build and inspect use, which owns route-graph compilation — and its manifest configures the pool, the test environment, the TypeScript transform, and the generated route registry the helpers in agent-bundle/test read. No artifact is built.

    The same pass supplies the project identity, so the configuration aliases agent-bundle/meta to a generated module carrying exactly the { name, packageName, packageVersion, version } a build would stamp: any source module importing it loads under the pool instead of raising AB4760. When preparation produced no plugin model there is no identity to stamp, and the aliased module throws AB4760 naming the compiler diagnostics instead of serving the manifest placeholder.

    import { defineConfig } from '@rstest/core';
    import { agentBundleRstest } from 'agent-bundle/rstest';
    
    export default defineConfig(await agentBundleRstest());

    This configuration carries the route-unit level only. Transport, browser, and packed-artifact proof levels arrive as their own configurations.

    Parameters

    options?

    AgentBundleRstestOptions

    Returns

    Promise<AgentBundleRstestConfig>