

























@@ -19,7 +19,11 @@ plugins.
19192020## Test utilities
212122-**Import:** `openclaw/plugin-sdk/testing`
22+**General import:** `openclaw/plugin-sdk/testing`
23+24+**Plugin API mock import:** `openclaw/plugin-sdk/plugin-test-api`
25+26+**Channel contract import:** `openclaw/plugin-sdk/channel-contract-testing`
23272428The testing subpath exports a narrow set of helpers for plugin authors:
2529@@ -29,44 +33,51 @@ import {
2933shouldAckReaction,
3034removeAckReactionAfterReply,
3135} from "openclaw/plugin-sdk/testing";
36+import { createTestPluginApi } from "openclaw/plugin-sdk/plugin-test-api";
37+import { expectChannelInboundContextContract } from "openclaw/plugin-sdk/channel-contract-testing";
3238```
33393440### Available exports
354136-| Export | Purpose |
37-| ------------------------------------------- | ------------------------------------------------------- |
38-| `installCommonResolveTargetErrorCases` | Shared test cases for target resolution error handling |
39-| `shouldAckReaction` | Check whether a channel should add an ack reaction |
40-| `removeAckReactionAfterReply` | Remove ack reaction after reply delivery |
41-| `createTestRegistry` | Build a channel plugin registry fixture |
42-| `createEmptyPluginRegistry` | Build an empty plugin registry fixture |
43-| `setActivePluginRegistry` | Install a registry fixture for plugin runtime tests |
44-| `createRequestCaptureJsonFetch` | Capture JSON fetch requests in media helper tests |
45-| `withFetchPreconnect` | Run fetch tests with preconnect hooks installed |
46-| `withEnv` / `withEnvAsync` | Temporarily patch environment variables |
47-| `createTempHomeEnv` / `withTempDir` | Create isolated filesystem test fixtures |
48-| `createMockServerResponse` | Create a minimal HTTP server response mock |
49-| `registerSingleProviderPlugin` | Register one provider plugin in loader smoke tests |
50-| `registerProviderPlugin` | Capture all provider kinds from one plugin |
51-| `registerProviderPlugins` | Capture provider registrations across multiple plugins |
52-| `requireRegisteredProvider` | Assert that a provider collection contains an id |
53-| `runProviderCatalog` | Execute a provider catalog hook with test dependencies |
54-| `resolveProviderWizardOptions` | Resolve provider setup wizard choices in contract tests |
55-| `resolveProviderModelPickerEntries` | Resolve provider model-picker entries in contract tests |
56-| `buildProviderPluginMethodChoice` | Build provider wizard choice ids for assertions |
57-| `setProviderWizardProvidersResolverForTest` | Inject provider wizard providers for isolated tests |
58-| `createProviderUsageFetch` | Build provider usage fetch fixtures |
59-| `useFrozenTime` / `useRealTime` | Freeze and restore timers for time-sensitive tests |
60-| `createRuntimeEnv` | Build a mocked CLI/plugin runtime environment |
61-| `createTestWizardPrompter` | Build a mocked setup wizard prompter |
62-| `createPluginSetupWizardStatus` | Build setup status helpers for channel plugins |
63-| `createRuntimeTaskFlow` | Create isolated runtime task-flow state |
64-| `typedCases` | Preserve literal types for table-driven tests |
65-66-Bundled-plugin contract suites also use this subpath for test-only registry,
67-manifest, public-artifact, and runtime fixture helpers. Keep new extension tests
68-on `openclaw/plugin-sdk/testing` or a narrower documented SDK subpath rather
69-than importing repo `src/**` files directly.
42+| Export | Purpose |
43+| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
44+| `createTestPluginApi` | Build a minimal plugin API mock for direct registration unit tests. Import from `plugin-sdk/plugin-test-api` |
45+| `expectChannelInboundContextContract` | Assert channel inbound context shape. Import from `plugin-sdk/channel-contract-testing` |
46+| `installChannelOutboundPayloadContractSuite` | Install channel outbound payload contract cases. Import from `plugin-sdk/channel-contract-testing` |
47+| `installCommonResolveTargetErrorCases` | Shared test cases for target resolution error handling |
48+| `shouldAckReaction` | Check whether a channel should add an ack reaction |
49+| `removeAckReactionAfterReply` | Remove ack reaction after reply delivery |
50+| `createTestRegistry` | Build a channel plugin registry fixture |
51+| `createEmptyPluginRegistry` | Build an empty plugin registry fixture |
52+| `setActivePluginRegistry` | Install a registry fixture for plugin runtime tests |
53+| `createRequestCaptureJsonFetch` | Capture JSON fetch requests in media helper tests |
54+| `withFetchPreconnect` | Run fetch tests with preconnect hooks installed |
55+| `withEnv` / `withEnvAsync` | Temporarily patch environment variables |
56+| `createTempHomeEnv` / `withTempDir` | Create isolated filesystem test fixtures |
57+| `createMockServerResponse` | Create a minimal HTTP server response mock |
58+| `registerSingleProviderPlugin` | Register one provider plugin in loader smoke tests |
59+| `registerProviderPlugin` | Capture all provider kinds from one plugin |
60+| `registerProviderPlugins` | Capture provider registrations across multiple plugins |
61+| `requireRegisteredProvider` | Assert that a provider collection contains an id |
62+| `runProviderCatalog` | Execute a provider catalog hook with test dependencies |
63+| `resolveProviderWizardOptions` | Resolve provider setup wizard choices in contract tests |
64+| `resolveProviderModelPickerEntries` | Resolve provider model-picker entries in contract tests |
65+| `buildProviderPluginMethodChoice` | Build provider wizard choice ids for assertions |
66+| `setProviderWizardProvidersResolverForTest` | Inject provider wizard providers for isolated tests |
67+| `createProviderUsageFetch` | Build provider usage fetch fixtures |
68+| `useFrozenTime` / `useRealTime` | Freeze and restore timers for time-sensitive tests |
69+| `createRuntimeEnv` | Build a mocked CLI/plugin runtime environment |
70+| `createTestWizardPrompter` | Build a mocked setup wizard prompter |
71+| `createPluginSetupWizardStatus` | Build setup status helpers for channel plugins |
72+| `createRuntimeTaskFlow` | Create isolated runtime task-flow state |
73+| `typedCases` | Preserve literal types for table-driven tests |
74+75+Bundled-plugin contract suites also use SDK testing subpaths for test-only
76+registry, manifest, public-artifact, and runtime fixture helpers. Keep new
77+extension tests on `openclaw/plugin-sdk/testing` or a narrower documented SDK
78+subpath such as `plugin-sdk/plugin-test-api` or
79+`plugin-sdk/channel-contract-testing` rather than importing repo `src/**` files
80+directly.
70817182### Types
7283此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。