परिक्षणों को पैरामीटराइज़ करें
आप किसी परीक्षण स्तर पर, सरल for
लूप के माध्यम से परीक्षणों को आसानी से पैरामीटराइज़ कर सकते हैं, उदाहरण के लिए:
const people = ['Alice', 'Bob']
describe('my tests', () => {
for (const name of people) {
it(`testing with ${name}`, async () => {
// ...
})
}
})
या परीक्षणों को गतिशील फ़ंक्शन में निकालकर, उदाहरण के लिए:
import { browser } from '@wdio/globals'
function testComponent(componentName, options) {
it(`should test my ${componentName}`, async () => {
await browser.url(`/${componentName}`)
await expect($('input')).toHaveValue(options.expectedValue)
})
}
describe('page components', () => {
testComponent('component-a', { expectedValue: 'some expected value' })
testComponent('component-b', { expectedValue: 'some other expected value' })
})