Google chrome 相同的Cypress测试在使用Chrome&;电子
我的同事和我在我们的机器上运行相同的Cypress测试套件,但得到的结果不同 我们使用的Cypress版本是Google chrome 相同的Cypress测试在使用Chrome&;电子,google-chrome,electron,cypress,Google Chrome,Electron,Cypress,我的同事和我在我们的机器上运行相同的Cypress测试套件,但得到的结果不同 我们使用的Cypress版本是3.8.3 当它们运行\node\u modules\.bin\cypress run时,所有测试都通过 但是当我尝试在我的机器上运行相同的命令时,其中一个测试失败了 我收到以下错误消息: <failure message="cy.type() can only be called on a single element. Your subject contained 8
3.8.3
当它们运行\node\u modules\.bin\cypress run
时,所有测试都通过
但是当我尝试在我的机器上运行相同的命令时,其中一个测试失败了
我收到以下错误消息:
<failure message="cy.type() can only be called on a single element.
Your subject contained 8 elements." type="CypressError">
<![CDATA[CypressError: cy.type() can only be called on a single element. Your subject contained 8 elements.
我能理解测试的意思,但我不知道为什么我们在不同的机器上运行相同的测试时会得到不同的结果
我能发现的一个区别是,他们可以选择在Chrome上运行测试,而我只能选择在Electron上运行
是否有人可以帮助解释导致此问题的原因以及如何解决此问题Cypress会自动检测本地计算机上安装的浏览器。因此,请检查您是否安装了chrome。电子直接来自柏树
应用程序行为可能因机器而异,也可能因浏览器而异,具体取决于配置和互联网速度。因此,在最终将测试标记为失败之前,使用它将根据定义的值重试测试总是很好的。cypress 5.0中引入了测试重试
您可以通过cypress.json
{
"retries": {
// Configure retry attempts for `cypress run`
// Default is 0
"runMode": 2,
// Configure retry attempts for `cypress open`
// Default is 0
"openMode": 0
}
或者,您也可以将其添加到特定测试中-
describe('User sign-up and login', () => {
// `it` test block with no custom configuration
it('should redirect unauthenticated user to sign-in page', () => {
// ...
})
// `it` test block with custom configuration
it(
'allows user to login',
{
retries: {
runMode: 2,
openMode: 1,
},
},
() => {
// ...
}
)
})
也可以是特定的测试套件-
// Customizing retry attempts for a suite of tests
describe('User bank accounts', {
retries: {
runMode: 2,
openMode: 1,
}
}, () => {
// The per-suite configuration is applied to each test
// If a test fails, it will be retried
it('allows a user to view their transactions', () => {
// ...
}
it('allows a user to edit their transactions', () => {
// ...
}
})
这个错误听起来非常特定于您正在测试的DOM(听起来像是一个有多个输入的表单),您能充实一下DOM的细节和它所使用的测试吗?