test: guard channel loader jiti mock call · openclaw/openclaw@ff54363
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,6 +26,16 @@ function createTempDir(): string {
|
26 | 26 | return tempDir; |
27 | 27 | } |
28 | 28 | |
| 29 | +function requireCreateJitiCall( |
| 30 | +createJiti: ReturnType<typeof vi.fn>, |
| 31 | +): [string, { tryNative?: boolean }] { |
| 32 | +const call = createJiti.mock.calls.at(0); |
| 33 | +if (!call) { |
| 34 | +throw new Error("expected createJiti call"); |
| 35 | +} |
| 36 | +return call as [string, { tryNative?: boolean }]; |
| 37 | +} |
| 38 | + |
29 | 39 | describe("channel plugin module loader helpers", () => { |
30 | 40 | it("resolves extensionless plugin module specifiers to the first existing extension", () => { |
31 | 41 | const rootDir = createTempDir(); |
@@ -102,9 +112,9 @@ describe("channel plugin module loader helpers", () => {
|
102 | 112 | target: fs.realpathSync.native(modulePath), |
103 | 113 | }); |
104 | 114 | expect(createJiti).toHaveBeenCalledOnce(); |
105 | | -const [loaderFilename, loaderOptions] = createJiti.mock.calls[0] ?? []; |
| 115 | +const [loaderFilename, loaderOptions] = requireCreateJitiCall(createJiti); |
106 | 116 | expect(loaderFilename).toContain("module-loader.ts"); |
107 | | -expect(loaderOptions?.tryNative).toBe(false); |
| 117 | +expect(loaderOptions.tryNative).toBe(false); |
108 | 118 | expect(loadWithJiti).toHaveBeenCalledWith(fs.realpathSync.native(modulePath)); |
109 | 119 | } finally { |
110 | 120 | for (const [extension, hook] of sourceHooks) { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。