Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
ae153aa3
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
350
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看板
提交
ae153aa3
编写于
1月 23, 2024
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 调整测试例兼容web端
上级
56b9ae3f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
54 addition
and
25 deletion
+54
-25
pages/component-instance/methods/call-method-easycom-uni-modules.uvue
...ent-instance/methods/call-method-easycom-uni-modules.uvue
+9
-9
pages/component-instance/methods/call-method-other.uvue
pages/component-instance/methods/call-method-other.uvue
+8
-8
pages/component-instance/parent/parent.test.js
pages/component-instance/parent/parent.test.js
+6
-0
pages/component-instance/watch-function/watch-array.test.js
pages/component-instance/watch-function/watch-array.test.js
+1
-1
pages/component-instance/watch-function/watch-function.test.js
.../component-instance/watch-function/watch-function.test.js
+4
-1
pages/composition-api/lifecycle/component-lifecycle/component-lifecycle.test.js
...lifecycle/component-lifecycle/component-lifecycle.test.js
+6
-0
pages/composition/provide/provide.test.js
pages/composition/provide/provide.test.js
+4
-3
pages/lifecycle/page/page.test.js
pages/lifecycle/page/page.test.js
+16
-3
未找到文件。
pages/component-instance/methods/call-method-easycom-uni-modules.uvue
浏览文件 @
ae153aa3
...
...
@@ -10,43 +10,43 @@
export default {
data() {
return {
$
callEasyMethod1: null as CallEasyMethodUniModulesComponentPublicInstance | null
callEasyMethod1: null as CallEasyMethodUniModulesComponentPublicInstance | null
}
},
onReady() {
// 通过组件 ref 属性获取组件实例, 组件标签名首字母大写,驼峰+ComponentPublicInstance
this.
$
callEasyMethod1 = this.$refs['callEasyMethod1'] as CallEasyMethodUniModulesComponentPublicInstance;
this.callEasyMethod1 = this.$refs['callEasyMethod1'] as CallEasyMethodUniModulesComponentPublicInstance;
},
methods: {
callMethod1() {
// 调用组件的 foo1 方法
this.
$
callEasyMethod1!.foo1();
this.callEasyMethod1!.foo1();
},
callMethod2() {
// 调用组件的 foo2 方法并传递 1个参数
this.
$
callEasyMethod1!.foo2(Date.now());
this.callEasyMethod1!.foo2(Date.now());
},
callMethod3() {
// 调用组件的 foo3 方法并传递 2个参数
this.
$
callEasyMethod1!.foo3(Date.now(), Date.now());
this.callEasyMethod1!.foo3(Date.now(), Date.now());
},
callMethod4() {
// 调用组件的 foo4 方法并传递 callback
this.
$
callEasyMethod1!.foo4(() => {
this.callEasyMethod1!.foo4(() => {
console.log('callback')
});
},
callMethod5() {
// 注意: 返回值可能为 null,当前例子一定不为空,所以加了 !
const result = this.
$
callEasyMethod1!.foo5('string1') as string;
const result = this.callEasyMethod1!.foo5('string1') as string;
console.log(result); // string1
},
callMethodTest(text: string): string | null {
const result = this.
$
callEasyMethod1!.foo5(text) as string;
const result = this.callEasyMethod1!.foo5(text) as string;
return result;
},
callMethodInOtherFile(text: string): string {
return testInOtherFile(this.
$
callEasyMethod1!, text);
return testInOtherFile(this.callEasyMethod1!, text);
},
}
}
...
...
pages/component-instance/methods/call-method-other.uvue
浏览文件 @
ae153aa3
...
...
@@ -14,40 +14,40 @@
},
data() {
return {
$
component1: null as ComponentPublicInstance | null
component1: null as ComponentPublicInstance | null
}
},
onReady() {
// 通过组件 ref 属性获取组件实例
this.
$
component1 = this.$refs['component1'] as ComponentPublicInstance;
this.component1 = this.$refs['component1'] as ComponentPublicInstance;
},
methods: {
callMethod1() {
// 通过 $callMethod 调用组件的 foo1 方法
this.
$
component1!.$callMethod('foo1');
this.component1!.$callMethod('foo1');
},
callMethod2() {
// 通过 $callMethod 调用组件的 foo2 方法并传递 1个参数
this.
$
component1!.$callMethod('foo2', Date.now());
this.component1!.$callMethod('foo2', Date.now());
},
callMethod3() {
// 通过 $callMethod 调用组件的 foo3 方法并传递 2个参数
this.
$
component1!.$callMethod('foo3', Date.now(), Date.now());
this.component1!.$callMethod('foo3', Date.now(), Date.now());
},
callMethod4() {
// 通过 $callMethod 调用组件的 foo4 方法并传递 callback
this.
$
component1!.$callMethod('foo4', () => {
this.component1!.$callMethod('foo4', () => {
console.log('callback')
});
},
callMethod5() {
// 通过 $callMethod 调用组件的 foo5 方法并接收返回值
// 注意: 返回值可能为 null,当前例子一定不为空,所以加了 !
const result = this.
$
component1!.$callMethod('foo5', 'string1') as string;
const result = this.component1!.$callMethod('foo5', 'string1') as string;
console.log(result); // string1
},
callMethodTest(text: string): string | null {
const result = this.
$
component1!.$callMethod('foo5', text) as string;
const result = this.component1!.$callMethod('foo5', text) as string;
return result;
},
}
...
...
pages/component-instance/parent/parent.test.js
浏览文件 @
ae153aa3
const
PAGE_PATH
=
'
/pages/component-instance/parent/parent
'
describe
(
'
$parent
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
// TODO: web 端暂不支持
it
(
'
web
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
})
}
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
...
...
pages/component-instance/watch-function/watch-array.test.js
浏览文件 @
ae153aa3
...
...
@@ -23,7 +23,7 @@ describe('watch', () => {
await
btnChangeData2
.
tap
()
await
page
.
waitFor
(
100
)
// count = 2,重新赋值触发
await
validateCount
(
page
,
2
)
await
validateCount
(
page
,
3
)
// 验证数据正确性
await
validateData2
(
page
,
3
,
4
)
})
...
...
pages/component-instance/watch-function/watch-function.test.js
浏览文件 @
ae153aa3
...
...
@@ -12,7 +12,10 @@ describe('$watch()', () => {
const
value4_new
=
await
page
.
$
(
'
.value-4-n
'
)
const
value4_old
=
await
page
.
$
(
'
.value-4-o
'
)
expect
(
await
value4_new
.
text
()).
toBe
(
'
6
'
)
expect
(
await
value4_old
.
text
()).
toBe
(
'
6
'
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
// TODO 安卓端由于类型问题,此处返回初始值,web端无值
expect
(
await
value4_old
.
text
()).
toBe
(
'
6
'
)
}
const
btn
=
await
page
.
$
(
'
.btn-click
'
)
...
...
pages/composition-api/lifecycle/component-lifecycle/component-lifecycle.test.js
浏览文件 @
ae153aa3
...
...
@@ -2,6 +2,12 @@ const PAGE_PATH = '/pages/composition-api/lifecycle/component-lifecycle/componen
const
HOME_PATH
=
'
/pages/tab-bar/options-api
'
describe
(
'
component-lifecycle
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
// TODO: 自动化测试暂不能调用web端setup内defineExpose导出的方法,待自动化测试兼容后开放此测试例
it
(
'
web
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
})
}
let
page
let
lifeCycleNum
beforeAll
(
async
()
=>
{
...
...
pages/composition/provide/provide.test.js
浏览文件 @
ae153aa3
const
PAGE_PATH
=
'
/pages/composition/provide/provide
'
describe
(
'
字面量方式创建 provide
'
,
()
=>
{
const
isWeb
=
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
...
...
@@ -50,21 +51,21 @@ describe('字面量方式创建 provide', () => {
const
providePageArrEl
=
await
page
.
$
(
'
.provide-page-arr
'
)
const
providePageArrText
=
await
providePageArrEl
.
text
()
expect
(
providePageArrText
).
toBe
(
'
providePageArr: ["字面量方式定义 provide page arr"]
'
isWeb
?
'
providePageArr: [
\n
"字面量方式定义 provide page arr"
\n
]
'
:
'
providePageArr: ["字面量方式定义 provide page arr"]
'
)
})
it
(
'
map
'
,
async
()
=>
{
const
providePageMapEl
=
await
page
.
$
(
'
.provide-page-map
'
)
const
providePageMapText
=
await
providePageMapEl
.
text
()
expect
(
providePageMapText
).
toBe
(
'
providePageMap: {"key":"字面量方式定义 provide page map"}
'
isWeb
?
'
providePageMap: {
\n
"key": "字面量方式定义 provide page map"
\n
}
'
:
'
providePageMap: {"key":"字面量方式定义 provide page map"}
'
)
})
it
(
'
set
'
,
async
()
=>
{
const
providePageSetEl
=
await
page
.
$
(
'
.provide-page-set
'
)
const
providePageSetText
=
await
providePageSetEl
.
text
()
expect
(
providePageSetText
).
toBe
(
'
providePageSet: ["字面量方式定义 provide page set"]
'
isWeb
?
'
providePageSet: [
\n
"字面量方式定义 provide page set"
\n
]
'
:
'
providePageSet: ["字面量方式定义 provide page set"]
'
)
})
it
(
'
string default value
'
,
async
()
=>
{
...
...
pages/lifecycle/page/page.test.js
浏览文件 @
ae153aa3
...
...
@@ -36,7 +36,12 @@ describe('page-lifecycle', () => {
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
700
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
130
)
// TODO 安卓端调整页面加载不触发onResize后调整此测试例
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
lifeCycleNum
).
toBe
(
130
)
}
else
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
lifeCycleNum
).
toBe
(
120
)
}
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
})
it
(
'
onPullDownRefresh
'
,
async
()
=>
{
...
...
@@ -75,11 +80,19 @@ describe('page-lifecycle', () => {
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
700
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
130
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
lifeCycleNum
).
toBe
(
130
)
}
else
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
lifeCycleNum
).
toBe
(
120
)
}
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
'
view
'
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
20
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
lifeCycleNum
).
toBe
(
20
)
}
else
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
lifeCycleNum
).
toBe
(
10
)
}
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
})
})
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录