@@ -369,6 +369,63 @@ describe('BatchRunner', () => {
369
369
) ;
370
370
consoleSpy . mockRestore ( ) ;
371
371
} ) ;
372
+
373
+ test ( 'continueOnError: failed tasks should be counted as failed files' , async ( ) => {
374
+ const consoleSpy = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
375
+
376
+ // Create a mock player that simulates continueOnError behavior:
377
+ // - player.status = 'done' (execution completed)
378
+ // - but taskStatusList contains failed tasks
379
+ const createMockPlayerWithFailedTasks = (
380
+ fileName : string ,
381
+ ) : ScriptPlayer < MidsceneYamlScriptEnv > => {
382
+ const isFile1 = fileName === 'file1.yml' ;
383
+ const mockPlayer = {
384
+ status : 'done' as ScriptPlayerStatusValue , // Always 'done' with continueOnError
385
+ output : '/test/output/file.json' ,
386
+ reportFile : '/test/report.html' ,
387
+ result : { test : 'data' } ,
388
+ errorInSetup : null ,
389
+ taskStatusList : isFile1
390
+ ? [
391
+ { status : 'error' , error : new Error ( 'Assertion failed: this is not a search engine' ) } ,
392
+ { status : 'done' }
393
+ ]
394
+ : [ { status : 'done' } ] ,
395
+ run : vi . fn ( ) . mockImplementation ( async ( ) => {
396
+ return undefined ;
397
+ } ) ,
398
+ script : mockYamlScript ,
399
+ setupAgent : vi . fn ( ) ,
400
+ unnamedResultIndex : 0 ,
401
+ pageAgent : null ,
402
+ currentTaskIndex : undefined ,
403
+ agentStatusTip : '' ,
404
+ } ;
405
+ return mockPlayer as unknown as ScriptPlayer < MidsceneYamlScriptEnv > ;
406
+ } ;
407
+
408
+ vi . mocked ( createYamlPlayer ) . mockImplementation ( async ( file ) =>
409
+ createMockPlayerWithFailedTasks ( file ) ,
410
+ ) ;
411
+
412
+ const config = { ...mockBatchConfig , continueOnError : true } ;
413
+ const executor = new BatchRunner ( config ) ;
414
+ await executor . run ( ) ;
415
+
416
+ const summary = executor . getExecutionSummary ( ) ;
417
+ const success = executor . printExecutionSummary ( ) ;
418
+
419
+ // This currently fails - demonstrates the bug
420
+ // Should show 1 failed file, but currently shows 0
421
+ expect ( summary . failed ) . toBe ( 1 ) ; // This test will fail, showing the bug
422
+ expect ( success ) . toBe ( false ) ;
423
+ expect ( consoleSpy ) . toHaveBeenCalledWith (
424
+ expect . stringContaining ( '❌ Failed files' ) ,
425
+ ) ;
426
+
427
+ consoleSpy . mockRestore ( ) ;
428
+ } ) ;
372
429
} ) ;
373
430
374
431
describe ( 'BatchRunner output file existence check' , ( ) => {
0 commit comments