cy.wait(20 * 1000);
cy.getAllByTestId('test-field-one')
.first()
.within(() => cy.getByTestId('test-field-two'))
.should('contain', 'test');
I'm currently using the above code, but I don't like the wait. I'd much rather prefer a timeout value. Does anyone know if this is possible in cypress?
The
getAll...
functions can't really use a timeout.The difference between
{ timeout: 20 * 1000 }
andcy.wait(20 * 1000)
is that timeout returns early when the condition it met.But how many exactly is "all"?
The only way to do an "all" query is to wait the maximum time and return everything at that point in time - which is what you already do with explicit
cy.wait()
.Since you are using
.first()
, just switch tocy.getByTestId()
Also note that
is testing
test-field-one
nottest-field-two
because.within()
does not pass on the inner value, it passes on the previous subject.