diff --git a/pages.json b/pages.json index 49cd951fe6083fbc06ae3cbe97907e8361043ef8..9d3393309277445bf13627be41da806f51d80ae1 100644 --- a/pages.json +++ b/pages.json @@ -183,6 +183,7 @@ "navigationBarTitleText": "$options" } }, + // #ifdef APP { "path": "pages/component-instance/parent/parent", "style": { @@ -195,6 +196,7 @@ "navigationBarTitleText": "$root" } }, + // #endif { "path": "pages/component-instance/slots/slots", "style": { @@ -506,13 +508,13 @@ "navigationBarTitleText": "toValue" } }, - // #endif { "path": "pages/composition-api/reactivity/to-refs/to-refs", "style": { "navigationBarTitleText": "toRefs" } }, + // #endif { "path": "pages/composition-api/reactivity/is-proxy/is-proxy", "style": { diff --git a/pages/component-instance/methods/call-method-easycom.uvue b/pages/component-instance/methods/call-method-easycom.uvue index a198fe7c48a617764cfb9bb73bdb04ad660664c0..2e5adeda006d90898f6c9648bfb020e1b66fd2b9 100644 --- a/pages/component-instance/methods/call-method-easycom.uvue +++ b/pages/component-instance/methods/call-method-easycom.uvue @@ -8,39 +8,39 @@ export default { data() { return { - $callEasyMethod1: null as CallEasyMethodComponentPublicInstance | null + callEasyMethod1: null as CallEasyMethodComponentPublicInstance | null } }, onReady() { // 通过组件 ref 属性获取组件实例, 组件标签名首字母大写,驼峰+ComponentPublicInstance - this.$callEasyMethod1 = this.$refs['callEasyMethod1'] as CallEasyMethodComponentPublicInstance; + this.callEasyMethod1 = this.$refs['callEasyMethod1'] as CallEasyMethodComponentPublicInstance; }, 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; }, } diff --git a/pages/component-instance/methods/call-method-uni-element.uvue b/pages/component-instance/methods/call-method-uni-element.uvue index 65bcbf3d8af65b0d1211b7cb5cb8f6c73a101876..c5b08b06a5a0f82c6430681ac2fa9d5e35ffa85e 100644 --- a/pages/component-instance/methods/call-method-uni-element.uvue +++ b/pages/component-instance/methods/call-method-uni-element.uvue @@ -8,22 +8,22 @@ export default { data() { return { - $slider1: null as UniSliderElement | null + slider1: null as UniSliderElement | null } }, onReady() { // 通过组件 ref 属性获取组件实例, Uni组件名(驼峰)UniElement - this.$slider1 = this.$refs['slider1'] as UniSliderElement; + this.slider1 = this.$refs['slider1'] as UniSliderElement; }, methods: { setValue() : boolean { // 设置组件的 value 属性 - this.$slider1!.value = 80; + this.slider1!.value = 80; return true; }, callMethodTest(text: string): string | null { - this.$slider1!.setAttribute('value', text); - const result = this.$slider1!.getAttribute('value') as string; + this.slider1!.setAttribute('str', text); + const result = this.slider1!.getAttribute('str') as string; return result; }, } diff --git a/pages/component-instance/root/root.test.js b/pages/component-instance/root/root.test.js index c3a05090868daa1e0dee40ee5fbd300bd24bd887..dc60ee209e814636369231f50cf68a21d5fa4f0a 100644 --- a/pages/component-instance/root/root.test.js +++ b/pages/component-instance/root/root.test.js @@ -1,6 +1,13 @@ const PAGE_PATH = '/pages/component-instance/root/root' describe('$root', () => { + if (process.env.uniTestPlatformInfo.startsWith('web')) { + // TODO: web 端$root指向和app端不同,具体待定 + it('web', async () => { + expect(1).toBe(1) + }) + return + } let page beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) diff --git a/pages/component-instance/root/root.uvue b/pages/component-instance/root/root.uvue index 2e86761e82511b78cd9376773f29b4011fee96ad..7a3274400541779e0b1e899c58a097e21f805df6 100644 --- a/pages/component-instance/root/root.uvue +++ b/pages/component-instance/root/root.uvue @@ -11,6 +11,9 @@ export default { root: true } }, + onReady() { + console.log(this.getRoot()) + }, methods: { getRoot (): boolean { return this.$root!.$data['root'] as boolean 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 6e71429ac6e84f4605b80fd2bb1622978f5245c1..797747417e005eaa622a2edf9c0fdba927adab3a 100644 --- a/pages/composition-api/dependency-injection/provide/provide-inject.test.js +++ b/pages/composition-api/dependency-injection/provide/provide-inject.test.js @@ -1,6 +1,7 @@ const PAGE_PATH = '/pages/composition-api/dependency-injection/provide/provide' describe('provide-inject-hasInjectionContext', () => { + const isWeb = process.env.uniTestPlatformInfo.startsWith('web') let page = null beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) @@ -14,11 +15,11 @@ describe('provide-inject-hasInjectionContext', () => { expect(await num.text()).toBe('num: 0') const obj = await page.$('.obj') - expect(await obj.text()).toBe('obj: {"a":1}') + expect(await obj.text()).toBe(isWeb ? 'obj: {\n"a": 1\n}' : 'obj: {"a":1}') const arr = await page.$('.arr') - expect(await arr.text()).toBe('arr: [1,2,3]') + expect(await arr.text()).toBe(isWeb ? 'arr: [\n1,\n2,\n3\n]' : 'arr: [1,2,3]') const fn = await page.$('.fn') expect(await fn.text()).toBe('fn: hello') diff --git a/pages/composition-api/reactivity/effect-scope/effect-scope.test.js b/pages/composition-api/reactivity/effect-scope/effect-scope.test.js index f9ec72412d9d0085a2d90335b5f6e5a8bab2023c..1ffc7e7f42501b94157682b29c2e4b62198fe5f3 100644 --- a/pages/composition-api/reactivity/effect-scope/effect-scope.test.js +++ b/pages/composition-api/reactivity/effect-scope/effect-scope.test.js @@ -1,6 +1,7 @@ const PAGE_PATH = '/pages/composition-api/reactivity/effect-scope/effect-scope' describe('effectScope', () => { + const isWeb = process.env.uniTestPlatformInfo.startsWith('web') let page = null beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) @@ -11,7 +12,7 @@ describe('effectScope', () => { expect(await counter.text()).toBe('counter: 0') const watchCounterRes = await page.$('#watch-counter-res') - expect(await watchCounterRes.text()).toBe('watch counter result: ') + expect(await watchCounterRes.text()).toBe(isWeb ? 'watch counter result:' : 'watch counter result: ') const watchEffectCounterRes = await page.$('#watch-effect-counter-res') expect(await watchEffectCounterRes.text()).toBe('watchEffect counter result: counter: 0') diff --git a/pages/composition-api/reactivity/readonly/readonly.test.js b/pages/composition-api/reactivity/readonly/readonly.test.js index 63e1c1af793c566fbe37ef957c2b481d0a272867..474341c1f66b32ad4ef0aa3d1f6eb0698d4e1d34 100644 --- a/pages/composition-api/reactivity/readonly/readonly.test.js +++ b/pages/composition-api/reactivity/readonly/readonly.test.js @@ -1,6 +1,7 @@ const PAGE_PATH = '/pages/composition-api/reactivity/readonly/readonly' -describe('ref', () => { +describe('ref', () => { + const isWeb = process.env.uniTestPlatformInfo.startsWith('web') let page = null beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) @@ -12,33 +13,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('data.arr: ["a","b","c"]') + expect(await dataArr.text()).toBe(isWeb ? 'data.arr: [\n"a",\n"b",\n"c"\n]' : '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('readonly data.arr: ["a","b","c"]') + expect(await readonlyDataArr.text()).toBe(isWeb ? 'readonly data.arr: [\n"a",\n"b",\n"c"\n]' : '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('data.arr: ["a","b","c","d"]') + 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 readonlyDataStr.text()).toBe('readonly data.str: new str') expect(await readonlyDataNum.text()).toBe('readonly data.num: 1') - expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]') + 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"]') 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('data.arr: ["a","b","c","d"]') + expect(await dataArr.text()).toBe(isWeb ? 'data.arr: [\n"a",\n"b",\n"c",\n"d"]' : '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('readonly data.arr: ["a","b","c","d"]') + 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"]') }) }) \ No newline at end of file diff --git a/pages/composition-api/reactivity/to-ref/to-ref.test.js b/pages/composition-api/reactivity/to-ref/to-ref.test.js index 7f0c46aea40a33c01cf0ef37dc3f912d63e735ce..8badff402410c5298977a640f9507c59f6683f03 100644 --- a/pages/composition-api/reactivity/to-ref/to-ref.test.js +++ b/pages/composition-api/reactivity/to-ref/to-ref.test.js @@ -1,6 +1,13 @@ const PAGE_PATH = '/pages/composition-api/reactivity/to-ref/to-ref' describe('toRef', () => { + if (process.env.uniTestPlatformInfo.startsWith('web')) { + // TODO: web 端暂不支持 + it('web', async () => { + expect(1).toBe(1) + }) + return + } let page = null beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) 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 d3740d7518f7cc09bb1433687af69a2291a0933b..7479d4aa793278bc59fe2156945a979020b5c4b1 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 @@ -1,6 +1,7 @@ const PAGE_PATH = '/pages/composition-api/reactivity/watch-post-effect/watch-post-effect' describe('watchPostEffect', () => { + const isWeb = process.env.uniTestPlatformInfo.startsWith('web') let page = null beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) @@ -23,7 +24,9 @@ describe('watchPostEffect', () => { const watchCountTriggerNum = await page.$('#watch-count-trigger-num') expect(await watchCountTriggerNum.text()).toBe('watch count trigger number: 0') const watchCountCleanupRes = await page.$('#watch-count-cleanup-res') - expect(await watchCountCleanupRes.text()).toBe('watch count cleanup result: ') + // TODO web端自动化测试text方法应使用textContent获取内容来保留空格,目前text方法未保留首尾空格 + expect(await watchCountCleanupRes.text()).toBe(isWeb ? 'watch count cleanup result:' : + 'watch count cleanup result: ') // watch count and obj.num const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res') @@ -75,11 +78,15 @@ 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('obj.arr: [0]') + expect(await objArr.text()).toBe(isWeb ? 'obj.arr: [\n0\n]' : 'obj.arr: [0]') const watchObjRes = await page.$('#watch-obj-res') + // TODO web端和安卓端JSON.stringify对属性的排序不一致 expect(await watchObjRes.text()).toBe( - 'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}') + isWeb ? + 'watch obj result: obj: {"num":0,"str":"num: 0","bool":false,"arr":[0]}' : + 'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}' + ) const watchObjStrRes = await page.$('#watch-obj-str-res') expect(await watchObjStrRes.text()).toBe( 'watch obj.str result: str: num: 0, obj.str ref text: obj.str: num: 0') @@ -92,13 +99,14 @@ 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('obj.arr: [0,1]') + expect(await objArr.text()).toBe(isWeb ? 'obj.arr: [\n0,\n1\n]' : 'obj.arr: [0,1]') expect(await watchObjRes.text()).toBe( '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('watch obj.arr result: arr: [0,1]') + expect(await watchObjArrRes.text()).toBe(isWeb ? 'watch obj.arr result: arr: [\n0,\n1\n]' : + 'watch obj.arr result: arr: [0,1]') const watchCountAndObjNumRes = await page.$('#watch-count-obj-num-res') expect(await watchCountAndObjNumRes.text()).toBe('watch count and obj.num result: count: 3, obj.num: 1') diff --git a/pages/composition-api/reactivity/watch-post-effect/watch-post-effect.uvue b/pages/composition-api/reactivity/watch-post-effect/watch-post-effect.uvue index 29782dea4ab26a41d712d62e888e3d2b2ac9c696..76bfa686ee5710c41f61bad626c74559dc9659de 100644 --- a/pages/composition-api/reactivity/watch-post-effect/watch-post-effect.uvue +++ b/pages/composition-api/reactivity/watch-post-effect/watch-post-effect.uvue @@ -8,8 +8,7 @@ watch count track number: {{ watchCountTrackNum }} watch count trigger number: {{ watchCountTriggerNum }} - watch count cleanup result: - {{ watchCountCleanupRes }} + watch count cleanup result: {{ watchCountCleanupRes }} 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 ff821e2eeb5b921c5760994f2adf96b871413cbf..036244c29a5a482cb36d777796a3ab708032d3c2 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 @@ -1,6 +1,7 @@ const PAGE_PATH = '/pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect' describe('watchSyncEffect', () => { + const isWeb = process.env.uniTestPlatformInfo.startsWith('web') let page = null beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) @@ -75,11 +76,14 @@ 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('obj.arr: [0]') + expect(await objArr.text()).toBe(isWeb ? 'obj.arr: [\n0\n]' : 'obj.arr: [0]') const watchObjRes = await page.$('#watch-obj-res') expect(await watchObjRes.text()).toBe( - 'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}') + isWeb ? + 'watch obj result: obj: {"num":0,"str":"num: 0","bool":false,"arr":[0]}' : + 'watch obj result: obj: {"arr":[0],"bool":false,"num":0,"str":"num: 0"}' + ) const watchObjStrRes = await page.$('#watch-obj-str-res') expect(await watchObjStrRes.text()).toBe( 'watch obj.str result: str: num: 0, obj.str ref text: obj.str: num: 0') diff --git a/pages/composition/mixins/mixins.test.js b/pages/composition/mixins/mixins.test.js index 019a114f7ac480e3d5075413c9afbd6ce1d45381..abda60d1621b9d5eb729a9d10fdd7cb6d509cda6 100644 --- a/pages/composition/mixins/mixins.test.js +++ b/pages/composition/mixins/mixins.test.js @@ -2,7 +2,7 @@ const PAGE_PATH = '/pages/composition/mixins/mixins' let page describe('mixins', () => { - if (process.env.uniTestPlatformInfo.startsWith('android')) { + if (process.env.uniTestPlatformInfo.startsWith('web')) { // TODO: web 端暂不支持 it('web', async () => { expect(1).toBe(1) diff --git a/pages/composition/setup/setup.test.js b/pages/composition/setup/setup.test.js index 1d1e75ba60488600415fd43ba582516b30c2bc74..e74b1d852b0fe9913b27fdbdb66404f94c7c4fc5 100644 --- a/pages/composition/setup/setup.test.js +++ b/pages/composition/setup/setup.test.js @@ -1,82 +1,91 @@ +// TODO web端 + const PAGE_PATH = '/pages/composition/setup/setup' describe('options setup', () => { - let page - beforeAll(async () => { - page = await program.reLaunch(PAGE_PATH) - await page.waitFor('view') - }) - it('basic', async () => { - const str = await page.$('#str') - expect(await str.text()).toBe('str: default str') - const num = await page.$('#num') - expect(await num.text()).toBe('num: 0') - const bool = await page.$('#bool') - expect(await bool.text()).toBe('bool: false') + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('basic', async () => { + const str = await page.$('#str') + expect(await str.text()).toBe('str: default str') + const num = await page.$('#num') + expect(await num.text()).toBe('num: 0') + const bool = await page.$('#bool') + expect(await bool.text()).toBe('bool: false') + + const count = await page.$('#count') + expect(await count.text()).toBe('count: 0') - const count = await page.$('#count') - expect(await count.text()).toBe('count: 0') + const objStr = await page.$('#obj-str') + expect(await objStr.text()).toBe('obj.str: obj default str') + const objNum = await page.$('#obj-num') + expect(await objNum.text()).toBe('obj.num: 0') + const objBool = await page.$('#obj-bool') + expect(await objBool.text()).toBe('obj.bool: false') - const objStr = await page.$('#obj-str') - expect(await objStr.text()).toBe('obj.str: obj default str') - const objNum = await page.$('#obj-num') - expect(await objNum.text()).toBe('obj.num: 0') - const objBool = await page.$('#obj-bool') - expect(await objBool.text()).toBe('obj.bool: false') + if (!process.env.uniTestPlatformInfo.startsWith('web')) { + const propsStr = await page.$('#props-str') + expect(await propsStr.text()).toBe('props.str: default str') + const propsCount = await page.$('#props-count') + expect(await propsCount.text()).toBe('props.count: 0') + const propsObjStr = await page.$('#props-obj-str') + expect(await propsObjStr.text()).toBe(`props.obj['str']: obj default str`) + const propsObjNum = await page.$('#props-obj-num') + expect(await propsObjNum.text()).toBe(`props.obj['num']: 0`) + const propsObjBool = await page.$('#props-obj-bool') + expect(await propsObjBool.text()).toBe(`props.obj['bool']: false`) + } + }) + it('props', async () => { + const incrementBtn = await page.$('#increment-btn') + await incrementBtn.tap() - const propsStr = await page.$('#props-str') - expect(await propsStr.text()).toBe('props.str: default str') - const propsCount = await page.$('#props-count') - expect(await propsCount.text()).toBe('props.count: 0') - const propsObjStr = await page.$('#props-obj-str') - expect(await propsObjStr.text()).toBe(`props.obj['str']: obj default str`) - const propsObjNum = await page.$('#props-obj-num') - expect(await propsObjNum.text()).toBe(`props.obj['num']: 0`) - const propsObjBool = await page.$('#props-obj-bool') - expect(await propsObjBool.text()).toBe(`props.obj['bool']: false`) - }) - it('props', async () => { - const incrementBtn = await page.$('#increment-btn') - await incrementBtn.tap() + const count = await page.$('#count') + expect(await count.text()).toBe('count: 1') + const propsCount = await page.$('#props-count') + expect(await propsCount.text()).toBe('props.count: 1') - const count = await page.$('#count') - expect(await count.text()).toBe('count: 1') - const propsCount = await page.$('#props-count') - expect(await propsCount.text()).toBe('props.count: 1') + const updateObjBtn = await page.$('#update-obj-btn') + await updateObjBtn.tap() - const updateObjBtn = await page.$('#update-obj-btn') - await updateObjBtn.tap() + const objStr = await page.$('#obj-str') + expect(await objStr.text()).toBe('obj.str: obj new str') + const objNum = await page.$('#obj-num') + expect(await objNum.text()).toBe('obj.num: 100') + const objBool = await page.$('#obj-bool') + expect(await objBool.text()).toBe('obj.bool: true') - const objStr = await page.$('#obj-str') - expect(await objStr.text()).toBe('obj.str: obj new str') - const objNum = await page.$('#obj-num') - expect(await objNum.text()).toBe('obj.num: 100') - const objBool = await page.$('#obj-bool') - expect(await objBool.text()).toBe('obj.bool: true') + if (!process.env.uniTestPlatformInfo.startsWith('web')) { + const propsObjStr = await page.$('#props-obj-str') + expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str`) + const propsObjNum = await page.$('#props-obj-num') + expect(await propsObjNum.text()).toBe(`props.obj['num']: 100`) + const propsObjBool = await page.$('#props-obj-bool') + expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`) + } + }) + it('context', async () => { + if (!process.env.uniTestPlatformInfo.startsWith('web')) { + // attrs + const contextAttrsIsShow = await page.$('#context-attrs-is-show') + expect(await contextAttrsIsShow.text()).toBe('context.attrs.isShow: true') - const propsObjStr = await page.$('#props-obj-str') - expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str`) - const propsObjNum = await page.$('#props-obj-num') - expect(await propsObjNum.text()).toBe(`props.obj['num']: 100`) - const propsObjBool = await page.$('#props-obj-bool') - expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`) - }) - it('context', async () => { - // attrs - const contextAttrsIsShow = await page.$('#context-attrs-is-show') - expect(await contextAttrsIsShow.text()).toBe('context.attrs.isShow: true') - // emits - const compUpdateObjBtn = await page.$('#comp-update-obj-btn') - await compUpdateObjBtn.tap() - const propsObjStr = await page.$('#props-obj-str') - expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str by comp update`) - const propsObjNum = await page.$('#props-obj-num') - expect(await propsObjNum.text()).toBe(`props.obj['num']: 200`) - const propsObjBool = await page.$('#props-obj-bool') - expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`) - // slots - const defaultSlotInFoo = await page.$('#default-slot-in-foo') - expect(await defaultSlotInFoo.text()).toBe('default slot in Foo') - const hasDefaultSlot = await page.$('#has-default-slot') - expect(await hasDefaultSlot.text()).toBe('hasDefaultSlot: true') - }) + // emits + const compUpdateObjBtn = await page.$('#comp-update-obj-btn') + await compUpdateObjBtn.tap() + const propsObjStr = await page.$('#props-obj-str') + expect(await propsObjStr.text()).toBe(`props.obj['str']: obj new str by comp update`) + const propsObjNum = await page.$('#props-obj-num') + expect(await propsObjNum.text()).toBe(`props.obj['num']: 200`) + const propsObjBool = await page.$('#props-obj-bool') + expect(await propsObjBool.text()).toBe(`props.obj['bool']: true`) + } + // slots + const defaultSlotInFoo = await page.$('#default-slot-in-foo') + expect(await defaultSlotInFoo.text()).toBe('default slot in Foo') + const hasDefaultSlot = await page.$('#has-default-slot') + expect(await hasDefaultSlot.text()).toBe('hasDefaultSlot: true') + }) }) \ No newline at end of file diff --git a/pages/composition/setup/setup.uvue b/pages/composition/setup/setup.uvue index c5c9989c25760d55d11b3e063fcf5a6fc2a5b12a..35ad655104611ef3e460b798160fa0e3fe89e458 100644 --- a/pages/composition/setup/setup.uvue +++ b/pages/composition/setup/setup.uvue @@ -1,64 +1,70 @@ + // #ifdef APP + import RenderFunction from './RenderFunction.uvue' + // #endif + import Foo from './Foo.uvue' + export default { + components: { + // #ifdef APP + RenderFunction, + // #endif + Foo + }, + setup() { + const count = ref(0) + // 函数只能通过声明变量,赋值函数的方式,不支持 function xxx(){} + const increment = () => { count.value++ } + const obj = reactive({ + str: 'obj default str', + num: 0, + bool: false, + }) + const updateObj = () => { + obj['str'] = 'obj new str' + obj['num'] = 100 + obj['bool'] = true + } + const compUpdateObj = () => { + obj['str'] = 'obj new str by comp update' + obj['num'] = 200 + obj['bool'] = true + } + return { + str: 'default str', + num: 0, + bool: false, + count, + increment, + obj, + updateObj, + compUpdateObj + } + } + } + \ 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 d9a09c6e4aa3365eeb6a2c015232b46d77d0399f..8689e71daad9f98d571a940f5d7859410158436b 100644 --- a/pages/directive/v-model/v-model.test.js +++ b/pages/directive/v-model/v-model.test.js @@ -1,11 +1,19 @@ 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() + '' @@ -15,4 +23,4 @@ describe('v-model', () => { const inputValueElement = await page.$('.input-value') expect(await inputValueElement.text()).toBe(value) }) -}) +}) \ No newline at end of file diff --git a/pages/tab-bar/composition-api.uvue b/pages/tab-bar/composition-api.uvue index f481f08a484d0da968d1ee230e5b25264c770eaf..7000a2a3feadc303719dae20b69ce4efbb7941d1 100644 --- a/pages/tab-bar/composition-api.uvue +++ b/pages/tab-bar/composition-api.uvue @@ -166,7 +166,12 @@ { name: 'toRefs', url: 'to-refs', + // #ifdef APP enable: true, + // #endif + // #ifdef WEB + enable: false, + // #endif }, { name: 'isProxy', diff --git a/pages/tab-bar/options-api.uvue b/pages/tab-bar/options-api.uvue index c77c10efd883eddceb7005af2f4efa558cff45a5..56813a46ef11d9475d76ac4b932ed87b7a302527 100644 --- a/pages/tab-bar/options-api.uvue +++ b/pages/tab-bar/options-api.uvue @@ -312,7 +312,12 @@ { name: '$root', url: 'root', + // #ifdef APP enable: true, + // #endif + // #ifdef WEB + enable: false, + // #endif }, { name: '$slots',