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

feat: 补充 App.uvue 访问 app.config 示例及测试

上级 fe8cacfd
......@@ -34,6 +34,9 @@
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100)
setAppShowPath(options.path)
if(this.globalPropertiesStr === 'default string'){
setLifeCycleNum(state.lifeCycleNum + 10)
}
console.log('App Show')
},
onHide: function () {
......@@ -65,7 +68,7 @@
},
// #endif
onError: function(error: any) {
console.log('App Error', error)
console.log('App Error', error)
setLifeCycleNum(state.lifeCycleNum + 100)
},
methods: {
......
const path = require('path')
module.exports = {
testTimeout: 10000,
reporters: ['default'],
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
moduleFileExtensions: ['js', 'json'],
rootDir: __dirname,
testMatch: ['<rootDir>/pages/**/**/*.test.js'],
testMatch: ["<rootDir>/pages/App.test.js"],
testPathIgnorePatterns: ['/node_modules/'],
setupFilesAfterEnv: ['<rootDir>/jest-setup.js'],
testSequencer: path.join(__dirname, "testSequencer.js")
}
......@@ -8,5 +8,8 @@ describe("app launch & show options", () => {
if (!process.env.uniTestPlatformInfo.startsWith('android')) {
expect(await page.callMethod("checkAppMixin")).toBe(true)
}
const lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(1110)
})
})
......@@ -39,7 +39,7 @@ describe('throw error', () => {
})
afterAll(async () => {
const resetLifecycleNum = 1100
const resetLifecycleNum = 1110
await page.callMethod('setLifeCycleNum', resetLifecycleNum)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(resetLifecycleNum)
......
......@@ -19,7 +19,7 @@ describe('component-lifecycle', () => {
await page.waitFor(700)
})
afterAll(async () => {
const resetLifecycleNum = 1100
const resetLifecycleNum = 1110
await page.callMethod('setLifeCycleNum', resetLifecycleNum)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(resetLifecycleNum)
......
......@@ -16,7 +16,7 @@ describe('component-lifecycle', () => {
await page.waitFor(700)
})
afterAll(async () => {
const resetLifecycleNum = 1100
const resetLifecycleNum = 1110
await page.callMethod('setLifeCycleNum', resetLifecycleNum)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(resetLifecycleNum)
......
......@@ -15,7 +15,7 @@ const initLifecycle = async () => {
}
const testPageLifecycle = async (pagePath) => {
// onLoad onShow onReady onResize
page = await program.reLaunch(pagePath)
page = await program.reLaunch(pagePath)
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('pageGetLifeCycleNum')
expect(lifeCycleNum).toBe(120)
......@@ -60,7 +60,7 @@ const testPageLifecycle = async (pagePath) => {
await page.waitFor(700)
lifeCycleNum = await page.callMethod('pageGetLifeCycleNum')
expect(lifeCycleNum).toBe(120)
page = await program.navigateBack()
page = await program.navigateBack()
await page.waitFor('view')
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(10)
......@@ -72,7 +72,7 @@ describe('app-lifecycle', () => {
page = await program.reLaunch(HOME_PATH)
await page.waitFor(700)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(1100)
expect(lifeCycleNum).toBe(1110)
})
it('onLastPageBackPress', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
......@@ -85,8 +85,8 @@ describe('app-lifecycle', () => {
})
describe('page-lifecycle', () => {
it('page-lifecycle options API', async () => {
await initLifecycle()
it('page-lifecycle options API', async () => {
await initLifecycle()
await testPageLifecycle(OPTIONS_PAGE_PATH)
})
......@@ -96,7 +96,7 @@ describe('page-lifecycle', () => {
})
afterAll(async () => {
const resetLifecycleNum = 1100
const resetLifecycleNum = 1110
await page.callMethod('setLifeCycleNum', resetLifecycleNum)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(resetLifecycleNum)
......
const Sequencer = require("@jest/test-sequencer").default
const sortTestFilePaths = [
"pages/App.test.js",
]
class CustomSequencer extends Sequencer {
sort(tests) {
// 测试例排序
const sortedTests = sortTestFilePaths
.map((filePath) => {
return tests.find((test) => test.path.endsWith(filePath))
})
.filter(Boolean)
return [...new Set([...sortedTests, ...tests])]
}
}
module.exports = CustomSequencer
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册