Skip to content
Discussion options

You must be logged in to vote

Yeah, we don't have any commands that currently support retry-ability and promises at the same time. A couple of options:

  1. Hack together a workaround:
let result;

cy.wrap(null).should(() => {
  try {
    // If result is null or doesn't include the database, throw an on error
    expect(result).to.deep.include({ name: 'MyDb', version: 1 })
  } catch (e) {
    // If we had a result, null it out and start waiting on a new promise
    if (result) {
      result = null
      // Whenever this promise resolves, we'll assert on the result the next time .should() retries.
      win.indexedDB.databases().then(dbs => result = dbs)
    }
    throw e
  }

})

Not the cleanest thing, but something li…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@n10v
Comment options

@BlueWinds
Comment options

@n10v
Comment options

@BlueWinds
Comment options

Answer selected by n10v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants