В Cypress я хочу создать метод, который будет запускать другие методы, если условие будет в порядке.
Код:
sizeOfTableShouldBeChangedAfterResizingIfThereAreManyData() {
cy.get('.footerWrapper').then(div => {
if(div.find('.pagination').length) {
cy.get('.pagination > .page').its('length').then(numberOfPages => {
if(numberOfPages > 3) {
this.numberOfRowsShouldBeEqualAtLeast(10)
this.changeNumberOfDisplayedRowsByIndex(1)
this.numberOfRowsShouldBeEqualAtLeast(20)
this.changeNumberOfDisplayedRowsByIndex(0)
this.numberOfRowsShouldBeEqualAtLeast(10)
return this
}
})
}
})
return this
}
От Cypress я получил сообщение:
CypressError: cy.then() failed because you are mixing up async and sync code.
In your callback function you invoked 1 or more cy commands but then returned a synchronous value.
Cypress commands are asynchronous and it doesn't make sense to queue cy commands and yet return a synchronous value.
You likely forgot to properly chain the cy commands using another cy.then().
The value you synchronously returned was: '{}'
Я прочитал документацию от:
https://docs.cypress.io/guides/overview/why-cypress.html#In-a-nutshell
Но я не уверен, как это должно быть написано для правильной работы. После этого метода я хочу вызывать другие синхронно.
У кого-нибудь есть идеи, как я могу это сделать?