From 604236be43879a70d631c554ecdca174e2dab405 Mon Sep 17 00:00:00 2001 From: ambzhang <450145249@qq.com> Date: Thu, 27 Nov 2025 18:12:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(utils):=20=E6=94=AF=E6=8C=81=20fileMode=20?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E5=8C=B9?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 createTestResults 方法中添加 fileMode 支持,当 TESTSOLAR_TTP_FILEMODE 为 1 时,按文件路径匹配测试用例。同时更新版本号至 0.2.24。 --- playwright/package.json | 2 +- playwright/src/playwrightx/utils.ts | 12 +++++++++++- playwright/testtool.yaml | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/playwright/package.json b/playwright/package.json index a749c3d..906fc97 100644 --- a/playwright/package.json +++ b/playwright/package.json @@ -1,6 +1,6 @@ { "name": "testsolar-oss-playwright", - "version": "0.2.23", + "version": "0.2.24", "description": "TestSolar support for playwright tool", "main": "main.js", "scripts": { diff --git a/playwright/src/playwrightx/utils.ts b/playwright/src/playwrightx/utils.ts index b3dbc74..02abe6a 100644 --- a/playwright/src/playwrightx/utils.ts +++ b/playwright/src/playwrightx/utils.ts @@ -722,6 +722,9 @@ export function createTestResults( const testResults: TestResult[] = []; const casePrefix = getTestcasePrefix(); + // 检查是否为 fileMode + const fileMode = process.env.TESTSOLAR_TTP_FILEMODE == "1"; + // 首先找出参考失败用例(output中的key不在testIdentifiers中的) let referenceFailedTest: TestResult | null = null; @@ -731,7 +734,14 @@ export function createTestResults( const fullTestPath = `${casePrefix}${testCase}`; // 判断当前测试用例是否在testIdentifiers中 - const isInTestIdentifiers = testIdentifiers.includes(testCase); + let isInTestIdentifiers = testIdentifiers.includes(testCase); + + // 在 fileMode 下,需要检查测试用例是否属于指定的文件 + if (fileMode && !isInTestIdentifiers) { + // 提取测试用例的文件路径部分(问号之前的部分) + const testFilePath = testCase.split('?')[0]; + isInTestIdentifiers = testIdentifiers.includes(testFilePath); + } // 处理每个结果 for (const result of results) { diff --git a/playwright/testtool.yaml b/playwright/testtool.yaml index 0ad0ebf..1f0b2ff 100644 --- a/playwright/testtool.yaml +++ b/playwright/testtool.yaml @@ -2,7 +2,7 @@ schemaVersion: 1.0 name: playwright nameZh: Playwright自动化测试 lang: javascript -version: '0.2.23' +version: '0.2.24' defaultBaseImage: node:18 langType: INTERPRETED description: |-