我想知道是否有辦法重新運行相同的測驗兩次(第二次使用不同的 url)以避免復制粘貼完全相同的代碼應該如下所示:
describe('...', () => {
before(() => cy.visit('/))
describe('Series of tests ...', () => {
// Tests goes here
})
after(() => {
cy.visit('other url')
cy.rerun() // Re run the describe right above with the new url is there a way to do something like this ?
})
})
uj5u.com熱心網友回復:
您可以使用Cypress Lodash迭代一定次數。
const urls = ['url1', 'url2'];
describe('...', () => {
Cypress._.times(urls.length, ((index) => {
it('Runs the test', () => {
cy.visit(url[index]);
// rest of test
});
});
});
uj5u.com熱心網友回復:
直接迭代url更容易,
const urls = ['url1', 'url2'];
describe('...', () => {
urls.forEach(url => {
it('Runs the test', () => {
cy.visit(url);
// rest of test
});
});
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/416384.html
標籤:
上一篇:保存照片SwiftUI
