@@ -18,29 +18,32 @@ describe("ConverseStream with text generation models", () => {
1818 mistral : "Mistral" ,
1919 } ;
2020
21- test . each ( Object . entries ( models ) . map ( ( [ sub , name ] ) => [ name , sub ] ) ) (
22- "should invoke %s and return text" ,
23- async ( _ , subdirectory ) => {
24- let output = "" ;
25- const outputStream = new Writable ( {
26- write ( /** @type string */ chunk , encoding , callback ) {
27- output += chunk . toString ( ) ;
28- callback ( ) ;
29- } ,
30- } ) ;
31-
32- const stdoutWriteSpy = vi
33- . spyOn ( process . stdout , "write" )
34- . mockImplementation ( outputStream . write . bind ( outputStream ) ) ;
35-
36- const script = path . join ( baseDirectory , subdirectory , fileName ) ;
37-
38- try {
39- await import ( script ) ;
40- expect ( output ) . toMatch ( / \S / ) ;
41- } finally {
42- stdoutWriteSpy . mockRestore ( ) ;
43- }
44- } ,
45- ) ;
21+ const delay = ( ms ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
22+
23+ test . sequential . each (
24+ Object . entries ( models ) . map ( ( [ sub , name ] ) => [ name , sub ] ) ,
25+ ) ( "should invoke %s and return text" , async ( _ , subdirectory ) => {
26+ // Add a 500 ms delay before each test to avoid throttling issues
27+ await delay ( 500 ) ;
28+ let output = "" ;
29+ const outputStream = new Writable ( {
30+ write ( /** @type string */ chunk , encoding , callback ) {
31+ output += chunk . toString ( ) ;
32+ callback ( ) ;
33+ } ,
34+ } ) ;
35+
36+ const stdoutWriteSpy = vi
37+ . spyOn ( process . stdout , "write" )
38+ . mockImplementation ( outputStream . write . bind ( outputStream ) ) ;
39+
40+ const script = path . join ( baseDirectory , subdirectory , fileName ) ;
41+
42+ try {
43+ await import ( script ) ;
44+ expect ( output ) . toMatch ( / \S / ) ;
45+ } finally {
46+ stdoutWriteSpy . mockRestore ( ) ;
47+ }
48+ } ) ;
4649} ) ;
0 commit comments