Skip to content

Commit

Permalink
feat(e2e): bug修复
Browse files Browse the repository at this point in the history
re #80
  • Loading branch information
fanniehuang committed May 13, 2021
1 parent f5d133d commit 8543004
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/wxa-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webank/wxa-cli2-apple",
"version": "1.0.79",
"version": "1.1.3",
"description": "cli for wxa development",
"main": "dist/wxa.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/wxa-cli/src/tester/domWalker.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class XMLManager {

let keyElement = [pagePath, hash, element.attribs.id];
if (isIeration){
keyElement.push(`-{{${indexVariable}}}`);
keyElement.push(`_{{${indexVariable}}}`);
}

let id = this.assembleUniqueId(keyElement);
Expand Down Expand Up @@ -138,7 +138,7 @@ class XMLManager {
assembleUniqueId(keyElement) {
return keyElement.reduce((prev, key)=>{
if (key) {
key = key.replace(/[^\w\{\}\-]/g, '');
key = key.replace(/[^\w\{\}\_]/g, '');
key = key[0].toUpperCase() + key.slice(1);

return prev + key;
Expand Down
2 changes: 1 addition & 1 deletion packages/wxa-cli/src/tester/wxa-e2eTest/e2eResultTpl.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
}
cur_case.diffIndex = diffIndex;
})
} else if (typeof jest_result !== 'undefined' && jest_result.testResults && jest_result.testResults.length > 0) {
} else if (typeof jest_result !== 'undefined' && jest_result && jest_result.testResults && jest_result.testResults.length > 0) {
let testResult = jest_result.testResults[0];
if (testResult.status === 'failed') {
if (testResult.assertionResults.length > 0) {
Expand Down
10 changes: 6 additions & 4 deletions packages/wxa-cli/src/tester/wxa-e2eTest/runTestCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export default async function(cmd, wxaConfigs) {
} catch(err) {
}
// 处理jest结果,方便网页文档读取
let jestErrArr = [];
let jestResJson = JSON.parse(readFile(jestResPath));
writeFile(jestResPath, `var jest_result = ${JSON.stringify(jestResJson)}`)

Expand Down Expand Up @@ -128,9 +127,12 @@ export default async function(cmd, wxaConfigs) {
// 复制文档目录
shelljs.cp(`-R`, path.join(__dirname, '../../../src/tester/wxa-e2eTest/staticWeb/staticFile'), path.join(testDir, '.doc', 'static'));
// 使用指定浏览器打开
console.log(docPath);
open(docPath, { app: {
console.log(`生成测试报告:${docPath}`);
await open(docPath, { app: {
name: open.apps.chrome
}});
process.exit(0);

setTimeout(() => {
process.exit(0);
}, 5000);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="./static/antd.min.css" rel="stylesheet" type="text/css">
<link href="./static/style.css" rel="stylesheet" type="text/css">
</head>
Expand Down

0 comments on commit 8543004

Please sign in to comment.