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
cy.getByLabelText("Label text").getFormByTitle("Form title")// custom command.within(()=>{// select editor with the same label as the previous getByLabelText, but nested in the formcy.getByLabelText("Label text")})
Philosophy
There's nothing to guarantee that label texts are unique within the page. Users will be filling out a form one section at a time. The form can have a title to indicate to the user what they should be filling in, while the label texts themselves are no different to another form with a different title.
So to mimic how the user would fill in the page, you'd look for the form with that title and look for label texts within that form section.
Problem description:
Cypress supports a within function. All cy statements within the within function scope should use its subject as the container.
Currently, cypress-testing-library always uses the window.document as container.
Suggested solution:
Check cy.state("withinSubject") (Cypress source) to check whether the query is being executed within a within function scope and use it instead of doc as container parameter to query functions.
The text was updated successfully, but these errors were encountered:
cypress-testing-library
version: 2.0.0node
version: 8.4.0npm
version: 5.3.0Relevant code or config
Philosophy
There's nothing to guarantee that label texts are unique within the page. Users will be filling out a form one section at a time. The form can have a title to indicate to the user what they should be filling in, while the label texts themselves are no different to another form with a different title.
So to mimic how the user would fill in the page, you'd look for the form with that title and look for label texts within that form section.
Problem description:
Cypress supports a
within
function. All cy statements within thewithin
function scope should use its subject as the container.Currently,
cypress-testing-library
always uses thewindow.document
as container.Suggested solution:
Check
cy.state("withinSubject")
(Cypress source) to check whether the query is being executed within awithin
function scope and use it instead ofdoc
ascontainer
parameter to query functions.The text was updated successfully, but these errors were encountered: