Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
3fd73dd8
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
355
Star
2
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello-uvue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
3fd73dd8
编写于
6月 19, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 补充 onError 测试例
上级
e2305ee4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
16 deletion
+80
-16
App.uvue
App.uvue
+2
-1
pages/error/throw-error/throw-error-composition.uvue
pages/error/throw-error/throw-error-composition.uvue
+24
-14
pages/error/throw-error/throw-error-options.uvue
pages/error/throw-error/throw-error-options.uvue
+7
-1
pages/error/throw-error/throw-error.test.js
pages/error/throw-error/throw-error.test.js
+47
-0
未找到文件。
App.uvue
浏览文件 @
3fd73dd8
...
...
@@ -65,7 +65,8 @@
},
// #endif
onError: function(error: any) {
console.log('App Error', error)
console.log('App Error', error)
setLifeCycleNum(state.lifeCycleNum + 100)
},
methods: {
checkLaunchPath() : boolean {
...
...
pages/error/throw-error/throw-error-composition.uvue
浏览文件 @
3fd73dd8
<template>
<view class="page">
<button @click="triggerError">trigger error</button>
</view>
</template>
<script setup lang="uts">
onReady(() => {
throw Error('error in error composition page onReady')
})
const triggerError = () => {
throw Error('trigger error in throw error composition page')
}
</script>
<template>
<view class="page">
<button id="trigger-error" @click="triggerError">trigger error</button>
</view>
</template>
<script setup lang="uts">
import { state } from '@/store/index.uts'
onReady(() => {
throw Error('error in error composition page onReady')
})
const triggerError = () => {
throw Error('trigger error in throw error composition page')
}
// 自动化测试
const getLifeCycleNum = () : number => {
return state.lifeCycleNum
}
defineExpose({
getLifeCycleNum
})
</script>
\ No newline at end of file
pages/error/throw-error/throw-error-options.uvue
浏览文件 @
3fd73dd8
<template>
<view class="page">
<button @click="triggerError">trigger error</button>
<button
id="trigger-error"
@click="triggerError">trigger error</button>
</view>
</template>
<script lang="uts">
import { state } from '@/store/index.uts'
export default {
onReady(){
throw Error('error in error options page onReady')
...
...
@@ -12,6 +14,10 @@ export default {
methods: {
triggerError(){
throw Error('trigger error in throw error options page')
},
// 自动化测试
getLifeCycleNum() : number {
return state.lifeCycleNum
}
},
}
...
...
pages/error/throw-error/throw-error.test.js
0 → 100644
浏览文件 @
3fd73dd8
const
OPTIONS_PAGE_PATH
=
'
/pages/error/throw-error/throw-error-options
'
const
COMPOSITION_PAGE_PATH
=
'
/pages/error/throw-error/throw-error-composition
'
const
HOME_PAGE_PATH
=
'
/pages/index/index
'
describe
(
'
throw error
'
,
()
=>
{
let
page
let
lifeCycleNum
const
initLifecycle
=
async
()
=>
{
page
=
await
program
.
reLaunch
(
HOME_PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
0
)
}
const
test
=
async
(
pagePath
)
=>
{
await
initLifecycle
()
page
=
await
program
.
reLaunch
(
pagePath
)
await
page
.
waitFor
(
'
view
'
)
expect
(
page
.
path
).
toBe
(
pagePath
.
substring
(
1
))
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
100
)
const
triggerErrorBtn
=
await
page
.
$
(
'
#trigger-error
'
)
await
triggerErrorBtn
.
tap
()
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
200
)
page
=
await
program
.
navigateTo
(
HOME_PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
expect
(
page
.
path
).
toBe
(
HOME_PAGE_PATH
.
substring
(
1
))
}
it
(
'
onError options API
'
,
async
()
=>
{
await
test
(
OPTIONS_PAGE_PATH
)
})
it
(
'
onError composition API
'
,
async
()
=>
{
await
test
(
COMPOSITION_PAGE_PATH
)
})
afterAll
(
async
()
=>
{
const
resetLifecycleNum
=
1100
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
resetLifecycleNum
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
resetLifecycleNum
)
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录