Closed LynyrdRoss closed 1 year ago
@LynyrdRoss The cypress/xpath plugin is deprecated, so we won't be making updates to that plugin anymore. However, I don't see the use of cy.state('withinSubject') even being used in that plugin.
Do you use the cypress-testing-library plugin? I know they make a call to that here. https://github.com/testing-library/cypress-testing-library/blob/1af9f2f28b2ca62936da8a8acca81fc87e2192f7/src/utils.js#L10 That may be where the deprecation error is coming from.
I don't recall anyone in our team using that specific plugin. My bad for pointing out @cypress/xpath as my prime suspect. It's just that upon using cy.get, I get no cy.state warnings, but if I switch to cy.xpath, that's where all this warning comes in. Is there any alternative we can use for xpath selection?
@LynyrdRoss
This was a topic that was discussed also in Discord where you can read:
@cypress/xpath
is deprecated and it uses the deprecated cy.state()
$ npm install @cypress/xpath
npm WARN deprecated @cypress/xpath@2.0.3: Package no longer supported.
If it is all still working for you, then you could consider just ignoring the warning
Cypress Warning:
cy.state('withinSubject')
has been deprecated and will be removed in a future release.
cy.state()
has not yet been removed in the latest Cypress release 13.2.0
.
*Note: this is slightly out of date now, since the latest release is 13.3.0
.
@cypress/xpath
contains by viewing the PR https://github.com/cypress-io/cypress/pull/26893 which removed it or you can go back in history in this repository, which shows the line of code in the deprecated @cypress/xpath
which causes the warning:@LynyrdRoss
Is there any way I can get around this warning without removing the plugin?
No, as explained above. However you can simply ignore the warning.
I don't think that there is anything more that can be done in this issue regarding the deprecated and unsupported @cypress/xpath npm module, so I suggest to close the issue.
I completely understand. thanks @MikeMcC399 . At this point, it may be best to divert the use of xpath in Cypress. I'm just worried that on future releases where cy.state() is finally removed, we will be forced to adjust all object selectors created via xpath. If I can understand it correctly this is the only course of action that we have considering this has been an ongoing discussion for 4 years?
This issue https://github.com/cypress-io/cypress/issues/29294 means that Cypress still requires xpath in order to test Salesforce lightning elements properly
Current behavior
I get a warning every time I run a script that involves cy.xpath:
Desired behavior
My initial thoughts is to root out which plugin is causing this. And what I have learned in my own testing of my current plugins is @cypress/xpath.
Out project has page elements using xpath selectors. Is there any way I can get around this warning without removing the plugin?
Test code to reproduce
Repo with reproduction: https://github.com/LynyrdRoss/cypress-test-tiny/tree/cystate-problem
Cypress Version
12.17.4
Node version
16.16.0
Operating System
Windows 10
Debug Logs
No response
Other
This is the link for the plugin if it helps