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

test(getCurrentPages): 补充 toSaveImageSnapshot 自定义文件名示例

上级 80a0390d
const HOME_PAGE_PATH = '/pages/tabBar/component' const HOME_PAGE_PATH = '/pages/tabBar/component'
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages' const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'
describe('getCurrentPages', () => { describe('getCurrentPages', () => {
let page let page
it('getCurrentPages', async () => { it('getCurrentPages', async () => {
// web 端等待应用首页加载完成 // web 端等待应用首页加载完成
if (process.env.uniTestPlatformInfo.startsWith('web')) { if (process.env.uniTestPlatformInfo.startsWith('web')) {
const waitTime = process.env.uniTestPlatformInfo.includes('safari') ? const waitTime = process.env.uniTestPlatformInfo.includes('safari') ?
5000 : 5000 :
3000 3000
await new Promise((resolve) => { await new Promise((resolve) => {
setTimeout(() => { setTimeout(() => {
resolve() resolve()
}, waitTime) }, waitTime)
}) })
} }
page = await program.switchTab(HOME_PAGE_PATH) page = await program.switchTab(HOME_PAGE_PATH)
await page.waitFor(1000) await page.waitFor(1000)
page = await program.navigateTo(PAGE_PATH) page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000) await page.waitFor(1000)
await page.callMethod('_getCurrentPages') await page.callMethod('_getCurrentPages')
await page.waitFor(200) await page.waitFor(200)
const data = await page.data() const data = await page.data()
expect(data.checked).toBe(true) expect(data.checked).toBe(true)
}) })
it('page-style', async () => { it('page-style', async () => {
page = await program.navigateTo(PAGE_PATH) page = await program.navigateTo(PAGE_PATH)
...@@ -47,7 +47,9 @@ describe('getCurrentPages', () => { ...@@ -47,7 +47,9 @@ describe('getCurrentPages', () => {
await page.callMethod('startPullDownRefresh') await page.callMethod('startPullDownRefresh')
await page.waitFor(500) await page.waitFor(500)
const image2 = await program.screenshot({fullPage: true}); const image2 = await program.screenshot({fullPage: true});
expect(image2).toSaveImageSnapshot(); expect(image2).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'get-current-pages-test-js-get-current-pages-page-style-before-set-page-style'
}});
await page.waitFor(3500) await page.waitFor(3500)
await page.callMethod('setPageStyle', { await page.callMethod('setPageStyle', {
...@@ -57,6 +59,8 @@ describe('getCurrentPages', () => { ...@@ -57,6 +59,8 @@ describe('getCurrentPages', () => {
await page.callMethod('startPullDownRefresh') await page.callMethod('startPullDownRefresh')
await page.waitFor(500) await page.waitFor(500)
const image3 = await program.screenshot({fullPage: true}); const image3 = await program.screenshot({fullPage: true});
expect(image3).toSaveImageSnapshot(); expect(image3).toSaveImageSnapshot({customSnapshotIdentifier() {
}) return 'get-current-pages-test-js-get-current-pages-page-style-after-set-page-style'
}});
})
}) })
...@@ -27,7 +27,9 @@ describe('getCurrentPages', () => { ...@@ -27,7 +27,9 @@ describe('getCurrentPages', () => {
const image3 = await program.screenshot({ const image3 = await program.screenshot({
fullPage: true fullPage: true
}); });
expect(image3).toSaveImageSnapshot(); expect(image3).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'set-page-style-disable-pull-down-refresh-test-js-get-current-pages-page-style-before-set-page-style'
}});
await page.waitFor(3500) await page.waitFor(3500)
...@@ -39,7 +41,9 @@ describe('getCurrentPages', () => { ...@@ -39,7 +41,9 @@ describe('getCurrentPages', () => {
const image2 = await program.screenshot({ const image2 = await program.screenshot({
fullPage: true fullPage: true
}); });
expect(image2).toSaveImageSnapshot(); expect(image2).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'set-page-style-disable-pull-down-refresh-test-js-get-current-pages-page-style-after-set-page-style'
}});
}) })
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册