cy.clock() preventing the subsequent visit/reload to load completely when running in emulator
See original GitHub issueCurrent behavior:
In emulator, Page is not loading completely if we are setting the clock before visiting the page
In emulator: Set the clock --> visit the page again --> page is not loading completely.
Desired behavior:
Page should be completely loaded. (please note : There is no issue with the flow when executed on chrome desktop view)
Test code to reproduce
code snippet which is causing issue
//eg : url = https://www.amazon.com/ (or) https://www.unibet.co.uk/
cy.clock(new Date().getTime())
cy.visit(url)
config used:
{
"userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
"viewportWidth":414,
"viewportHeight":896
}
Versions
“cypress”: “^4.5.0” running on chrome 81
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
clock - Cypress Documentation
cy.clock() overrides native global functions related to time allowing them to be controlled synchronously via cy.tick() or the yielded clock object. This.
Read more >Cypress clock function makes html body invisible
The cy.clock() command overwrites and freezes the javascript functions relating to timers - setTimeout, setInterval as well as the Date ...
Read more >Cypress Cy.Tick() Not Forwarding Time The Second Time It Is ...
The fact that Cypress is running inside the same context as the. ... clock preventing the subsequent visit/reload to load completely when running...
Read more >Make The Test Faster Using cy.clock And cy.tick Commands
If the application uses a setTimeout or other time -related functions, you can speed it up by controlling the application's clock using the ......
Read more >Stop the time with cy.clock | przemuh.dev
Now it is time to write some cypress tests. We are testing! In our test scenario we would like to check: if the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So basically, there is some call using
setTimeout
that your application requires when it’s on this userAgent in order to load your page. Since callingcy.clock()
overwritessetTimeout
, the time is not clicking forward in order to trigger what it needed in this call.You can see that the loading of the site breaks only if you overwrite
setTimeout
.If you want to only overwrite the
Date
object, I recommend explicitly specifying to only overwrite that function like below:If you still want to overwrite the
setTimeout
timing, you’ll need to tick time forward so that your call tosetTimeout
is called as time would normally progress.In the code snippet, I have given another example about loading the site https://www.unibet.co.uk which is under our control, the result is same in this case as well. The page is not loaded completely