From fc45f9cd313d22d260a91eabd978793343e06b8c Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Wed, 29 Jan 2025 13:51:27 -0500 Subject: [PATCH] Throw error if mock not found --- packages/vertexai/test-utils/mock-response.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/vertexai/test-utils/mock-response.ts b/packages/vertexai/test-utils/mock-response.ts index 8332d9eb36e..9b42c93427b 100644 --- a/packages/vertexai/test-utils/mock-response.ts +++ b/packages/vertexai/test-utils/mock-response.ts @@ -49,6 +49,9 @@ export function getMockResponseStreaming( filename: string, chunkLength: number = 20 ): Partial { + if (!(filename in mocksLookup)) { + throw Error(`Mock response file '${filename}' not found.`); + } const fullText = mocksLookup[filename]; return { @@ -57,6 +60,9 @@ export function getMockResponseStreaming( } export function getMockResponse(filename: string): Partial { + if (!(filename in mocksLookup)) { + throw Error(`Mock response file '${filename}' not found.`); + } const fullText = mocksLookup[filename]; return { ok: true,