

























@@ -8,6 +8,14 @@ describe("plugin lifecycle trace", () => {
88const originalTraceEnv = process.env.OPENCLAW_PLUGIN_LIFECYCLE_TRACE;
99let errorSpy: ReturnType<typeof vi.spyOn>;
101011+function requireErrorMessage(index = 0): unknown {
12+const call = errorSpy.mock.calls.at(index);
13+if (!call) {
14+throw new Error(`expected console.error call ${index}`);
15+}
16+return call[0];
17+}
18+1119beforeEach(() => {
1220errorSpy = vi.spyOn(console, "error").mockImplementation(() => undefined);
1321});
@@ -40,7 +48,7 @@ describe("plugin lifecycle trace", () => {
4048).toBe(42);
41494250expect(errorSpy).toHaveBeenCalledTimes(1);
43-expect(errorSpy.mock.calls[0]?.[0]).toMatch(
51+expect(requireErrorMessage()).toMatch(
4452/^\[plugins:lifecycle\] phase="config read" ms=\d+\.\d{2} status=ok command="inspect" includeDisabled=true$/,
4553);
4654});
@@ -56,7 +64,7 @@ describe("plugin lifecycle trace", () => {
5664).toThrow(error);
57655866expect(errorSpy).toHaveBeenCalledTimes(1);
59-expect(errorSpy.mock.calls[0]?.[0]).toMatch(
67+expect(requireErrorMessage()).toMatch(
6068/^\[plugins:lifecycle\] phase="registry refresh" ms=\d+\.\d{2} status=error$/,
6169);
6270});
@@ -72,7 +80,7 @@ describe("plugin lifecycle trace", () => {
7280).rejects.toThrow(error);
73817482expect(errorSpy).toHaveBeenCalledTimes(1);
75-expect(errorSpy.mock.calls[0]?.[0]).toMatch(
83+expect(requireErrorMessage()).toMatch(
7684/^\[plugins:lifecycle\] phase="manifest registry" ms=\d+\.\d{2} status=error$/,
7785);
7886});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。