Skip to content

Commit 9fb95e9

Browse files
author
wan
committed
feat: 添加测试报告存储类型配置,支持项目目录存储选项
1 parent 8c413de commit 9fb95e9

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

package.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"isRecordTestCaseList": "config.hbuilderx-for-uniapp-test.recordTestCaseList",
3131
"isShowCreateTestCase": "expression.isCheckTestEnv && (expression.isUniPageDir || expression.isUniPageFile)",
3232
"isShowRunCurrentTestCaseMenu": "expression.isUniApp && expression.isJSFileForEnv && (workspaceFolderRelativePath =~ /^(src\\/pages|pages)\\/.*\\.test\\.js$/ || workspaceFolderRelativePath =~ /^\\pages\\/autotest\\/uni.*/)",
33-
"isShowRunALLTestCaseMenu": "expression.isUniApp && expression.isJSFileForEnv && expression.isJSFileForJestConfig && (explorerResourceIsWorkspaceFolder || expression.isTestConfigFile)"
33+
"isShowRunALLTestCaseMenu": "expression.isUniApp && expression.isJSFileForEnv && expression.isJSFileForJestConfig && (explorerResourceIsWorkspaceFolder || expression.isTestConfigFile)",
34+
"iSOtherTestReport": "config.hbuilderx-for-uniapp-test.storageTestReportOutPutDirType == '其它'"
3435
},
3536
"snippets": [
3637
{
@@ -597,17 +598,27 @@
597598
"hbuilderx-for-uniapp-test.customTestEnvironmentDependencyDir": {
598599
"type": "string",
599600
"default": "",
600-
"description": "uni-app自动化测试依赖:自定义依赖目录。<span style='font-size: 13px;'><br/>1. 配置方法:HBuilderX安装目录/hbuilderx-for-uniapp-test/src/environment目录下<br/>2. 拷贝package.json到你要自定义的目录,执行npm install。<br/>3. <span style='color: #4E9ADE;'>注意:请谨慎操作。路径必须要以node_modules结尾。如非专业人员,建议使用默认,不要修改此项。</span></span>"
601+
"description": "uni-app自动化测试依赖:自定义依赖目录。<span style='font-size: 12px;'><br/>1. 配置方法:HBuilderX安装目录/hbuilderx-for-uniapp-test/src/environment目录下<br/>2. 拷贝package.json到你要自定义的目录,执行npm install。<br/>3. <span style='color: #4E9ADE;'>注意:请谨慎操作。路径必须要以node_modules结尾。如非专业人员,建议使用默认,不要修改此项。</span></span>"
602+
},
603+
"hbuilderx-for-uniapp-test.storageTestReportOutPutDirType": {
604+
"type": "string",
605+
"default": "其它",
606+
"enum": [
607+
"项目目录",
608+
"其它"
609+
],
610+
"description": "uni-app自动化测试插件,测试报告,存储类型。"
601611
},
602612
"hbuilderx-for-uniapp-test.testReportOutPutDir": {
603613
"type": "string",
604614
"default": "",
605-
"description": "uni-app自动化测试插件,测试报告输出路径。"
615+
"description": "uni-app自动化测试插件,测试报告输出路径。<br/><span style='font-size: 12px;color: #4E9ADE;'>当测试报告存储类型,选择 [其它] 时生效。</span>",
616+
"when": "iSOtherTestReport"
606617
},
607618
"hbuilderx-for-uniapp-test.AutomaticModificationTestMatch": {
608619
"type": "boolean",
609620
"default": true,
610-
"description": "自动修改jest.config.js文件中的testMatch。<br/><span style='font-size: 13px;color: #4E9ADE;'>默认规范:测试用例在pages页面目录下。如测试用例在其它目录,请不要勾选此项。</span>"
621+
"description": "自动修改jest.config.js文件中的testMatch。<br/><span style='font-size: 12px;color: #4E9ADE;'>默认规范:测试用例在pages页面目录下。如测试用例在其它目录,请不要勾选此项。</span>"
611622
},
612623
"hbuilderx-for-uniapp-test.jestNodeType": {
613624
"type": "boolean",

src/TestCaseRun.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,13 @@ class Common {
278278

279279
// 获取测试报告目录
280280
async getReportOutputDir(projectName, testPlatform) {
281+
const storagePathType = await getPluginConfig("hbuilderx-for-uniapp-test.storageTestReportOutPutDirType");
282+
if (storagePathType == "项目目录" || storagePathType == "项目下") {
283+
let ProjectReportDir = path.join(this.projectPath, '.hbuilderx', 'test-report', testPlatform);
284+
mkdirsSync(ProjectReportDir);
285+
return ProjectReportDir;
286+
};
287+
281288
// 使用用户自定义的目录
282289
const userSet = (await getPluginConfig("hbuilderx-for-uniapp-test.testReportOutPutDir"))?.trim();
283290
if (userSet) {

0 commit comments

Comments
 (0)