提交 26658618 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: 优化测试逻辑,兼容 ios

上级 f625e055
...@@ -15,6 +15,6 @@ ...@@ -15,6 +15,6 @@
</head> </head>
<body> <body>
<div id="app"><!--app-html--></div> <div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script> <script type="module" src="/main"></script>
</body> </body>
</html> </html>
const ERR_RE = /expected:<(.*)> but was:<(.*)>/ const ERR_RE = /expected:<(.*)> but was:<(.*)>/
let result; let result;
const resultEmptyError = '获取到 result 是空的, 请运行项目进行排查'
beforeAll(async () => { beforeAll(async () => {
await program.reLaunch('/pages/index/basicTest') await program.reLaunch('/pages/index/basicTest')
...@@ -11,6 +11,9 @@ beforeAll(async () => { ...@@ -11,6 +11,9 @@ beforeAll(async () => {
}) })
function getApiFailed(describe, api) { function getApiFailed(describe, api) {
if(Object.keys(result).length === 0){
return resultEmptyError
}
const failed = result[describe]?.failed?.find(item => { const failed = result[describe]?.failed?.find(item => {
return item.split(':')[0] === api return item.split(':')[0] === api
}) })
...@@ -22,7 +25,9 @@ describes.forEach(d => { ...@@ -22,7 +25,9 @@ describes.forEach(d => {
d?.tests && d.tests.forEach(api => { d?.tests && d.tests.forEach(api => {
it(api, () => { it(api, () => {
const failed = getApiFailed(d.describe, api) const failed = getApiFailed(d.describe, api)
if (failed) { if(failed == resultEmptyError){
expect('').toBe(resultEmptyError)
}else if (failed) {
const parts = failed.split('\n') const parts = failed.split('\n')
const matches = parts[1].match(ERR_RE) const matches = parts[1].match(ERR_RE)
if (matches?.length) { if (matches?.length) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册