英文:
Why isnt cypress honoring my timeout for a single command?
问题
以下是您要翻译的内容:
"I'm a couple of weeks into cypress test automation (cypress V12) and while it seems cool I am confused by what I am seeing.
I have code that looks like this:
it('shows the problem for Stack Overflow', {defaultCommandTimeout: 20000}, function () {
//bunch of commands that do stuff are here but I dont think they are related to the issue...
const loadingSpinnerLocator = ".k-loader-canvas";
cy.get(loadingSpinnerLocator).should('be.visible');
cy.get(loadingSpinnerLocator).should('not.exist' ,{ timeout: 15000 });
})
this code works fine because I am doing a workaround in the top line and overriding the defaultCommandTimeout to 20 seconds.
If I remove the override on the "it statement" the test fails when we are making sure that the spinner is gone after 4 seconds. Isn't my code saying to look for 15 seconds???
How do I tell cypress to "wait up to 15 seconds for the loading spinner to not be there" without bumping up the timeout for the whole test??"
英文:
I'm a couple of weeks into cypress test automation (cypress V12) and while it seems cool I am confused by what I am seeing.
I have code that looks like this:
it('shows the problem for Stack Overflow', {defaultCommandTimeout: 20000}, function () {
//bunch of commands that do stuff are here but I dont think they are related to the issue...
const loadingSpinnerLocator = ".k-loader-canvas";
cy.get(loadingSpinnerLocator).should('be.visible');
cy.get(loadingSpinnerLocator).should('not.exist' ,{ timeout: 15000 });
})
this code works fine because I am doing a workaround in the top line and overriding the defaultCommandTimeout to 20 seconds.
If I remove the override on the "it statement" the test fails when we are making sure that the spinner is gone after 4 seconds. Isn't my code saying to look for 15 seconds???
How do I tell cypress to "wait up to 15 seconds for the loading spinner to not be there" without bumping up the timeout for the whole test??
答案1
得分: 3
一般来说,{ timeout: 15000 }
是一个选项对象。
所有 Cypress 命令都在语法部分有文档,其中告诉您是否可以传递选项,例如 .should()
> 语法
> js > .should(chainers) > .should(chainers, value) > .should(chainers, method, value) > .should(callbackFn) >
这告诉您.should()
没有选项语法。
另一方面,对于 .get(),有允许传递 options
参数的不同排列方式,
> 语法
> js > cy.get(selector) > cy.get(alias) > cy.get(selector, options) > cy.get(alias, options) >
英文:
Generally speaking, { timeout: 15000 }
is an options object.
All Cypress commands are documented with a Syntax section which tells you if you can pass options, for example .should()
> Syntax
> js
> .should(chainers)
> .should(chainers, value)
> .should(chainers, method, value)
> .should(callbackFn)
>
This tells you there is no options syntax for .should()
.
On the other hand for .get(), there are permutations that allow an options
parameter,
> Syntax
> js
> cy.get(selector)
> cy.get(alias)
> cy.get(selector, options)
> cy.get(alias, options)
>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论