question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[solved] I get an error message if I don't prepend calls to findBy... with a get('body') call

See original GitHub issue
  • cypress-testing-library version: ^6.0.0
  • node version: v10.21.0
  • npm (or yarn) version: 1.22.4 (yarn)

Relevant code or config

    cy.visit('/email-verified')
      .findByText(/okay/i)

What you did:

I visit a page and call findByText

What happened:

I get the following error message:

Timed out retrying: Expected container to be an Element, a Document or a DocumentFragment but got Window.

image

If I call get('body') before calling findByText it works:

    cy.visit('/email-verified')
      .get('body')
      .findByText(/okay/i)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

15reactions
dutzicommented, Jun 23, 2020

Just posted this for anyone encoutering this. Turns out cypress-testing-library no longer supports chaining commands, so you have to write something like:

cy.visit('/page');
cy.findByText(/okay/i).click();
cy.findByText(/another button/i).click()
3reactions
selbekkcommented, Jul 1, 2020

Oh sorry, it’s just a new API - you’re not supposed to chain stuff any more. Perhaps we could implement a better error message?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to perform an action only if the Mono is empty and throw ...
I call a method on the repository layer that will find a user by username and if not found it will return an...
Read more >
Common mistakes with React Testing Library - Kent C. Dodds
Hi there I created React Testing Library because I wasn't satisfied with the testing landscape at the time. It expanded to DOM Testing ......
Read more >
Automation in Selenium: Page Object Model and Page Factory
Proper test automation is the key to quality software. Explore maintainable test automation in Selenium, including Page Object model and Page Factory.
Read more >
Document.getElementById() - Web APIs | MDN
If you need to get access to an element which doesn't have an ID, ... and not available as a method on all...
Read more >
Searching: getElement*, querySelector*
If an element has the id attribute, we can get the element using the ... The method getElementById can be called only on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found