Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
b7d18b57
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
359
Star
3
Fork
8
代码
文件
提交
分支
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看板
提交
b7d18b57
编写于
9月 27, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 补充 App.uvue 访问 app.config 示例及测试
上级
fe8cacfd
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
37 addition
and
11 deletion
+37
-11
App.uvue
App.uvue
+4
-1
jest.config.js
jest.config.js
+4
-1
pages/App.test.js
pages/App.test.js
+3
-0
pages/error/throw-error/throw-error.test.js
pages/error/throw-error/throw-error.test.js
+1
-1
pages/lifecycle/component/component-composition.test.js
pages/lifecycle/component/component-composition.test.js
+1
-1
pages/lifecycle/component/component-options.test.js
pages/lifecycle/component/component-options.test.js
+1
-1
pages/lifecycle/page/page.test.js
pages/lifecycle/page/page.test.js
+6
-6
testSequencer.js
testSequencer.js
+17
-0
未找到文件。
App.uvue
浏览文件 @
b7d18b57
...
...
@@ -34,6 +34,9 @@
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100)
setAppShowPath(options.path)
if(this.globalPropertiesStr === 'default string'){
setLifeCycleNum(state.lifeCycleNum + 10)
}
console.log('App Show')
},
onHide: function () {
...
...
@@ -65,7 +68,7 @@
},
// #endif
onError: function(error: any) {
console.log('App Error', error)
console.log('App Error', error)
setLifeCycleNum(state.lifeCycleNum + 100)
},
methods: {
...
...
jest.config.js
浏览文件 @
b7d18b57
const
path
=
require
(
'
path
'
)
module
.
exports
=
{
testTimeout
:
10000
,
reporters
:
[
'
default
'
],
watchPathIgnorePatterns
:
[
'
/node_modules/
'
,
'
/dist/
'
,
'
/.git/
'
],
moduleFileExtensions
:
[
'
js
'
,
'
json
'
],
rootDir
:
__dirname
,
testMatch
:
[
'
<rootDir>/pages/**/**/*.test.js
'
],
testMatch
:
[
"
<rootDir>/pages/App.test.js
"
],
testPathIgnorePatterns
:
[
'
/node_modules/
'
],
setupFilesAfterEnv
:
[
'
<rootDir>/jest-setup.js
'
],
testSequencer
:
path
.
join
(
__dirname
,
"
testSequencer.js
"
)
}
pages/App.test.js
浏览文件 @
b7d18b57
...
...
@@ -8,5 +8,8 @@ describe("app launch & show options", () => {
if
(
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
await
page
.
callMethod
(
"
checkAppMixin
"
)).
toBe
(
true
)
}
const
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
1110
)
})
})
pages/error/throw-error/throw-error.test.js
浏览文件 @
b7d18b57
...
...
@@ -39,7 +39,7 @@ describe('throw error', () => {
})
afterAll
(
async
()
=>
{
const
resetLifecycleNum
=
11
0
0
const
resetLifecycleNum
=
11
1
0
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
resetLifecycleNum
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
resetLifecycleNum
)
...
...
pages/lifecycle/component/component-composition.test.js
浏览文件 @
b7d18b57
...
...
@@ -19,7 +19,7 @@ describe('component-lifecycle', () => {
await
page
.
waitFor
(
700
)
})
afterAll
(
async
()
=>
{
const
resetLifecycleNum
=
11
0
0
const
resetLifecycleNum
=
11
1
0
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
resetLifecycleNum
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
resetLifecycleNum
)
...
...
pages/lifecycle/component/component-options.test.js
浏览文件 @
b7d18b57
...
...
@@ -16,7 +16,7 @@ describe('component-lifecycle', () => {
await
page
.
waitFor
(
700
)
})
afterAll
(
async
()
=>
{
const
resetLifecycleNum
=
11
0
0
const
resetLifecycleNum
=
11
1
0
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
resetLifecycleNum
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
resetLifecycleNum
)
...
...
pages/lifecycle/page/page.test.js
浏览文件 @
b7d18b57
...
...
@@ -15,7 +15,7 @@ const initLifecycle = async () => {
}
const
testPageLifecycle
=
async
(
pagePath
)
=>
{
// onLoad onShow onReady onResize
page
=
await
program
.
reLaunch
(
pagePath
)
page
=
await
program
.
reLaunch
(
pagePath
)
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
pageGetLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
120
)
...
...
@@ -60,7 +60,7 @@ const testPageLifecycle = async (pagePath) => {
await
page
.
waitFor
(
700
)
lifeCycleNum
=
await
page
.
callMethod
(
'
pageGetLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
120
)
page
=
await
program
.
navigateBack
()
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
'
view
'
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
10
)
...
...
@@ -72,7 +72,7 @@ describe('app-lifecycle', () => {
page
=
await
program
.
reLaunch
(
HOME_PATH
)
await
page
.
waitFor
(
700
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
11
0
0
)
expect
(
lifeCycleNum
).
toBe
(
11
1
0
)
})
it
(
'
onLastPageBackPress
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
...
...
@@ -85,8 +85,8 @@ describe('app-lifecycle', () => {
})
describe
(
'
page-lifecycle
'
,
()
=>
{
it
(
'
page-lifecycle options API
'
,
async
()
=>
{
await
initLifecycle
()
it
(
'
page-lifecycle options API
'
,
async
()
=>
{
await
initLifecycle
()
await
testPageLifecycle
(
OPTIONS_PAGE_PATH
)
})
...
...
@@ -96,7 +96,7 @@ describe('page-lifecycle', () => {
})
afterAll
(
async
()
=>
{
const
resetLifecycleNum
=
11
0
0
const
resetLifecycleNum
=
11
1
0
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
resetLifecycleNum
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
resetLifecycleNum
)
...
...
testSequencer.js
0 → 100644
浏览文件 @
b7d18b57
const
Sequencer
=
require
(
"
@jest/test-sequencer
"
).
default
const
sortTestFilePaths
=
[
"
pages/App.test.js
"
,
]
class
CustomSequencer
extends
Sequencer
{
sort
(
tests
)
{
// 测试例排序
const
sortedTests
=
sortTestFilePaths
.
map
((
filePath
)
=>
{
return
tests
.
find
((
test
)
=>
test
.
path
.
endsWith
(
filePath
))
})
.
filter
(
Boolean
)
return
[...
new
Set
([...
sortedTests
,
...
tests
])]
}
}
module
.
exports
=
CustomSequencer
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录