@@ -356,7 +356,9 @@ export function generateCommands(
356356
357357 // 默认启用环境变量JSON文件,除非明确设置为"0"才禁用
358358 const useEnvJsonFile = process . env . TESTSOLAR_TTP_ENVJSONFILE !== "0" ;
359-
359+ const runAllCases = process . env . TESTSOLAR_TTP_RUNALLCASES ?. toLowerCase ( ) === "1" ||
360+ process . env . TESTSOLAR_TTP_RUNALLCASES ?. toLowerCase ( ) === "true" ;
361+
360362 // 默认启用trace,只有当明确设置TESTSOLAR_TTP_TRACE为"0"时才关闭
361363 const disableTrace = process . env . TESTSOLAR_TTP_TRACE === "0" ;
362364 const traceOption = disableTrace ? "--trace off" : "--trace on" ;
@@ -376,7 +378,7 @@ export function generateCommands(
376378
377379 // 获取 grep 模式(在 fileMode 下不使用 grep)
378380 let grepPattern = "" ;
379- if ( testCases . length > 0 && ! fileMode ) {
381+ if ( testCases . length > 0 && ! fileMode && ! runAllCases ) {
380382 grepPattern = `--grep="${ decodeURIComponent ( testCases . join ( "|" ) ) } "` ;
381383 }
382384
@@ -392,7 +394,11 @@ export function generateCommands(
392394 command = `export PLAYWRIGHT_JSON_OUTPUT_NAME=${ jsonName } && npx playwright test --reporter=json ${ traceOption } ${ workersOption } ${ outputOption } ${ extraArgs } ` ;
393395 }
394396 } else {
395- command = `export PLAYWRIGHT_JSON_OUTPUT_NAME=${ jsonName } && npx playwright test ${ casePath } ${ grepPattern } --reporter=json ${ traceOption } ${ workersOption } ${ outputOption } ${ extraArgs } ` ;
397+ if ( runAllCases ) {
398+ command = `export PLAYWRIGHT_JSON_OUTPUT_NAME=${ jsonName } && npx playwright test ./${ casePath } / --reporter=json ${ traceOption } ${ workersOption } ${ outputOption } ${ extraArgs } ` ;
399+ } else {
400+ command = `export PLAYWRIGHT_JSON_OUTPUT_NAME=${ jsonName } && npx playwright test ${ casePath } ${ grepPattern } --reporter=json ${ traceOption } ${ workersOption } ${ outputOption } ${ extraArgs } ` ;
401+ }
396402 }
397403 } else {
398404 // 使用原始的重定向方式
@@ -404,7 +410,11 @@ export function generateCommands(
404410 command = `npx playwright test --reporter=json ${ traceOption } ${ workersOption } ${ outputOption } ${ extraArgs } > ${ jsonName } ` ;
405411 }
406412 } else {
407- command = `npx playwright test ${ casePath } ${ grepPattern } --reporter=json ${ traceOption } ${ workersOption } ${ outputOption } ${ extraArgs } > ${ jsonName } ` ;
413+ if ( runAllCases ) {
414+ command = `export PLAYWRIGHT_JSON_OUTPUT_NAME=${ jsonName } && npx playwright test ./${ casePath } / --reporter=json ${ traceOption } ${ workersOption } ${ outputOption } ${ extraArgs } ` ;
415+ } else {
416+ command = `npx playwright test ${ casePath } ${ grepPattern } --reporter=json ${ traceOption } ${ workersOption } ${ outputOption } ${ extraArgs } > ${ jsonName } ` ;
417+ }
408418 }
409419 }
410420
@@ -724,6 +734,8 @@ export function createTestResults(
724734
725735 // 检查是否为 fileMode
726736 const fileMode = process . env . TESTSOLAR_TTP_FILEMODE == "1" ;
737+ const runAllCases = process . env . TESTSOLAR_TTP_RUNALLCASES ?. toLowerCase ( ) === "1" ||
738+ process . env . TESTSOLAR_TTP_RUNALLCASES ?. toLowerCase ( ) === "true" ;
727739
728740 // 首先找出参考失败用例(output中的key不在testIdentifiers中的)
729741 let referenceFailedTest : TestResult | null = null ;
@@ -742,6 +754,10 @@ export function createTestResults(
742754 const testFilePath = testCase . split ( '?' ) [ 0 ] ;
743755 isInTestIdentifiers = testIdentifiers . includes ( testFilePath ) ;
744756 }
757+
758+ if ( runAllCases && ! isInTestIdentifiers ) {
759+ isInTestIdentifiers = true ;
760+ }
745761
746762 // 处理每个结果
747763 for ( const result of results ) {
0 commit comments