cypress-testing-library: TypeError: container.querySelectorAll is not a function

  • cypress-testing-library version: 5.1.1
  • node version: 12.4.0
  • npm (or yarn) version: 1.21.1 (yarn)

Relevant code or config


describe('anonymous calculator', () => {
  it('can make calculations', () => {
    cy.visit('/')
      .findByText(/^1$/)
      .click()
      .findByText(/^\+$/)
      .click()
      .findByText(/^2$/)
      .click()
      .findByText(/^=$/)
      .click()
      .findByTestId('total')
      .should('have.text', '3')
  })
})

What you did: Attempted to run tjs/cypress-04 branch of https://github.com/kentcdodds/jest-cypress-react-babel-webpack/tree/tjs/cypress-04

What happened:

Screen Shot 2020-01-30 at 1 52 55 PM

Reproduction repository: https://github.com/kentcdodds/jest-cypress-react-babel-webpack/tree/tjs/cypress-04

Problem description:

TypeError: container.querySelectorAll is not a function

Suggested solution:

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (12 by maintainers)

Commits related to this issue

Most upvoted comments

For people who came across this issue, from what I understand, starting from @testing-library/cypress@6.0.0, they are no longer supporting chaining of multiple find* commands. So, you’ll have to write it as

    cy.visit('/')
    cy.findByText(/^1$/).click()
    cy.findByText(/^\+$/).click()
    cy.findByText(/^2$/).click()
    cy.findByText(/^=$/).click()
    cy.findByTestId('total').should('have.text', '3')

More discussion about this decision on: https://github.com/testing-library/cypress-testing-library/issues/110

@kentcdodds @tlrobinson please correct me if I’m wrong. Also, it would be helpful to add this change to release changelog: https://github.com/testing-library/cypress-testing-library/releases.

🎉 This issue has been resolved in version 5.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

5.1.2 has been published to revert that change. I apologize for not recognizing the implications of the change in the first place. Sorry for the bump.

Ok, I think that in order to address the breaking change I’m going to revert #100 right now, and then we can talk about the merits of making a breaking change to support it in a new major version bump.

I agree that would be better for the course. Will probably do something like that in the next update 👍 thanks!

I’ll look up this issue and see if it is related to #100 and if there is any way to introduce #100 as a non-breaking change

Oh, Crumbs. No, I was on 5.1.1, I’m sorry @kentcdodds @twgraham!