W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
規(guī)范文件包含了測試你的實際應(yīng)用程序的代碼。測試運行程序?qū)⒓虞d這些規(guī)范,并根據(jù)需要自動運行它們?,F(xiàn)在讓我們在我們指定的目錄中創(chuàng)建我們的規(guī)范。
test/specs/example.e2e.js:
// calculates the luma from a hex color `#abcdef`
function luma(hex) {
if (hex.startsWith('#')) {
hex = hex.substring(1)
}
const rgb = parseInt(hex, 16)
const r = (rgb >> 16) & 0xff
const g = (rgb >> 8) & 0xff
const b = (rgb >> 0) & 0xff
return 0.2126 * r + 0.7152 * g + 0.0722 * b
}
describe('Hello Tauri', () => {
it('should be cordial', async () => {
const header = await $('body > h1')
const text = await header.getText()
expect(text).toMatch(/^[hH]ello/)
})
it('should be excited', async () => {
const header = await $('body > h1')
const text = await header.getText()
expect(text).toMatch(/!$/)
})
it('should be easy on the eyes', async () => {
const body = await $('body')
const backgroundColor = await body.getCSSProperty('background-color')
expect(luma(backgroundColor.parsed.hex)).toBeLessThan(100)
})
})
頂部的luma
函數(shù)只是我們其中一個測試的輔助函數(shù),與應(yīng)用程序的實際測試無關(guān)。如果你熟悉其他測試框架,你可能會注意到類似的函數(shù)被暴露出來,并被使用,例如describe
、it
和expect
。其他API,比如$
及其暴露的方法,都在WebdriverIO的API文檔中有詳細介紹。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: