You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@OliverJAsh Regarding the issue we talked about — here's a suggestion for how we can really get the right Window yielded by cy.window().
If my suggestion falls outside the scope of this pull request, please let me know — I can open a separate issue or a pull request instead.
Problem
When you run a test with Cypress, there are two Window instances in play.
The top Window object in which the Cypress UI lives, and
The Window that represents the tested application.
These are different Windows, but they share the same definition. If you define additional properties by using declaration merging, they will appear on both, which in most cases is incorrect and leads to bugs.
Solution
Allow users to define global variables separately.
In cli/types/index.d.ts, define an empty interface called ApplicationWindow.
interfaceApplicationWindow{}
Change the definition for cy.window so that the yielded object includes the properties defined by ApplicationWindow.
The code for this is done in cypress-io/cypress#7806, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Current behavior:
It's from #6624.
Previously this would type error:
(
window
should have typeWindow & typeof globalThis
.)You may want to fix other instances of
Chainable<Window>
as well.It's from the comment in #6624
@OliverJAsh Regarding the issue we talked about — here's a suggestion for how we can really get the right
Window
yielded bycy.window()
.If my suggestion falls outside the scope of this pull request, please let me know — I can open a separate issue or a pull request instead.
Problem
When you run a test with Cypress, there are two
Window
instances in play.Window
object in which the Cypress UI lives, andWindow
that represents the tested application.These are different
Window
s, but they share the same definition. If you define additional properties by using declaration merging, they will appear on both, which in most cases is incorrect and leads to bugs.Solution
Allow users to define global variables separately.
In
cli/types/index.d.ts
, define an empty interface calledApplicationWindow
.Change the definition for
cy.window
so that the yielded object includes the properties defined byApplicationWindow
.Usage
The users can now define properties that exist on the yielded
window
, but not on thewindow
accessed directly inside a Cypress test.Originally posted by @karol-majewski in #6624 (comment)
Desired behavior:
Window
definition should includeglobalThis
definitions.ApplicationWindow
can be extended.Test code to reproduce
Versions
Cypress 4.9.0.
The text was updated successfully, but these errors were encountered: