Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test finishing with commands in its queue when calling method on undefined with cy async return #284

Closed
jennifer-shehane opened this issue Nov 2, 2016 · 1 comment

Comments

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Nov 2, 2016

When I write the following test case, an error throws saying that some commands were not finished:

describe('Test', function() {
  beforeEach(function() {
    return cy
  })

  it('asserts length', function() {
    cy.get('foobar').should('have.length', undefined.length)
  })
})

Cypress error:

CypressError: Oops, Cypress detected something wrong with your test code.

The test has finished but Cypress still has commands in its queue.
The 1 queued commands that have not yet run are:

- cy.get('foobar')

In every situation we've seen, this has been caused by programmer error.
Most often this indicates a race condition due to a forgotten 'return' or from commands in a previously run test bleeding into the current test.

For a much more thorough explanation including examples please review this error here:

https://on.cypress.io/command-queue-ended-early

But when I remove the beforeEach, the proper error is thrown: that it cannot read 'length' of undefined.

describe('Test', function() {
  it('asserts length', function() {
    cy.get('foobar').should('have.length', undefined.length)
  })
})

Cypress error:

TypeError: Cannot read property 'length' of undefined
@jennifer-shehane jennifer-shehane changed the title Test finishing with commands in its queue when calling method on undefined + using beforeEach Test finishing with commands in its queue when calling method on undefined with cy async return Nov 2, 2016
@jennifer-shehane
Copy link
Member Author

Can confirm this only happens in version 0.17.5 and up.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant