You need to sign in or sign up before continuing.
提交 c7e4278c 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

Merge branch 'dev' into alpha

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