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"], ]);