Replies: 1 comment 5 replies
-
@lmiller1990 Would it be possible to have Cypress' position on this one? I can also explain why in our (real world) app we still need to have wrapper classes for several UI components and also page objects:
I probably could go on... ;-) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Before I create an issue I wanted to check what Cypress' position is on the following topic.
In Angular some components often have host style with "display:contents" so that the layout is not changed by the element of the component (I'm not aware of other reasons other than lazyness when layout issues occur?)
Now in the tests there may or may not exist selectors which point to such an element which has set "display:contents". This selector may then be used in an assertion like
cy.get('myElementWithDisplayContents').should('not.be.visible')
and a counter part that checks for visibility may not exist. We cannot easily know whether that other assertion exists.What we're left with is an assertion that ALWAYS passes because an element with "display:contents" is always invisible to Cypress (and also the inspector in the browser). There may be really strange edge cases where some JS dynamically changes "display:contents" on and off. But I think it would be really advantageous for the majority of Cypress users to let the test immediately fail whenever a selector points to an element which has "display:contents" set.
I'm aware that this means that more checks need to be done when running assertions like "not.visible" / "not.be.visible" (that's what I did in a class which wraps
cy.get()
.What is Cypress' position on this? Would it be possible/feasable/smart to add this check into Cypress and let the user deactivate it for edge cases?
Personally I think I could live with my workaround even though it's not really pretty and efficient.
In parallel I'm working on more strict typing for selectors so that the above can be avoided during compile time:
"my-autocomplete-component" could be component which has "display:contents" and contains an input element which actually can be dynamically shown/hidden:
This way I know in my wrapper class what kind of component was selected and where the selector is pointing at..
Otherwise it's just a game of guessing and requires other code such as:
Any ideas :D
Beta Was this translation helpful? Give feedback.
All reactions