From a889ec1e09d1a601ae7f211841834524b2a7176a Mon Sep 17 00:00:00 2001
From: zhenyuWang <13641039885@163.com>
Date: Wed, 24 Jan 2024 17:02:28 +0800
Subject: [PATCH] =?UTF-8?q?test:=20=E8=B0=83=E6=95=B4=E6=B5=8B=E8=AF=95?=
=?UTF-8?q?=E4=BE=8B=E5=85=BC=E5=AE=B9=20web=20=E7=AB=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../force-update/force-update.test.js | 2 +-
pages/component-instance/props/props.test.js | 8 +-
.../basic/define-slots/define-slots.test.js | 2 +-
.../provide/provide-inject.test.js | 4 +-
.../component-lifecycle.test.js | 7 -
.../page-lifecycle/page-lifecycle.test.js | 18 +-
.../reactivity/computed/computed.test.js | 6 +-
.../reactivity/computed/computed.uvue | 2 +-
.../reactivity/reactive/reactive.test.js | 4 +-
.../reactivity/readonly/readonly.test.js | 15 +-
.../watch-effect/watch-effect.test.js | 4 +-
.../watch-post-effect.test.js | 8 +-
.../watch-sync-effect.test.js | 4 +-
.../reactivity/watch/watch.test.js | 4 +-
.../composition/provide/provide-page2.test.js | 6 +-
pages/composition/provide/provide.test.js | 8 +-
pages/directive/v-model/v-model.test.js | 47 +++---
pages/lifecycle/page/page.test.js | 159 +++++++++---------
18 files changed, 144 insertions(+), 164 deletions(-)
diff --git a/pages/component-instance/force-update/force-update.test.js b/pages/component-instance/force-update/force-update.test.js
index 21a9342..ce38400 100644
--- a/pages/component-instance/force-update/force-update.test.js
+++ b/pages/component-instance/force-update/force-update.test.js
@@ -14,6 +14,6 @@ describe('$forceUpdate', () => {
await triggerForceUpdateBtn.tap()
const timeText2 = (await timeEl.text()).replace('Date.now(): ', '')
- expect(parseInt(timeText2)).toBeGreaterThan(parseInt(timeText1))
+ expect(parseInt(timeText2)).toBeGreaterThanOrEqual(parseInt(timeText1))
})
})
diff --git a/pages/component-instance/props/props.test.js b/pages/component-instance/props/props.test.js
index 5b72f6e..b452fec 100644
--- a/pages/component-instance/props/props.test.js
+++ b/pages/component-instance/props/props.test.js
@@ -15,9 +15,9 @@ describe('$props', () => {
const arrayLiteralBool = await page.$('#array-literal-bool')
expect(await arrayLiteralBool.text()).toBe('true')
const arrayLiteralObj = await page.$('#array-literal-obj')
- expect((await arrayLiteralObj.text()).replaceAll('\n', '').replaceAll(' ', '')).toBe('{"count":1}')
+ expect((await arrayLiteralObj.text()).replaceAll(' ', '')).toBe('{"count":1}')
const arrayLiteralArr = await page.$('#array-literal-arr')
- expect((await arrayLiteralArr.text()).replaceAll('\n', '')).toBe('[1,2,3]')
+ expect(await arrayLiteralArr.text()).toBe('[1,2,3]')
const string = await page.$('.string')
const number = await page.$('.number')
@@ -32,8 +32,8 @@ describe('$props', () => {
expect(await object.text()).toBe('1')
const checkTypeArr = await page.$('#check-type-arr')
- expect((await checkTypeArr.text()).replaceAll('\n', '')).toBe('arr: ["a","b","c"]')
+ expect(await checkTypeArr.text()).toBe('arr: ["a","b","c"]')
const fooArr = await page.$('#foo-arr')
- expect((await fooArr.text()).replaceAll('\n', '')).toBe('arr: [1,2,3]')
+ expect(await fooArr.text()).toBe('arr: [1,2,3]')
})
})
diff --git a/pages/composition-api/basic/define-slots/define-slots.test.js b/pages/composition-api/basic/define-slots/define-slots.test.js
index e87c039..1406fa0 100644
--- a/pages/composition-api/basic/define-slots/define-slots.test.js
+++ b/pages/composition-api/basic/define-slots/define-slots.test.js
@@ -14,6 +14,6 @@ describe('defineSlots', () => {
expect(await slotContent.text()).toBe('default slot num: 0')
const slotFooter = await page.$('#slot-footer')
- expect((await slotFooter.text()).replaceAll('\n', '')).toBe('footer slot arr: ["a","b","c"]')
+ expect(await slotFooter.text()).toBe('footer slot arr: ["a","b","c"]')
})
})
\ No newline at end of file
diff --git a/pages/composition-api/dependency-injection/provide/provide-inject.test.js b/pages/composition-api/dependency-injection/provide/provide-inject.test.js
index 7977474..8acd889 100644
--- a/pages/composition-api/dependency-injection/provide/provide-inject.test.js
+++ b/pages/composition-api/dependency-injection/provide/provide-inject.test.js
@@ -15,11 +15,11 @@ describe('provide-inject-hasInjectionContext', () => {
expect(await num.text()).toBe('num: 0')
const obj = await page.$('.obj')
- expect(await obj.text()).toBe(isWeb ? 'obj: {\n"a": 1\n}' : 'obj: {"a":1}')
+ expect(await obj.text()).toBe(isWeb ? 'obj: {"a": 1}' : 'obj: {"a":1}')
const arr = await page.$('.arr')
- expect(await arr.text()).toBe(isWeb ? 'arr: [\n1,\n2,\n3\n]' : 'arr: [1,2,3]')
+ expect(await arr.text()).toBe('arr: [1,2,3]')
const fn = await page.$('.fn')
expect(await fn.text()).toBe('fn: hello')
diff --git a/pages/composition-api/lifecycle/component-lifecycle/component-lifecycle.test.js b/pages/composition-api/lifecycle/component-lifecycle/component-lifecycle.test.js
index df1dcf3..f26bb9f 100644
--- a/pages/composition-api/lifecycle/component-lifecycle/component-lifecycle.test.js
+++ b/pages/composition-api/lifecycle/component-lifecycle/component-lifecycle.test.js
@@ -2,13 +2,6 @@ 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)
- })
- return
- }
let page
let lifeCycleNum
beforeAll(async () => {
diff --git a/pages/composition-api/lifecycle/page-lifecycle/page-lifecycle.test.js b/pages/composition-api/lifecycle/page-lifecycle/page-lifecycle.test.js
index 73fe1c5..d3dfd6b 100644
--- a/pages/composition-api/lifecycle/page-lifecycle/page-lifecycle.test.js
+++ b/pages/composition-api/lifecycle/page-lifecycle/page-lifecycle.test.js
@@ -4,14 +4,14 @@ const INTER_PAGE_PATH = '/pages/app-instance/index/index'
let page
let lifeCycleNum
-describe('page-lifecycle', () => {
+describe('page-lifecycle', () => {
if (process.env.uniTestPlatformInfo.startsWith('web')) {
- // TODO: 自动化测试暂不能调用web端setup内defineExpose导出的方法,待自动化测试兼容后开放此测试例
- it('web', async () => {
- expect(1).toBe(1)
- })
- return
- }
+ // TODO: onPageShow onPageHide 别名暂不支持
+ it('web', async () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
beforeAll(async () => {
page = await program.reLaunch(HOME_PATH)
await page.waitFor(700)
@@ -28,7 +28,7 @@ describe('page-lifecycle', () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(700)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(130)
+ expect(lifeCycleNum).toBe(120)
await page.callMethod('pageSetlifeCycleNum', 0)
})
it('onPullDownRefresh', async () => {
@@ -67,7 +67,7 @@ describe('page-lifecycle', () => {
page = await program.navigateTo(PAGE_PATH)
await page.waitFor(700)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(130)
+ expect(lifeCycleNum).toBe(120)
page = await program.navigateBack()
await page.waitFor('view')
lifeCycleNum = await page.callMethod('getLifeCycleNum')
diff --git a/pages/composition-api/reactivity/computed/computed.test.js b/pages/composition-api/reactivity/computed/computed.test.js
index 90a7e4f..6bed895 100644
--- a/pages/composition-api/reactivity/computed/computed.test.js
+++ b/pages/composition-api/reactivity/computed/computed.test.js
@@ -13,16 +13,16 @@ describe('computed', () => {
expect(await doubleCount.text()).toBe('computed double count: 0')
const objArr = await page.$('#obj-arr')
- expect((await objArr.text()).replaceAll('\n', '')).toBe('obj.arr: [1,2,3]')
+ expect(await objArr.text()).toBe('obj.arr: [1,2,3]')
const objArrLen = await page.$('#obj-arr-len')
expect(await objArrLen.text()).toBe('computed obj.arr.length: 3')
- const updateBtn = await page.$('.update-btn')
+ const updateBtn = await page.$('#update-btn')
await updateBtn.tap()
expect(await count.text()).toBe('count: 1')
expect(await doubleCount.text()).toBe('computed double count: 2')
- expect((await objArr.text()).replaceAll('\n', '')).toBe('obj.arr: [1,2,3,4]')
+ expect(await objArr.text()).toBe('obj.arr: [1,2,3,4]')
expect(await objArrLen.text()).toBe('computed obj.arr.length: 4')
})
diff --git a/pages/composition-api/reactivity/computed/computed.uvue b/pages/composition-api/reactivity/computed/computed.uvue
index bf59641..2ec5d0f 100644
--- a/pages/composition-api/reactivity/computed/computed.uvue
+++ b/pages/composition-api/reactivity/computed/computed.uvue
@@ -4,7 +4,7 @@
computed double count: {{ doubleCount }}
obj.arr: {{ obj.arr }}
computed obj.arr.length: {{ objArrLen }}
-
+
diff --git a/pages/composition-api/reactivity/reactive/reactive.test.js b/pages/composition-api/reactivity/reactive/reactive.test.js
index ad69625..298d89a 100644
--- a/pages/composition-api/reactivity/reactive/reactive.test.js
+++ b/pages/composition-api/reactivity/reactive/reactive.test.js
@@ -17,7 +17,7 @@ describe('reactive', () => {
expect(await objNum.text()).toBe('obj.num: 0')
const objArr = await page.$('#obj-arr')
- expect((await objArr.text()).replaceAll('\n', '')).toBe('obj.arr: ["a","b","c"]')
+ expect(await objArr.text()).toBe('obj.arr: ["a","b","c"]')
const updateBtn = await page.$('.update-btn')
await updateBtn.tap()
@@ -25,6 +25,6 @@ describe('reactive', () => {
expect(await count.text()).toBe('count: 2')
expect(await objStr.text()).toBe('obj.str: new str')
expect(await objNum.text()).toBe('obj.num: 2')
- expect((await objArr.text()).replaceAll('\n', '')).toBe('obj.arr: ["a","b","c","d"]')
+ expect(await objArr.text()).toBe('obj.arr: ["a","b","c","d"]')
})
})
\ No newline at end of file
diff --git a/pages/composition-api/reactivity/readonly/readonly.test.js b/pages/composition-api/reactivity/readonly/readonly.test.js
index 4926f1d..63e1c1a 100644
--- a/pages/composition-api/reactivity/readonly/readonly.test.js
+++ b/pages/composition-api/reactivity/readonly/readonly.test.js
@@ -1,7 +1,6 @@
const PAGE_PATH = '/pages/composition-api/reactivity/readonly/readonly'
-describe('ref', () => {
- const isWeb = process.env.uniTestPlatformInfo.startsWith('web')
+describe('ref', () => {
let page = null
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
@@ -13,33 +12,33 @@ describe('ref', () => {
const dataNum = await page.$('#data-num')
expect(await dataNum.text()).toBe('data.num: 0')
const dataArr = await page.$('#data-arr')
- expect(await dataArr.text()).toBe(isWeb ? 'data.arr: [\n"a",\n"b",\n"c"\n]' : 'data.arr: ["a","b","c"]')
+ expect(await dataArr.text()).toBe('data.arr: ["a","b","c"]')
const readonlyDataStr = await page.$('#readonly-data-str')
expect(await readonlyDataStr.text()).toBe('readonly data.str: default str')
const readonlyDataNum = await page.$('#readonly-data-num')
expect(await readonlyDataNum.text()).toBe('readonly data.num: 0')
const readonlyDataArr = await page.$('#readonly-data-arr')
- expect(await readonlyDataArr.text()).toBe(isWeb ? 'readonly data.arr: [\n"a",\n"b",\n"c"\n]' : 'readonly data.arr: ["a","b","c"]')
+ expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c"]')
const updateDataBtn = await page.$('#update-data-btn')
await updateDataBtn.tap()
expect(await dataStr.text()).toBe('data.str: new str')
expect(await dataNum.text()).toBe('data.num: 1')
- expect(await dataArr.text()).toBe(isWeb ? 'data.arr: [\n"a",\n"b",\n"c",\n"d"\n]' : 'data.arr: ["a","b","c","d"]')
+ expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]')
expect(await readonlyDataStr.text()).toBe('readonly data.str: new str')
expect(await readonlyDataNum.text()).toBe('readonly data.num: 1')
- expect(await readonlyDataArr.text()).toBe(isWeb ? 'readonly data.arr: [\n"a",\n"b",\n"c",\n"d"\n]' : 'readonly data.arr: ["a","b","c","d"]')
+ expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]')
const updateReadonlyDataBtn = await page.$('#update-readonly-data-btn')
await updateReadonlyDataBtn.tap()
expect(await dataStr.text()).toBe('data.str: new str')
expect(await dataNum.text()).toBe('data.num: 1')
- expect(await dataArr.text()).toBe(isWeb ? 'data.arr: [\n"a",\n"b",\n"c",\n"d"\n]' : 'data.arr: ["a","b","c","d"]')
+ expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]')
expect(await readonlyDataStr.text()).toBe('readonly data.str: new str')
expect(await readonlyDataNum.text()).toBe('readonly data.num: 1')
- expect(await readonlyDataArr.text()).toBe(isWeb ? 'readonly data.arr: [\n"a",\n"b",\n"c",\n"d"\n]' : 'readonly data.arr: ["a","b","c","d"]')
+ expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]')
})
})
\ No newline at end of file
diff --git a/pages/composition-api/reactivity/watch-effect/watch-effect.test.js b/pages/composition-api/reactivity/watch-effect/watch-effect.test.js
index 7b77108..661f989 100644
--- a/pages/composition-api/reactivity/watch-effect/watch-effect.test.js
+++ b/pages/composition-api/reactivity/watch-effect/watch-effect.test.js
@@ -76,7 +76,7 @@ describe('watchEffect', () => {
const objBool = await page.$('#obj-bool')
expect(await objBool.text()).toBe('obj.bool: false')
const objArr = await page.$('#obj-arr')
- expect((await objArr.text()).replaceAll('\n', '')).toBe('obj.arr: [0]')
+ expect(await objArr.text()).toBe('obj.arr: [0]')
const watchObjRes = await page.$('#watch-obj-res')
if (process.env.uniTestPlatformInfo.startsWith('android')) {
@@ -104,7 +104,7 @@ describe('watchEffect', () => {
expect(await objStr.text()).toBe('obj.str: num: 1')
expect(await objNum.text()).toBe('obj.num: 1')
expect(await objBool.text()).toBe('obj.bool: true')
- expect((await objArr.text()).replaceAll('\n', '')).toBe('obj.arr: [0,1]')
+ expect(await objArr.text()).toBe('obj.arr: [0,1]')
if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(await watchObjRes.text()).toBe(
diff --git a/pages/composition-api/reactivity/watch-post-effect/watch-post-effect.test.js b/pages/composition-api/reactivity/watch-post-effect/watch-post-effect.test.js
index cfd4a86..8d95e62 100644
--- a/pages/composition-api/reactivity/watch-post-effect/watch-post-effect.test.js
+++ b/pages/composition-api/reactivity/watch-post-effect/watch-post-effect.test.js
@@ -78,7 +78,7 @@ describe('watchPostEffect', () => {
const objBool = await page.$('#obj-bool')
expect(await objBool.text()).toBe('obj.bool: false')
const objArr = await page.$('#obj-arr')
- expect(await objArr.text()).toBe(isWeb ? 'obj.arr: [\n0\n]' : 'obj.arr: [0]')
+ expect(await objArr.text()).toBe('obj.arr: [0]')
const watchObjRes = await page.$('#watch-obj-res')
// TODO web端和安卓端JSON.stringify对属性的排序不一致
@@ -99,16 +99,16 @@ describe('watchPostEffect', () => {
expect(await objStr.text()).toBe('obj.str: num: 1')
expect(await objNum.text()).toBe('obj.num: 1')
expect(await objBool.text()).toBe('obj.bool: true')
- expect(await objArr.text()).toBe(isWeb ? 'obj.arr: [\n0,\n1\n]' : 'obj.arr: [0,1]')
+ expect(await objArr.text()).toBe('obj.arr: [0,1]')
expect(await watchObjRes.text()).toBe(
isWeb ?
- 'watch obj result: obj: {"num":0,"str":"num: 0","bool":false,"arr":[0]}' :
+ 'watch obj result: obj: {"num":1,"str":"num: 1","bool":true,"arr":[0,1]}' :
'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}'
)
expect(await watchObjStrRes.text()).toBe(
'watch obj.str result: str: num: 1, obj.str ref text: obj.str: num: 1')
- expect(await watchObjArrRes.text()).toBe(isWeb ? 'watch obj.arr result: arr: [\n0,\n1\n]' :
+ expect(await watchObjArrRes.text()).toBe(
'watch obj.arr result: arr: [0,1]')
const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res')
diff --git a/pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect.test.js b/pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect.test.js
index bb6f28f..564f4de 100644
--- a/pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect.test.js
+++ b/pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect.test.js
@@ -76,7 +76,7 @@ describe('watchSyncEffect', () => {
const objBool = await page.$('#obj-bool')
expect(await objBool.text()).toBe('obj.bool: false')
const objArr = await page.$('#obj-arr')
- expect(await objArr.text()).toBe(isWeb ? 'obj.arr: [\n0\n]' : 'obj.arr: [0]')
+ expect(await objArr.text()).toBe('obj.arr: [0]')
const watchObjRes = await page.$('#watch-obj-res')
expect(await watchObjRes.text()).toBe(
@@ -96,7 +96,7 @@ describe('watchSyncEffect', () => {
expect(await objStr.text()).toBe('obj.str: num: 1')
expect(await objNum.text()).toBe('obj.num: 1')
expect(await objBool.text()).toBe('obj.bool: true')
- expect(await objArr.text()).toBe(isWeb ? 'obj.arr: [\n0,\n1\n]' : 'obj.arr: [0,1]')
+ expect(await objArr.text()).toBe('obj.arr: [0,1]')
expect(await watchObjRes.text()).toBe(
isWeb ?
diff --git a/pages/composition-api/reactivity/watch/watch.test.js b/pages/composition-api/reactivity/watch/watch.test.js
index 6538f45..751d317 100644
--- a/pages/composition-api/reactivity/watch/watch.test.js
+++ b/pages/composition-api/reactivity/watch/watch.test.js
@@ -81,7 +81,7 @@ describe('watch', () => {
const objBool = await page.$('#obj-bool')
expect(await objBool.text()).toBe('obj.bool: false')
const objArr = await page.$('#obj-arr')
- expect((await objArr.text()).replaceAll('\n', '')).toBe('obj.arr: [0]')
+ expect(await objArr.text()).toBe('obj.arr: [0]')
const watchObjRes = await page.$('#watch-obj-res')
if (process.env.uniTestPlatformInfo.startsWith('android')) {
@@ -107,7 +107,7 @@ describe('watch', () => {
expect(await objStr.text()).toBe('obj.str: num: 1')
expect(await objNum.text()).toBe('obj.num: 1')
expect(await objBool.text()).toBe('obj.bool: true')
- expect((await objArr.text()).replaceAll('\n', '')).toBe('obj.arr: [0,1]')
+ expect(await objArr.text()).toBe('obj.arr: [0,1]')
if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(await watchObjRes.text()).toBe(
diff --git a/pages/composition/provide/provide-page2.test.js b/pages/composition/provide/provide-page2.test.js
index 26d8db6..df318f8 100644
--- a/pages/composition/provide/provide-page2.test.js
+++ b/pages/composition/provide/provide-page2.test.js
@@ -51,21 +51,21 @@ describe('函数方式创建 provide', () => {
const providePageArrEl = await page.$('.provide-page-arr')
const providePageArrText = await providePageArrEl.text()
expect(providePageArrText).toBe(
- isWeb ? 'providePageArr: [\n"函数方式定义 provide page arr"\n]' : 'providePageArr: ["函数方式定义 provide page arr"]'
+ 'providePageArr: ["函数方式定义 provide page arr"]'
)
})
it('map', async () => {
const providePageMapEl = await page.$('.provide-page-map')
const providePageMapText = await providePageMapEl.text()
expect(providePageMapText).toBe(
- isWeb ? 'providePageMap: {\n"key": "函数方式定义 provide page map"\n}' : 'providePageMap: {"key":"函数方式定义 provide page map"}'
+ isWeb ? 'providePageMap: {"key": "函数方式定义 provide page map"}' : 'providePageMap: {"key":"函数方式定义 provide page map"}'
)
})
it('set', async () => {
const providePageSetEl = await page.$('.provide-page-set')
const providePageSetText = await providePageSetEl.text()
expect(providePageSetText).toBe(
- isWeb ? 'providePageSet: [\n"函数方式定义 provide page set"\n]' : 'providePageSet: ["函数方式定义 provide page set"]'
+ 'providePageSet: ["函数方式定义 provide page set"]'
)
})
})
diff --git a/pages/composition/provide/provide.test.js b/pages/composition/provide/provide.test.js
index e3508c5..8f03946 100644
--- a/pages/composition/provide/provide.test.js
+++ b/pages/composition/provide/provide.test.js
@@ -51,21 +51,21 @@ describe('字面量方式创建 provide', () => {
const providePageArrEl = await page.$('.provide-page-arr')
const providePageArrText = await providePageArrEl.text()
expect(providePageArrText).toBe(
- isWeb ? 'providePageArr: [\n"字面量方式定义 provide page arr"\n]' : 'providePageArr: ["字面量方式定义 provide page arr"]'
+ 'providePageArr: ["字面量方式定义 provide page arr"]'
)
})
it('map', async () => {
const providePageMapEl = await page.$('.provide-page-map')
const providePageMapText = await providePageMapEl.text()
expect(providePageMapText).toBe(
- isWeb ? 'providePageMap: {\n"key": "字面量方式定义 provide page map"\n}' : 'providePageMap: {"key":"字面量方式定义 provide page map"}'
+ isWeb ? 'providePageMap: {"key": "字面量方式定义 provide page map"}' : 'providePageMap: {"key":"字面量方式定义 provide page map"}'
)
})
it('set', async () => {
const providePageSetEl = await page.$('.provide-page-set')
const providePageSetText = await providePageSetEl.text()
expect(providePageSetText).toBe(
- isWeb ? 'providePageSet: [\n"字面量方式定义 provide page set"\n]' : 'providePageSet: ["字面量方式定义 provide page set"]'
+ 'providePageSet: ["字面量方式定义 provide page set"]'
)
})
it('string default value', async () => {
@@ -97,4 +97,4 @@ describe('字面量方式创建 provide', () => {
'testInjectObjectDefaultValue.content: test inject object default value content'
)
})
-})
+})
\ No newline at end of file
diff --git a/pages/directive/v-model/v-model.test.js b/pages/directive/v-model/v-model.test.js
index 8689e71..8f1cf75 100644
--- a/pages/directive/v-model/v-model.test.js
+++ b/pages/directive/v-model/v-model.test.js
@@ -1,26 +1,23 @@
-const PAGE_PATH = '/pages/directive/v-model/v-model'
-
-describe('v-model', () => {
- if (process.env.uniTestPlatformInfo.startsWith('web')) {
- // TODO: web 自动化测试InputElement input方法报错
- it('web', async () => {
- expect(1).toBe(1)
- })
- return
- }
- let page
- beforeAll(async () => {
- page = await program.reLaunch(PAGE_PATH)
- await page.waitFor(500)
- })
-
- it('input', async () => {
- const value = Date.now() + ''
-
- const inputElement = await page.$('.input')
- await inputElement.input(value)
-
- const inputValueElement = await page.$('.input-value')
- expect(await inputValueElement.text()).toBe(value)
- })
+const PAGE_PATH = '/pages/directive/v-model/v-model'
+
+describe('v-model', () => {
+ let page
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(500)
+ })
+
+ it('input', async () => {
+ const value = Date.now() + ''
+
+ // TODO: 自动化测试web端存在问题
+ // 1. 直接获取 input 由于 web 端 input 为框架封装的自定义组件,所以被自动化测试框架识别为组定义组件,而不是 input element
+ // 2. 通过 class 获取标准 input element,自动化测试框架 isValidEl 限制只允许获取 uni element
+ if (process.env.uniTestPlatformInfo.startsWith('android')) {
+ const inputElement = await page.$('.input')
+ await inputElement.input(value)
+ const inputValueElement = await page.$('.input-value')
+ expect(await inputValueElement.text()).toBe(value)
+ }
+ })
})
\ No newline at end of file
diff --git a/pages/lifecycle/page/page.test.js b/pages/lifecycle/page/page.test.js
index c35c664..5bfc501 100644
--- a/pages/lifecycle/page/page.test.js
+++ b/pages/lifecycle/page/page.test.js
@@ -1,98 +1,89 @@
-const PAGE_PATH = '/pages/lifecycle/page/page'
+const PAGE_PATH = '/pages/lifecycle/page/page'
const HOME_PATH = '/pages/tab-bar/options-api'
const INTER_PAGE_PATH = '/pages/app-instance/index/index'
let page
let lifeCycleNum
describe('app-lifecycle', () => {
- it('onLaunch onShow', async () => {
- page = await program.reLaunch(HOME_PATH)
- await page.waitFor(700)
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(1100)
- })
- it('onLastPageBackPress', async () => {
- if (process.env.uniTestPlatformInfo.startsWith('android')) {
- page = await program.navigateBack()
- await page.waitFor(700)
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(100)
- }
- await page.callMethod('setLifeCycleNum', 0)
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(0)
- })
+ it('onLaunch onShow', async () => {
+ page = await program.reLaunch(HOME_PATH)
+ await page.waitFor(700)
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(1100)
+ })
+ it('onLastPageBackPress', async () => {
+ if (process.env.uniTestPlatformInfo.startsWith('android')) {
+ page = await program.navigateBack()
+ await page.waitFor(700)
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(100)
+ }
+ await page.callMethod('setLifeCycleNum', 0)
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(0)
+ })
})
describe('page-lifecycle', () => {
- afterAll(async () => {
- const resetLifecycleNum = 1100
- await page.callMethod('setLifeCycleNum', resetLifecycleNum)
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(resetLifecycleNum)
- })
+ afterAll(async () => {
+ const resetLifecycleNum = 1100
+ await page.callMethod('setLifeCycleNum', resetLifecycleNum)
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(resetLifecycleNum)
+ })
- it('onLoad onShow onReady onResize', async () => {
- page = await program.reLaunch(PAGE_PATH)
- await page.waitFor(700)
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- // 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 () => {
- await page.callMethod('pullDownRefresh')
- await page.waitFor(1500)
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(10)
- await page.callMethod('setLifeCycleNum', 0)
- })
- it('onPageScroll onReachBottom', async () => {
- await program.pageScrollTo(2000)
- const data = await page.data()
- expect(data.isScrolled).toBe(true)
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(10)
- await page.callMethod('setLifeCycleNum', 0)
- })
- it('onHide', async () => {
- page = await program.navigateTo(INTER_PAGE_PATH)
- await page.waitFor('view')
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(-10)
- page = await program.navigateBack()
- await page.waitFor('view')
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(0)
- })
- it('onUnload', async () => {
- page = await program.reLaunch(HOME_PATH)
- await page.waitFor(700)
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- expect(lifeCycleNum).toBe(-100)
- await page.callMethod('setLifeCycleNum', 0)
- })
- it('onBackPress', async () => {
- page = await program.navigateTo(PAGE_PATH)
- await page.waitFor(700)
- lifeCycleNum = await page.callMethod('getLifeCycleNum')
- 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')
- if (process.env.uniTestPlatformInfo.startsWith('android')) {
+ it('onLoad onShow onReady onResize', async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(700)
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(120)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+ it('onPullDownRefresh', async () => {
+ await page.callMethod('pullDownRefresh')
+ await page.waitFor(1500)
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(10)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+ it('onPageScroll onReachBottom', async () => {
+ await program.pageScrollTo(2000)
+ const data = await page.data()
+ expect(data.isScrolled).toBe(true)
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(10)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+ it('onHide', async () => {
+ page = await program.navigateTo(INTER_PAGE_PATH)
+ await page.waitFor('view')
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(-10)
+ page = await program.navigateBack()
+ await page.waitFor('view')
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(0)
+ })
+ it('onUnload', async () => {
+ page = await program.reLaunch(HOME_PATH)
+ await page.waitFor(700)
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(-100)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+ it('onBackPress', async () => {
+ page = await program.navigateTo(PAGE_PATH)
+ await page.waitFor(700)
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifeCycleNum).toBe(120)
+ page = await program.navigateBack()
+ await page.waitFor('view')
+ lifeCycleNum = await page.callMethod('getLifeCycleNum')
+ if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(lifeCycleNum).toBe(20)
- } else if(process.env.uniTestPlatformInfo.startsWith('web')){
+ } else if (process.env.uniTestPlatformInfo.startsWith('web')) {
expect(lifeCycleNum).toBe(10)
}
- await page.callMethod('setLifeCycleNum', 0)
- })
+ await page.callMethod('setLifeCycleNum', 0)
+ })
})
\ No newline at end of file
--
GitLab