提交 c7e4278c 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

Merge branch 'dev' into alpha

const path = require('path') const path = require('path')
module.exports = { module.exports = {
testTimeout: 10000, testTimeout: 20000,
reporters: ['default'], reporters: ['default'],
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'], watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
moduleFileExtensions: ['js', 'json'], moduleFileExtensions: ['js', 'json'],
rootDir: __dirname, rootDir: __dirname,
testMatch: ["<rootDir>/pages/App.test.js"], testMatch: ["<rootDir>/pages/**/*test.[jt]s?(x)"],
testPathIgnorePatterns: ['/node_modules/'], testPathIgnorePatterns: ['/node_modules/'],
setupFilesAfterEnv: ['<rootDir>/jest-setup.js'], setupFilesAfterEnv: ['<rootDir>/jest-setup.js'],
testSequencer: path.join(__dirname, "testSequencer.js") testSequencer: path.join(__dirname, "testSequencer.js")
......
jest.setTimeout(20000) jest.setTimeout(30000)
const OPTIONS_PAGE_PATH = '/pages/app-instance/globalProperties/globalProperties-options' const OPTIONS_PAGE_PATH = '/pages/app-instance/globalProperties/globalProperties-options'
const COMPOSITION_PAGE_PATH = '/pages/app-instance/globalProperties/globalProperties-composition' const COMPOSITION_PAGE_PATH = '/pages/app-instance/globalProperties/globalProperties-composition'
......
...@@ -8,6 +8,7 @@ describe('built-in/special-elements/component', () => { ...@@ -8,6 +8,7 @@ describe('built-in/special-elements/component', () => {
const showBtn = await page.$('#show-botton') const showBtn = await page.$('#show-botton')
expect(await showBtn.text()).toBe("点击显示") expect(await showBtn.text()).toBe("点击显示")
await showBtn.tap() await showBtn.tap()
await page.waitFor(500)
const dataInfo = await page.data('dataInfo') const dataInfo = await page.data('dataInfo')
expect(dataInfo.isShow).toBeTruthy() expect(dataInfo.isShow).toBeTruthy()
......
const OPTIONS_PAGE_PATH = '/pages/component-instance/attrs/attrs-options' const OPTIONS_PAGE_PATH = '/pages/component-instance/attrs/attrs-options'
const COMPOSITION_PAGE_PATH = '/pages/component-instance/attrs/attrs-composition' const COMPOSITION_PAGE_PATH = '/pages/component-instance/attrs/attrs-composition'
describe('$attrs', () => { describe('$attrs', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isWeb = platformInfo.startsWith('web')
const isIos = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp') const isMP = platformInfo.startsWith('mp')
let page
const test = async (page) => { const test = async (pagePath) => {
const page = await program.reLaunch(pagePath)
await page.waitFor('view')
await page.waitFor(1000)
const hasPropsAttr = await page.$('#has-props-attr') const hasPropsAttr = await page.$('#has-props-attr')
expect(await hasPropsAttr.text()).toBe('false') expect(await hasPropsAttr.text()).toBe('false')
const hasEmitsAttr = await page.$('#has-emits-attr') const hasEmitsAttr = await page.$('#has-emits-attr')
...@@ -20,16 +20,10 @@ describe('$attrs', () => { ...@@ -20,16 +20,10 @@ describe('$attrs', () => {
} }
it('$attrs options API', async () => { it('$attrs options API', async () => {
page = await program.reLaunch(OPTIONS_PAGE_PATH) await test(OPTIONS_PAGE_PATH)
await page.waitFor('view')
await test(page)
}) })
it('useAttrs composition API', async () => { it('useAttrs composition API', async () => {
page = await program.reLaunch(COMPOSITION_PAGE_PATH) await test(COMPOSITION_PAGE_PATH)
await page.waitFor('view')
await test(page)
}) })
}) })
...@@ -10,6 +10,7 @@ describe('$emit()', () => { ...@@ -10,6 +10,7 @@ describe('$emit()', () => {
const btn = await page.$('.call-parent-btn') const btn = await page.$('.call-parent-btn')
await btn.tap() await btn.tap()
await page.waitFor(500)
const afterValue = await valueText.text() const afterValue = await valueText.text()
expect(beforeValue).not.toBe(afterValue) expect(beforeValue).not.toBe(afterValue)
......
...@@ -12,6 +12,7 @@ describe('$forceUpdate', () => { ...@@ -12,6 +12,7 @@ describe('$forceUpdate', () => {
const triggerForceUpdateBtn = await page.$('.trigger-force-update-btn') const triggerForceUpdateBtn = await page.$('.trigger-force-update-btn')
await triggerForceUpdateBtn.tap() await triggerForceUpdateBtn.tap()
await page.waitFor(500)
const timeText2 = (await timeEl.text()).replace('Date.now(): ', '') const timeText2 = (await timeEl.text()).replace('Date.now(): ', '')
expect(parseInt(timeText2)).toBeGreaterThan(parseInt(timeText1)) expect(parseInt(timeText2)).toBeGreaterThan(parseInt(timeText1))
...@@ -25,6 +26,7 @@ describe('$forceUpdate', () => { ...@@ -25,6 +26,7 @@ describe('$forceUpdate', () => {
const triggerForceUpdateBtn = await page.$('.trigger-force-update-btn') const triggerForceUpdateBtn = await page.$('.trigger-force-update-btn')
await triggerForceUpdateBtn.tap() await triggerForceUpdateBtn.tap()
await page.waitFor(500)
const timeText2 = (await timeEl.text()).replace('Date.now(): ', '') const timeText2 = (await timeEl.text()).replace('Date.now(): ', '')
expect(parseInt(timeText2)).toBeGreaterThan(parseInt(timeText1)) expect(parseInt(timeText2)).toBeGreaterThan(parseInt(timeText1))
......
...@@ -2,8 +2,10 @@ const OPTIONS_PAGE_PATH = '/pages/component-instance/parent/parent-options' ...@@ -2,8 +2,10 @@ const OPTIONS_PAGE_PATH = '/pages/component-instance/parent/parent-options'
const COMPOSITION_PAGE_PATH = '/pages/component-instance/parent/parent-composition' const COMPOSITION_PAGE_PATH = '/pages/component-instance/parent/parent-composition'
describe('$parent', () => { describe('$parent', () => {
let page const test = async (pagePath) => {
const test = async (page) => { page = await program.reLaunch(pagePath)
await page.waitFor('view')
await page.waitFor(500)
const parentStr = await page.$('#parent-str') const parentStr = await page.$('#parent-str')
expect(await parentStr.text()).toBe('parent str') expect(await parentStr.text()).toBe('parent str')
...@@ -12,20 +14,15 @@ describe('$parent', () => { ...@@ -12,20 +14,15 @@ describe('$parent', () => {
const triggerParentFnBtn = await page.$('#trigger-parent-fn') const triggerParentFnBtn = await page.$('#trigger-parent-fn')
await triggerParentFnBtn.tap() await triggerParentFnBtn.tap()
await page.waitFor(500)
expect(await parentNum.text()).toBe('1') expect(await parentNum.text()).toBe('1')
} }
it('$parent 选项式 API', async () => { it('$parent 选项式 API', async () => {
page = await program.reLaunch(OPTIONS_PAGE_PATH) await test(OPTIONS_PAGE_PATH)
await page.waitFor('view')
await test(page)
}); });
it('$parent 组合式 API', async () => { it('$parent 组合式 API', async () => {
page = await program.reLaunch(COMPOSITION_PAGE_PATH) await test(COMPOSITION_PAGE_PATH)
await page.waitFor('view')
await test(page)
}) })
}) })
...@@ -5,8 +5,10 @@ const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() ...@@ -5,8 +5,10 @@ const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.includes('android') const isAndroid = platformInfo.includes('android')
describe('props', () => { describe('props', () => {
let page const test = async (pagePath) => {
const test = async (page) => { page = await program.reLaunch(pagePath)
await page.waitFor('view')
await page.waitFor(1000)
const arrayLiteralStr = await page.$('#array-literal-str') const arrayLiteralStr = await page.$('#array-literal-str')
expect(await arrayLiteralStr.text()).toBe('str') expect(await arrayLiteralStr.text()).toBe('str')
...@@ -50,16 +52,10 @@ describe('props', () => { ...@@ -50,16 +52,10 @@ describe('props', () => {
} }
it('props 选项式 API', async () => { it('props 选项式 API', async () => {
page = await program.reLaunch(OPTIONS_PAGE_PATH) await test(OPTIONS_PAGE_PATH)
await page.waitFor('view')
await test(page)
}); });
it('props 组合式 API', async () => { it('props 组合式 API', async () => {
page = await program.reLaunch(COMPOSITION_PAGE_PATH) await test(COMPOSITION_PAGE_PATH)
await page.waitFor('view')
await test(page)
}) })
}) })
\ No newline at end of file
...@@ -32,6 +32,7 @@ describe('组合式 API provide', () => { ...@@ -32,6 +32,7 @@ describe('组合式 API provide', () => {
const checkHasInjectionContextBtn = await page.$('.check-has-injection-context-btn') const checkHasInjectionContextBtn = await page.$('.check-has-injection-context-btn')
await checkHasInjectionContextBtn.tap() await checkHasInjectionContextBtn.tap()
await page.waitFor(500)
expect(await hasInjectionContext.text()).toBe('hasInjectionContext: false') expect(await hasInjectionContext.text()).toBe('hasInjectionContext: false')
}) })
......
const OPTIONS_PAGE_PATH = '/pages/component-instance/root/root-options' const OPTIONS_PAGE_PATH = '/pages/component-instance/root/root-options'
const COMPOSITION_PAGE_PATH = '/pages/component-instance/root/root-composition' const COMPOSITION_PAGE_PATH = '/pages/component-instance/root/root-composition'
describe('$root', () => { describe('$root', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.includes('android')
const isIOS = platformInfo.includes('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web') const isWeb = platformInfo.startsWith('web')
if (isWeb) { if (isWeb) {
// TODO: web 端 $root 指向和 app 端不同,具体待定
it('not support', async () => { it('not support', async () => {
expect(1).toBe(1) expect(1).toBe(1)
}) })
...@@ -17,6 +15,7 @@ describe('$root', () => { ...@@ -17,6 +15,7 @@ describe('$root', () => {
const test = async (pagePath) => { const test = async (pagePath) => {
page = await program.reLaunch(pagePath) page = await program.reLaunch(pagePath)
await page.waitFor('view') await page.waitFor('view')
await page.waitFor(1000)
const rootStrParent = await page.$('#root-str-parent') const rootStrParent = await page.$('#root-str-parent')
expect(await rootStrParent.text()).toBe('root component str') expect(await rootStrParent.text()).toBe('root component str')
......
...@@ -2,17 +2,20 @@ const OPTIONS_PAGE_PATH = '/pages/directive/v-if/v-if-options' ...@@ -2,17 +2,20 @@ const OPTIONS_PAGE_PATH = '/pages/directive/v-if/v-if-options'
const COMPOSITION_PAGE_PATH = '/pages/directive/v-if/v-if-composition' const COMPOSITION_PAGE_PATH = '/pages/directive/v-if/v-if-composition'
describe('v-if', () => { describe('v-if', () => {
let page const test = async (pagePath) => {
const test = async (page) => { page = await program.reLaunch(pagePath)
await page.waitFor('view')
let vIfShow = await page.$('#v-if-show') let vIfShow = await page.$('#v-if-show')
expect(await vIfShow.text()).toBe('show') expect(await vIfShow.text()).toBe('show')
const switchVIfBtn = await page.$('#switch-v-if-btn') const switchVIfBtn = await page.$('#switch-v-if-btn')
await switchVIfBtn.tap() await switchVIfBtn.tap()
await page.waitFor(500)
vIfShow = await page.$('#v-if-show') vIfShow = await page.$('#v-if-show')
expect(vIfShow).toBeNull() expect(vIfShow).toBeNull()
await switchVIfBtn.tap() await switchVIfBtn.tap()
await page.waitFor(500)
vIfShow = await page.$('#v-if-show') vIfShow = await page.$('#v-if-show')
expect(await vIfShow.text()).toBe('show') expect(await vIfShow.text()).toBe('show')
...@@ -27,6 +30,7 @@ describe('v-if', () => { ...@@ -27,6 +30,7 @@ describe('v-if', () => {
const changeNumBtn = await page.$('#change-num-btn') const changeNumBtn = await page.$('#change-num-btn')
await changeNumBtn.tap() await changeNumBtn.tap()
await page.waitFor(500)
expect(await num.text()).toBe('2') expect(await num.text()).toBe('2')
numVIf = await page.$('#num-v-if') numVIf = await page.$('#num-v-if')
...@@ -37,6 +41,7 @@ describe('v-if', () => { ...@@ -37,6 +41,7 @@ describe('v-if', () => {
expect(numVElse).toBeNull() expect(numVElse).toBeNull()
await changeNumBtn.tap() await changeNumBtn.tap()
await page.waitFor(500)
expect(await num.text()).toBe('3') expect(await num.text()).toBe('3')
numVIf = await page.$('#num-v-if') numVIf = await page.$('#num-v-if')
...@@ -47,6 +52,7 @@ describe('v-if', () => { ...@@ -47,6 +52,7 @@ describe('v-if', () => {
expect(await numVElse.text()).toBe('v-else') expect(await numVElse.text()).toBe('v-else')
await changeNumBtn.tap() await changeNumBtn.tap()
await page.waitFor(500)
expect(await num.text()).toBe('1') expect(await num.text()).toBe('1')
numVIf = await page.$('#num-v-if') numVIf = await page.$('#num-v-if')
...@@ -58,16 +64,10 @@ describe('v-if', () => { ...@@ -58,16 +64,10 @@ describe('v-if', () => {
} }
it('v-if options API', async () => { it('v-if options API', async () => {
page = await program.reLaunch(OPTIONS_PAGE_PATH) await test(OPTIONS_PAGE_PATH)
await page.waitFor('view')
await test(page)
}) })
it('v-if composition API', async () => { it('v-if composition API', async () => {
page = await program.reLaunch(COMPOSITION_PAGE_PATH) await test(COMPOSITION_PAGE_PATH)
await page.waitFor('view')
await test(page)
}) })
}) })
\ No newline at end of file
...@@ -7,7 +7,8 @@ describe('v-model', () => { ...@@ -7,7 +7,8 @@ describe('v-model', () => {
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500) await page.waitFor('view')
await page.waitFor(1000)
}) })
it('input', async () => { it('input', async () => {
...@@ -16,7 +17,7 @@ describe('v-model', () => { ...@@ -16,7 +17,7 @@ describe('v-model', () => {
const str = await page.$('#str') const str = await page.$('#str')
expect(await str.text()).toBe('new str') expect(await str.text()).toBe('new str')
if (!isIos) { if (!isIos) {
// TODO: ios 不支持 number & trim 修饰符 // TODO: ios 不支持 number & trim 修饰符
const modelNumInput = await page.$('#model-num') const modelNumInput = await page.$('#model-num')
await modelNumInput.input('123') await modelNumInput.input('123')
...@@ -26,11 +27,11 @@ describe('v-model', () => { ...@@ -26,11 +27,11 @@ describe('v-model', () => {
const modelStrTrimInput = await page.$('#model-str-trim') const modelStrTrimInput = await page.$('#model-str-trim')
await modelStrTrimInput.input(' trim ') await modelStrTrimInput.input(' trim ')
const strLength = await page.$('#str-length') const strLength = await page.$('#str-length')
expect(await strLength.text()).toBe('4') expect(await strLength.text()).toBe('4')
const sonInput = await page.$('#son-input') const sonInput = await page.$('#son-input')
expect(await sonInput.text()).toBe('nested') expect(await sonInput.text()).toBe('nested')
} }
// TODO: lazy 修饰符仅 android 支持,补充测试 // TODO: lazy 修饰符仅 android 支持,补充测试
}) })
}) })
\ No newline at end of file
...@@ -17,9 +17,10 @@ describe('v-on', () => { ...@@ -17,9 +17,10 @@ describe('v-on', () => {
const btnList = await page.$$('.btn') const btnList = await page.$$('.btn')
for (let i = 0; i < btnList.length; i++) { for (let i = 0; i < btnList.length; i++) {
await btnList[i].tap() await btnList[i].tap()
} await page.waitFor(500)
}
const supportedCount = isIOS ? '7' : isMP ? '5' : '8'
const supportedCount = isIOS ? '7' : isMP ? '5' : '8'
expect(await count.text()).toBe(supportedCount) expect(await count.text()).toBe(supportedCount)
......
...@@ -26,6 +26,7 @@ describe('throw error', () => { ...@@ -26,6 +26,7 @@ describe('throw error', () => {
const triggerErrorBtn = await page.$('#trigger-error') const triggerErrorBtn = await page.$('#trigger-error')
await triggerErrorBtn.tap() await triggerErrorBtn.tap()
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum') lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(200) expect(lifeCycleNum).toBe(200)
......
...@@ -18,18 +18,21 @@ describe('built-in/component', () => { ...@@ -18,18 +18,21 @@ describe('built-in/component', () => {
expect(await grandChildElement.text()).toEqual('0') expect(await grandChildElement.text()).toEqual('0')
await parentBtn.tap() await parentBtn.tap()
await page.waitFor(500)
expect(await parentMsgElement.text()).toEqual('1') expect(await parentMsgElement.text()).toEqual('1')
expect(await childMsgElement.text()).toEqual('1') expect(await childMsgElement.text()).toEqual('1')
expect(await grandChildElement.text()).toEqual('1') expect(await grandChildElement.text()).toEqual('1')
await parentBtn.tap() await parentBtn.tap()
await page.waitFor(500)
expect(await parentMsgElement.text()).toEqual('2') expect(await parentMsgElement.text()).toEqual('2')
expect(await childMsgElement.text()).toEqual('2') expect(await childMsgElement.text()).toEqual('2')
expect(await grandChildElement.text()).toEqual('2') expect(await grandChildElement.text()).toEqual('2')
await grandChildBtn.tap() await grandChildBtn.tap()
await page.waitFor(500)
expect(await parentMsgElement.text()).toEqual('0') expect(await parentMsgElement.text()).toEqual('0')
expect(await childMsgElement.text()).toEqual('0') expect(await childMsgElement.text()).toEqual('0')
......
const PAGE_PATH = '/pages/reactivity/advanced/effect-scope/effect-scope' const PAGE_PATH = '/pages/reactivity/advanced/effect-scope/effect-scope'
describe('effectScope', () => { describe('effectScope', () => {
let page = null let page = null
const platformInfo = process.env.uniTestPlatformInfo.toLowerCase() const platformInfo = process.env.uniTestPlatformInfo.toLowerCase()
const isAndroid = platformInfo.startsWith('android') const isAndroid = platformInfo.startsWith('android')
const isIos = platformInfo.startsWith('ios') const isIos = platformInfo.startsWith('ios')
const isWeb = platformInfo.startsWith('web') const isWeb = platformInfo.startsWith('web')
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
...@@ -15,12 +15,12 @@ describe('effectScope', () => { ...@@ -15,12 +15,12 @@ describe('effectScope', () => {
const counter = await page.$('#counter') const counter = await page.$('#counter')
expect(await counter.text()).toBe('0') expect(await counter.text()).toBe('0')
const watchCounterRes = await page.$('#watch-counter-res') const watchCounterRes = await page.$('#watch-counter-res')
if(isAndroid || isWeb){ if(isAndroid || isWeb){
expect(await watchCounterRes.text()).toBe('') expect(await watchCounterRes.text()).toBe('')
} }
if(isIos){ if(isIos){
expect(await watchCounterRes.text()).toBe(null) expect(await watchCounterRes.text()).toBe(null)
} }
const watchEffectCounterRes = await page.$('#watch-effect-counter-res') const watchEffectCounterRes = await page.$('#watch-effect-counter-res')
...@@ -28,6 +28,7 @@ describe('effectScope', () => { ...@@ -28,6 +28,7 @@ describe('effectScope', () => {
const incrementCounterBtn = await page.$('#increment-counter-btn') const incrementCounterBtn = await page.$('#increment-counter-btn')
await incrementCounterBtn.tap() await incrementCounterBtn.tap()
await page.waitFor(500)
expect(await counter.text()).toBe('1') expect(await counter.text()).toBe('1')
expect(await watchCounterRes.text()).toBe('newVal: 1, oldVal: 0') expect(await watchCounterRes.text()).toBe('newVal: 1, oldVal: 0')
...@@ -35,8 +36,8 @@ describe('effectScope', () => { ...@@ -35,8 +36,8 @@ describe('effectScope', () => {
const stopEffectScopeBtn = await page.$('#stop-effect-scope-btn') const stopEffectScopeBtn = await page.$('#stop-effect-scope-btn')
await stopEffectScopeBtn.tap() await stopEffectScopeBtn.tap()
await incrementCounterBtn.tap() await incrementCounterBtn.tap()
await page.waitFor(500)
expect(await counter.text()).toBe('2') expect(await counter.text()).toBe('2')
expect(await watchCounterRes.text()).toBe('newVal: 1, oldVal: 0') expect(await watchCounterRes.text()).toBe('newVal: 1, oldVal: 0')
......
...@@ -12,11 +12,13 @@ describe('onScopeDispose', () => { ...@@ -12,11 +12,13 @@ describe('onScopeDispose', () => {
const createScopeBtn = await page.$('#create-scope-btn') const createScopeBtn = await page.$('#create-scope-btn')
await createScopeBtn.tap() await createScopeBtn.tap()
await page.waitFor(500)
expect(await hasCurrentScope.text()).toBe('true') expect(await hasCurrentScope.text()).toBe('true')
const stopScopeBtn = await page.$('#stop-scope-btn') const stopScopeBtn = await page.$('#stop-scope-btn')
await stopScopeBtn.tap() await stopScopeBtn.tap()
await page.waitFor(500)
expect(await hasCurrentScope.text()).toBe('false') expect(await hasCurrentScope.text()).toBe('false')
}) })
......
...@@ -22,6 +22,7 @@ describe('shallowReactive', () => { ...@@ -22,6 +22,7 @@ describe('shallowReactive', () => {
const incrementStateCountBtn = await page.$('#increment-state-count-btn') const incrementStateCountBtn = await page.$('#increment-state-count-btn')
await incrementStateCountBtn.tap() await incrementStateCountBtn.tap()
await page.waitFor(500)
if (isWeb) { if (isWeb) {
// web 端 view text 为组件,无法动态更新 shallowReactive nested 数据 // web 端 view text 为组件,无法动态更新 shallowReactive nested 数据
......
...@@ -17,6 +17,7 @@ describe('shallowRef', () => { ...@@ -17,6 +17,7 @@ describe('shallowRef', () => {
const updateStateBtn = await page.$('#update-state-btn') const updateStateBtn = await page.$('#update-state-btn')
await updateStateBtn.tap() await updateStateBtn.tap()
await page.waitFor(500)
expect(await stateCount.text()).toBe('1') expect(await stateCount.text()).toBe('1')
}) })
......
...@@ -12,11 +12,13 @@ describe('triggerRef', () => { ...@@ -12,11 +12,13 @@ describe('triggerRef', () => {
const incrementStateCountBtn = await page.$('#increment-state-count-btn') const incrementStateCountBtn = await page.$('#increment-state-count-btn')
await incrementStateCountBtn.tap() await incrementStateCountBtn.tap()
await page.waitFor(500)
expect(await stateCount.text()).toBe('0') expect(await stateCount.text()).toBe('0')
const triggerRefStateBtn = await page.$('#trigger-ref-state-btn') const triggerRefStateBtn = await page.$('#trigger-ref-state-btn')
await triggerRefStateBtn.tap() await triggerRefStateBtn.tap()
await page.waitFor(500)
expect(await stateCount.text()).toBe('1') expect(await stateCount.text()).toBe('1')
}) })
......
...@@ -13,13 +13,14 @@ describe('computed', () => { ...@@ -13,13 +13,14 @@ describe('computed', () => {
const objArr = await page.$('#obj-arr') const objArr = await page.$('#obj-arr')
expect(await objArr.text()).toBe('[1,2,3]') expect(await objArr.text()).toBe('[1,2,3]')
const objArrLen = await page.$('#obj-arr-len') const objArrLen = await page.$('#obj-arr-len')
expect(await objArrLen.text()).toBe('3') expect(await objArrLen.text()).toBe('3')
const computedWithArgument = await page.$('#computed-with-argument') const computedWithArgument = await page.$('#computed-with-argument')
expect(await computedWithArgument.text()).toBe('审核中') expect(await computedWithArgument.text()).toBe('审核中')
const updateBtn = await page.$('#update-btn') const updateBtn = await page.$('#update-btn')
await updateBtn.tap() await updateBtn.tap()
await page.waitFor(500)
expect(await count.text()).toBe('1') expect(await count.text()).toBe('1')
expect(await doubleCount.text()).toBe('2') expect(await doubleCount.text()).toBe('2')
......
...@@ -24,19 +24,23 @@ describe('reactive', () => { ...@@ -24,19 +24,23 @@ describe('reactive', () => {
const updateCountBtn = await page.$('#update-count-btn') const updateCountBtn = await page.$('#update-count-btn')
await updateCountBtn.tap() await updateCountBtn.tap()
await page.waitFor(500)
expect(await count.text()).toBe('1') expect(await count.text()).toBe('1')
const updateObjStrBtn = await page.$('#update-obj-str-btn') const updateObjStrBtn = await page.$('#update-obj-str-btn')
await updateObjStrBtn.tap() await updateObjStrBtn.tap()
await page.waitFor(500)
expect(await objStr.text()).toBe('new str') expect(await objStr.text()).toBe('new str')
const updateObjNumBtn = await page.$('#update-obj-num-btn') const updateObjNumBtn = await page.$('#update-obj-num-btn')
await updateObjNumBtn.tap() await updateObjNumBtn.tap()
await page.waitFor(500)
expect(await count.text()).toBe('2') expect(await count.text()).toBe('2')
expect(await objNum.text()).toBe('2') expect(await objNum.text()).toBe('2')
const updateObjArrBtn = await page.$('#update-obj-arr-btn') const updateObjArrBtn = await page.$('#update-obj-arr-btn')
await updateObjArrBtn.tap() await updateObjArrBtn.tap()
await page.waitFor(500)
expect(await objArr.text()).toBe('["a","b","c","d"]') expect(await objArr.text()).toBe('["a","b","c","d"]')
const count1 = await page.$('#count1') const count1 = await page.$('#count1')
...@@ -48,6 +52,7 @@ describe('reactive', () => { ...@@ -48,6 +52,7 @@ describe('reactive', () => {
const updateArr1Btn = await page.$('#update-arr1-btn') const updateArr1Btn = await page.$('#update-arr1-btn')
await updateArr1Btn.tap() await updateArr1Btn.tap()
await page.waitFor(500)
expect(await arr1.text()).toBe(JSON.stringify([1, 2, 3])) expect(await arr1.text()).toBe(JSON.stringify([1, 2, 3]))
const updateArr1ReactiveBtn = await page.$('#update-arr1-reactive-btn') const updateArr1ReactiveBtn = await page.$('#update-arr1-reactive-btn')
......
...@@ -23,6 +23,7 @@ describe('ref', () => { ...@@ -23,6 +23,7 @@ describe('ref', () => {
const updateDataBtn = await page.$('#update-data-btn') const updateDataBtn = await page.$('#update-data-btn')
await updateDataBtn.tap() await updateDataBtn.tap()
await page.waitFor(500)
expect(await dataStr.text()).toBe('new str') expect(await dataStr.text()).toBe('new str')
expect(await dataNum.text()).toBe('1') expect(await dataNum.text()).toBe('1')
......
...@@ -16,32 +16,38 @@ describe('ref', () => { ...@@ -16,32 +16,38 @@ describe('ref', () => {
const arr = await page.$('#arr') const arr = await page.$('#arr')
expect(await arr.text()).toBe('[1,2,3]') expect(await arr.text()).toBe('[1,2,3]')
const counterCount = await page.$('#counter-count') const counterCount = await page.$('#counter-count')
expect(await counterCount.text()).toBe('0') expect(await counterCount.text()).toBe('0')
const countersCount = await page.$('#counters-count') const countersCount = await page.$('#counters-count')
expect(await countersCount.text()).toBe('0') expect(await countersCount.text()).toBe('0')
const changeCountBtn = await page.$('#change-count-btn') const changeCountBtn = await page.$('#change-count-btn')
await changeCountBtn.tap() await changeCountBtn.tap()
await page.waitFor(500)
expect(await count.text()).toBe('1') expect(await count.text()).toBe('1')
const changeStrBtn = await page.$('#change-str-btn') const changeStrBtn = await page.$('#change-str-btn')
await changeStrBtn.tap() await changeStrBtn.tap()
await page.waitFor(500)
expect(await str.text()).toBe('new str') expect(await str.text()).toBe('new str')
const changeBoolBtn = await page.$('#change-bool-btn') const changeBoolBtn = await page.$('#change-bool-btn')
await changeBoolBtn.tap() await changeBoolBtn.tap()
await page.waitFor(500)
expect(await bool.text()).toBe('true') expect(await bool.text()).toBe('true')
const changeArrBtn = await page.$('#change-arr-btn') const changeArrBtn = await page.$('#change-arr-btn')
await changeArrBtn.tap() await changeArrBtn.tap()
await page.waitFor(500)
expect(await arr.text()).toBe('[1,2,3,4]') expect(await arr.text()).toBe('[1,2,3,4]')
const changeCounterBtn = await page.$('#change-counter-btn') const changeCounterBtn = await page.$('#change-counter-btn')
await changeCounterBtn.tap() await changeCounterBtn.tap()
expect(await counterCount.text()).toBe('1') await page.waitFor(500)
expect(await counterCount.text()).toBe('1')
const changeCountersBtn = await page.$('#change-counters-btn')
await changeCountersBtn.tap() const changeCountersBtn = await page.$('#change-counters-btn')
await changeCountersBtn.tap()
await page.waitFor(500)
expect(await countersCount.text()).toBe('1') expect(await countersCount.text()).toBe('1')
}) })
......
...@@ -25,6 +25,7 @@ describe('toRef', () => { ...@@ -25,6 +25,7 @@ describe('toRef', () => {
const incrementBtn = await page.$('#increment-btn') const incrementBtn = await page.$('#increment-btn')
await incrementBtn.tap() await incrementBtn.tap()
await page.waitFor(500)
expect(await objNum.text()).toBe('2') expect(await objNum.text()).toBe('2')
expect(await toRefObjNum.text()).toBe('2') expect(await toRefObjNum.text()).toBe('2')
......
...@@ -25,6 +25,7 @@ describe('toRefs', () => { ...@@ -25,6 +25,7 @@ describe('toRefs', () => {
const updateStateBtn = await page.$('#update-state-btn') const updateStateBtn = await page.$('#update-state-btn')
await updateStateBtn.tap() await updateStateBtn.tap()
await page.waitFor(500)
expect(await stateNum.text()).toBe('1') expect(await stateNum.text()).toBe('1')
expect(await stateStr.text()).toBe('str-1') expect(await stateStr.text()).toBe('str-1')
......
const PAGE_PATH = '/pages/reactivity/utilities/to-value/to-value' const PAGE_PATH = '/pages/reactivity/utilities/to-value/to-value'
const platformInfo = process.env.uniTestPlatformInfo.toLowerCase() const platformInfo = process.env.uniTestPlatformInfo.toLowerCase()
const isWeb = platformInfo.startsWith('web') const isWeb = platformInfo.startsWith('web')
describe('toValue', () => { describe('toValue', () => {
...@@ -25,10 +25,11 @@ describe('toValue', () => { ...@@ -25,10 +25,11 @@ describe('toValue', () => {
const incrementBtn = await page.$('#increment-btn') const incrementBtn = await page.$('#increment-btn')
await incrementBtn.tap() await incrementBtn.tap()
await page.waitFor(500)
expect(await objNum.text()).toBe('1') expect(await objNum.text()).toBe('1')
if(!isWeb){ if(!isWeb){
// 数据更新成功,但因为 web 端 text 为组件,所以视图未更新 // 数据更新成功,但因为 web 端 text 为组件,所以视图未更新
expect(await toValueObjNum.text()).toBe('1') expect(await toValueObjNum.text()).toBe('1')
} }
}) })
......
...@@ -8,7 +8,6 @@ const endTestFilePaths = [ ...@@ -8,7 +8,6 @@ const endTestFilePaths = [
] ]
class CustomSequencer extends Sequencer { class CustomSequencer extends Sequencer {
sort(tests) { sort(tests) {
// 测试例排序
const startTests = startTestFilePaths const startTests = startTestFilePaths
.map((filePath) => { .map((filePath) => {
return tests.find((test) => test.path.endsWith(filePath)) return tests.find((test) => test.path.endsWith(filePath))
...@@ -19,7 +18,12 @@ class CustomSequencer extends Sequencer { ...@@ -19,7 +18,12 @@ class CustomSequencer extends Sequencer {
return tests.find((test) => test.path.endsWith(filePath)) return tests.find((test) => test.path.endsWith(filePath))
}) })
.filter(Boolean) .filter(Boolean)
return [...new Set([...startTests, ...tests, ...endTests])]
const middleTests = tests.filter((test) =>
!startTests.includes(test) && !endTests.includes(test)
);
return [...startTests, ...middleTests, ...endTests]
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册