Skip to content

"Your callback function returned a promise which never resolved" error with cy.queryByText() #37

Closed
@vfernandestoptal

Description

@vfernandestoptal
  • cypress-testing-library version: 2.3.6
  • node version: 10.12.0
  • npm (or yarn) version: 6.4.1

I have a few tests checking that an elements doesn't exist using a command like

cy.queryByText("xxxxxxx", { timeout: 300 }).should("not.exist");

Usually, everything is fine. But, occasionally, I get a failure like this:

     CypressError: cy.then() timed out after waiting '400ms'.

Your callback function returned a promise which never resolved.

The callback function was:

function Command__queryByText(thenArgs) {
              return commandImpl(thenArgs.document)
            }
      at Object.cypressErr (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:65283:11)
      at Object.throwErr (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:65248:18)
      at Object.throwErrByPath (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:65275:17)
      at http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:54007:21
      at tryCatcher (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:127195:23)
      at http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:122505:41
      at tryCatcher (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:127195:23)
      at Promise._settlePromiseFromHandler (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:125213:31)
      at Promise._settlePromise (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:125270:18)
      at Promise._settlePromise0 (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:125315:10)
      at Promise._settlePromises (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:125390:18)
      at Async._drainQueue (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:122119:16)
      at Async._drainQueues (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:122129:10)
      at Async.drainQueues (http://xxx.xxx.xxx:8084/__cypress/runner/cypress_runner.js:122003:14)
      at <anonymous>

I nailed it down to the timeout on https://github.com/kentcdodds/cypress-testing-library/blob/master/src/index.js#L53 , and everything seems to work if we remove the timeout option.

Since waitForElement is already called with a timeout option on https://github.com/kentcdodds/cypress-testing-library/blob/master/src/index.js#L24 , is it needed on the cypress command chain? Could it be removed from that line 53?

Sorry for not providing a code sample, but I have not been able to reliably reproduce it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions