Comments (6)
You cannot use Cypress' assertions inside cy.waitUntil
. cy.wrap
already has retry-ability and timeout customization so go with it without using cy.waitUntil
!
Your code should look like
- standard version:
cy.wrap('445').should('eq', '44')
- custom timeout version:
cy.wrap('445', {timeout: 20000}).should('eq', '44')
- (not necessary) waitUntil version without wrap:
cy.waitUntil(() => '445' === '44', { timeout: 20000, interval:2000 })
- (not necessary) waitUntil version with wrap:
cy.waitUntil(() => cy.wrap('445').then(myString => myString === '44'), { timeout: 20000, interval:2000 })
The general advice is: do not use cy.waitUntil
if you can handle what you need with Cypress built-in functionalities.
Hope it helps, feel free to reopen the issue 😉
from cypress-wait-until.
Thank you for your answer!
But my example was only example..
This is real case:
When I visit my site, I can see some numbers in [class="tickers__price-value"]
After sometimes (1-10 seconds) numbers will change.
So, I dont want use cy.wait(10), I'd like end test as soon as numbers has been changed.
cy.visit('/')
cy.get('[class="tickers__price-value"]').invoke('text').then(firstDate => {
cy.get('[class="tickers__price-value"]').invoke('text').should('not.eq', firstDate)
})
})
How set timeout there? using cy.waitUntil
from cypress-wait-until.
I have not tested it but this should be enough with cy.waitUntil
😉
cy.visit('/')
cy.get('[class="tickers__price-value"]')
.invoke('text')
.waitUntil(
(firstDate) =>
cy
.get('[class="tickers__price-value"]')
.invoke('text')
.then((newDate) => newDate !== firstDate),
{timeout: 20000}
)
Please let me know if it works 😊
from cypress-wait-until.
Your code works perfect)
Big thanks)
from cypress-wait-until.
You're welcome 😊
from cypress-wait-until.
@SlavikDMI I was curious and I'd like to solve your problem with Cypress built-ins too... and I found the solution 😊 you can find everything in this repository and the file you need to checkout is issue.spec.js.
Long story short: in the Cypress docs there is an example of your use case that, applied to your code, looks like the following:
cy.get('[class="tickers__price-value"]')
.invoke('text')
.then((firstDate) => {
cy.get('[class="tickers__price-value"]', { timeout: 20000 }).should(($el) => {
const newDate = $el.text()
expect(newDate).to.not.eq(firstDate)
})
})
- the
timeout
must be set to thecy.get
call - the text retrieval must be performed inside the
.should(...)
call
And it works fine 😊
Last but not least: if you have looked for a solution on Google/StackOverflow and you haven't found anything useful... Please help the community doing so
- raise a new question on StackOverflow
- explain well your problem and link to all the resources that seemed helpful but they weren't (and why)
- I'll reply with the solution and you accept it
Doing so:
- the next time you are looking for the same solution you find it directly searching on Google
- you'll help other developers with the same problem
- other useful and alternative solutions could come and we both learn something new
What do you think? 😊
from cypress-wait-until.
Related Issues (20)
- Great use of wait-until if you have detached dom problems HOT 1
- Document Promise.reject() as anti-pattern HOT 3
- Timed out retrying after 4000ms: Expected to find element HOT 2
- Global timeout HOT 3
- Overwrite WaitUntil command HOT 3
- Cypress throw an error when returning `true` inside the cy.waitUntil callback HOT 4
- Example/Document Request: How to catch 'errorMsg' if cy.waitUntil() exceeds 'timeout'? HOT 1
- How to write test code about progess bar by waituntil HOT 3
- Wait for DOM change in order to assert completion of a job HOT 3
- Element is never found when timeout options are overrided HOT 5
- Update plugin to be compatible with Cypress 10 HOT 4
- feature request: use config file to set default timeout HOT 2
- Question: can I waitUntil multiple elements appear? HOT 2
- Cypress configuration error HOT 3
- Using cy.reload() - Failed because you are mixing up async and sync code. HOT 5
- Not working on the latest cypress version HOT 5
- Timeout can take longer than defined HOT 6
- allow node 16 HOT 5
- Is version 2.0.1 compatible with cypress 10? HOT 3
- Problem with TypeScript signature HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cypress-wait-until.