Skip to content

Commit 44027e7

Browse files
committed
test(agents): narrow bounded error assertions
1 parent d1bca0c commit 44027e7

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/agents/minimax-vlm.normalizes-api-key.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,11 @@ describe("minimaxUnderstandImage apiKey normalization", () => {
178178
prompt: "hi",
179179
imageDataUrl: "data:image/png;base64,AAAA",
180180
apiHost: "https://api.minimax.io",
181-
}).catch((caught: unknown) => caught as Error);
181+
}).catch((caught: unknown) => caught);
182182

183-
expect(error).toBeInstanceOf(Error);
183+
if (!(error instanceof Error)) {
184+
throw new Error("expected MiniMax VLM request to throw an Error");
185+
}
184186
expect(error.message).toContain("MiniMax VLM request failed");
185187
expect(error.message).toContain("Trace-Id: trace-123");
186188
expect(error.message).not.toContain("tail-marker");

src/agents/tools/pdf-native-providers.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,11 @@ describe("native PDF provider API calls", () => {
131131

132132
const error = await pdfNativeProviders
133133
.anthropicAnalyzePdf(makeAnthropicAnalyzeParams())
134-
.catch((caught: unknown) => caught as Error);
134+
.catch((caught: unknown) => caught);
135135

136-
expect(error).toBeInstanceOf(Error);
136+
if (!(error instanceof Error)) {
137+
throw new Error("expected Anthropic PDF request to throw an Error");
138+
}
137139
expect(error.message).toContain("Anthropic PDF request failed");
138140
expect(error.message).not.toContain("tail-marker");
139141
expect(error.message.length).toBeLessThan(500);
@@ -160,13 +162,15 @@ describe("native PDF provider API calls", () => {
160162
const error = await Promise.race([
161163
pdfNativeProviders
162164
.anthropicAnalyzePdf(makeAnthropicAnalyzeParams())
163-
.catch((caught: unknown) => caught as Error),
165+
.catch((caught: unknown) => caught),
164166
new Promise<Error>((_resolve, reject) => {
165167
setTimeout(() => reject(new Error("timed out waiting for bounded error body")), 500);
166168
}),
167169
]);
168170

169-
expect(error).toBeInstanceOf(Error);
171+
if (!(error instanceof Error)) {
172+
throw new Error("expected Anthropic PDF request to throw an Error");
173+
}
170174
expect(error.message).toContain("Anthropic PDF request failed");
171175
expect(canceled).toBe(true);
172176
});

0 commit comments

Comments
 (0)