From ed6db3cd23dd8963a613585b6879067c57ee87de Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 12 May 2026 05:41:13 +0100 Subject: [PATCH] test: guard plugin services mock call --- src/plugins/services.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/services.test.ts b/src/plugins/services.test.ts index 9b49e971cd6..3844ba5067d 100644 --- a/src/plugins/services.test.ts +++ b/src/plugins/services.test.ts @@ -78,6 +78,14 @@ function expectServiceLifecycleState(params: { expectServiceContexts(params.contexts, params.config); } +function requireLoggerErrorMessage(index = 0): string { + const call = mockedLogger.error.mock.calls.at(index); + if (!call) { + throw new Error(`expected logger error call ${index}`); + } + return call[0]; +} + async function startTrackingServices(params: { services: OpenClawPluginService[]; config?: Parameters[0]["config"]; @@ -174,7 +182,7 @@ describe("startPluginServices", () => { "plugin service failed (service-start-fail, plugin=plugin:test, root=/plugins/test-plugin): start failed", ], ]); - expect(mockedLogger.error.mock.calls[0]?.[0]).not.toContain("\n"); + expect(requireLoggerErrorMessage()).not.toContain("\n"); expect(mockedLogger.warn.mock.calls).toEqual([ ["plugin service stop failed (service-stop-fail): Error: stop failed"], ]);