test: clarify runtime event assertions

This commit is contained in:
Peter Steinberger
2026-05-08 13:06:18 +01:00
parent e6031fd03a
commit d0f484d024
6 changed files with 9 additions and 12 deletions

View File

@@ -1127,8 +1127,8 @@ describe("Initialization guard", () => {
it("ensureContextEnginesInitialized() is idempotent and registers legacy", async () => {
const { ensureContextEnginesInitialized } = await import("./init.js");
expect(() => ensureContextEnginesInitialized()).not.toThrow();
expect(() => ensureContextEnginesInitialized()).not.toThrow();
expect(ensureContextEnginesInitialized()).toBeUndefined();
expect(ensureContextEnginesInitialized()).toBeUndefined();
const ids = listContextEngineIds();
expect(ids).toContain("legacy");

View File

@@ -234,8 +234,7 @@ describe("GatewayClient security checks", () => {
onConnectError,
});
// Should not throw
expect(() => client.start()).not.toThrow();
expect(client.start()).toBeUndefined();
expectSecurityConnectError(onConnectError);
expect(wsInstances.length).toBe(0); // No WebSocket created
@@ -535,9 +534,7 @@ describe("GatewayClient close handling", () => {
const client = createClientWithIdentity("dev-2", onClose);
client.start();
expect(() => {
getLatestWs().emitClose(1008, "unauthorized: device token mismatch");
}).not.toThrow();
expect(getLatestWs().emitClose(1008, "unauthorized: device token mismatch")).toBeUndefined();
expect(logDebugMock).toHaveBeenCalledWith(
expect.stringContaining("failed clearing stale device-auth token"),

View File

@@ -210,7 +210,7 @@ describe("GatewayClient", () => {
});
try {
expect(() => client.start()).not.toThrow();
expect(client.start()).toBeUndefined();
await connected;
expect(onConnectError).not.toHaveBeenCalled();
} finally {

View File

@@ -552,6 +552,6 @@ describe("talk realtime gateway relay", () => {
expect(() => createSession("conn-1")).toThrow(
"Too many active realtime relay sessions for this connection",
);
expect(() => createSession("conn-2")).not.toThrow();
expect(createSession("conn-2")).toBeDefined();
});
});

View File

@@ -177,7 +177,7 @@ describe("enableConsoleCapture", () => {
enableConsoleCapture();
const epipe = new Error("write EPIPE") as NodeJS.ErrnoException;
epipe.code = "EPIPE";
expect(() => stream.emit("error", epipe)).not.toThrow();
expect(stream.emit("error", epipe)).toBe(true);
});
it("rethrows non-EPIPE errors on stdout", () => {

View File

@@ -48,12 +48,12 @@ describe("session lifecycle events", () => {
const unsubscribeNoisy = onSessionLifecycleEvent(noisy.listener);
const unsubscribeHealthy = onSessionLifecycleEvent(healthy.listener);
expect(() =>
expect(
emitSessionLifecycleEvent({
sessionKey: "agent:main:main",
reason: "resumed",
}),
).not.toThrow();
).toBeUndefined();
expect(noisy.calls).toHaveLength(1);
expect(healthy.calls).toHaveLength(1);