forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix _global.setTimeout being undefined when restoring the clock (cypr…
…ess-io#2875) fixes cypress-io#2850 this fixes an edge case where the application under test changed the clock at a later time and when we restored the clock, the global function became undefined due to deleting the property off of window
- Loading branch information
1 parent
e7b8683
commit 2f97cb3
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/driver/test/cypress/integration/issues/2850_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// https://github.com/cypress-io/cypress/issues/2850 | ||
describe('issue #2850: invoking cy.clock() before two visits', () => { | ||
it('works the first time', () => { | ||
cy.clock() | ||
cy.visit('/fixtures/generic.html') | ||
cy.window().then((win) => { | ||
// override the setTimeout function now | ||
win.setTimeout = () => {} | ||
}) | ||
}) | ||
|
||
it('works the second time', () => { | ||
cy.clock() | ||
cy.visit('/fixtures/generic.html') | ||
}) | ||
|
||
it('works the third time', () => { | ||
cy.clock().then((clock) => { | ||
cy.visit('/fixtures/generic.html') | ||
cy.window().then((win) => { | ||
// override the setTimeout function now | ||
win.setTimeout = () => { } | ||
|
||
// manually restore the clock | ||
clock.restore() | ||
}) | ||
cy.clock().then((clock2) => { | ||
clock2.restore() | ||
}) | ||
}) | ||
}) | ||
|
||
it('works the forth time', () => { | ||
cy.clock() | ||
cy.visit('/fixtures/generic.html') | ||
}) | ||
}) |