In this example, I have to iterate through pages until the "Next" button is disabled. On every page, I grab the number of visible table rows, adding them all up. After we get to the last page and the "Next" button is disabled, we wrap the total rows count and use an alias to save the final value. Later, we will get the value using the alias and confirm it is equal to the expected number. Find the source code and more examples like this one at
https://github.com/bahmutov/cypress-recurse