提交 53a95a55 编写于 作者: fxy060608's avatar fxy060608

fix(uts): 优化ext api错误提示

上级 1c422a07
......@@ -283,12 +283,12 @@ const formatters: Formatter[] = [
format(error, codes) {
if (error.includes('Failed resolution of: Lio/dcloud/uniapp/extapi/')) {
let api = ''
// 遍历查找
for (const msg of codes) {
api = findUniApi(msg)
if (api) {
break
}
// 第一步先遍历查找^^^^^的索引
const codeFrames = codes[codes.length - 1].split(splitRE)
const index = codeFrames.findIndex((frame) => frame.includes('^^^^^'))
if (index > 0) {
// 第二步,取前一条记录,查找uni.开头的api
api = findUniApi(codeFrames[index - 1])
}
if (api) {
api = `ext api ${api}`
......@@ -301,7 +301,7 @@ const formatters: Formatter[] = [
},
]
const UNI_API_RE = /(uni\.\w+)\([^)]*\)/
const UNI_API_RE = /(uni\.\w+)/
function findUniApi(msg: string) {
const matches = msg.match(UNI_API_RE)
if (matches) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册