@@ -16,14 +16,6 @@ it("Should cache AI SDK in the task and scorers", async () => {
1616 cacheDebug : true ,
1717 } ) ;
1818
19- const output = fixture . getOutput ( ) ;
20-
21- const storage = fixture . storage ;
22-
23- const runs = await storage . runs . getMany ( ) ;
24-
25- expect ( runs ) . toHaveLength ( 2 ) ;
26-
2719 const allLogs = fixture . getOutput ( ) . split ( "\n" ) ;
2820
2921 const cachelogs = allLogs . filter ( ( log ) => log . includes ( "[CACHE]" ) ) ;
@@ -32,3 +24,65 @@ it("Should cache AI SDK in the task and scorers", async () => {
3224 expect ( cachelogs . some ( ( log ) => log . includes ( "Scorer cache HIT" ) ) ) . toBe ( true ) ;
3325 expect ( cachelogs . some ( ( log ) => log . includes ( "saved" ) ) ) . toBe ( true ) ;
3426} ) ;
27+
28+ it ( "Should disable cache when cacheEnabled is false" , async ( ) => {
29+ await using fixture = await loadFixture ( "ai-sdk-caching" ) ;
30+
31+ await fixture . run ( {
32+ mode : "run-once-and-exit" ,
33+ cacheDebug : true ,
34+ cacheEnabled : false ,
35+ } ) ;
36+
37+ await fixture . run ( {
38+ mode : "run-once-and-exit" ,
39+ cacheDebug : true ,
40+ cacheEnabled : false ,
41+ } ) ;
42+
43+ const allLogs = fixture . getOutput ( ) . split ( "\n" ) ;
44+ const cachelogs = allLogs . filter ( ( log ) => log . includes ( "[CACHE]" ) ) ;
45+ expect ( cachelogs . length ) . toBe ( 0 ) ;
46+ } ) ;
47+
48+ it ( "Should respect cacheEnabled: false in config" , async ( ) => {
49+ await using fixture = await loadFixture ( "ai-sdk-caching-config-disabled" ) ;
50+
51+ // First run
52+ await fixture . run ( {
53+ mode : "run-once-and-exit" ,
54+ cacheDebug : true ,
55+ } ) ;
56+
57+ // Second run - should still not cache because config disables it
58+ await fixture . run ( {
59+ mode : "run-once-and-exit" ,
60+ cacheDebug : true ,
61+ } ) ;
62+
63+ const allLogs = fixture . getOutput ( ) . split ( "\n" ) ;
64+ const cachelogs = allLogs . filter ( ( log ) => log . includes ( "[CACHE]" ) ) ;
65+ expect ( cachelogs . length ) . toBe ( 0 ) ;
66+ } ) ;
67+
68+ it ( "Should let runEvalite cacheEnabled override config cacheEnabled" , async ( ) => {
69+ await using fixture = await loadFixture ( "ai-sdk-caching-config-precedence" ) ;
70+
71+ // Config has cacheEnabled: true, but we override with false
72+ await fixture . run ( {
73+ mode : "run-once-and-exit" ,
74+ cacheDebug : true ,
75+ cacheEnabled : false ,
76+ } ) ;
77+
78+ await fixture . run ( {
79+ mode : "run-once-and-exit" ,
80+ cacheDebug : true ,
81+ cacheEnabled : false ,
82+ } ) ;
83+
84+ const allLogs = fixture . getOutput ( ) . split ( "\n" ) ;
85+ const cachelogs = allLogs . filter ( ( log ) => log . includes ( "[CACHE]" ) ) ;
86+ // Should have no cache logs because runEvalite overrides config
87+ expect ( cachelogs . length ) . toBe ( 0 ) ;
88+ } ) ;
0 commit comments