File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
packages/ai/__tests__/test-utils Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,6 @@ export function getMockResponseStreaming(
46
46
const fullText = mocksLookup [ filename ] ;
47
47
48
48
return {
49
-
50
49
// Really tangled typescript error here from our transitive dependencies.
51
50
// Ignoring it now, but uncomment and run `yarn lerna:prepare` in top-level
52
51
// of the repo to see if you get it or if it has gone away.
@@ -60,10 +59,17 @@ export function getMockResponseStreaming(
60
59
} ;
61
60
}
62
61
63
- export function getMockResponse ( filename : string ) : Partial < Response > {
64
- const fullText = mocksLookup [ filename ] ;
62
+ type BackendName = 'vertexai' | 'googleai' ;
63
+ export function getMockResponse ( backendName : BackendName , filename : string ) : Partial < Response > {
64
+ // @ts -ignore
65
+ const backendMocksLookup : Record < string , string > = mocksLookup [ backendName ] ;
66
+ if ( ! ( filename in backendMocksLookup ) ) {
67
+ throw Error ( `${ backendName } mock response file '${ filename } ' not found.` ) ;
68
+ }
69
+ const fullText = backendMocksLookup [ filename ] as string ;
70
+
65
71
return {
66
72
ok : true ,
67
- json : ( ) => Promise . resolve ( JSON . parse ( fullText ! ) ) ,
73
+ json : ( ) => Promise . resolve ( JSON . parse ( fullText ) ) ,
68
74
} ;
69
75
}
You can’t perform that action at this time.
0 commit comments