Skip to content

waitForElement not working as expect on latest react version(16.8.6) #347

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

Closed
aledustet opened this issue Apr 5, 2019 · 6 comments · Fixed by #346
Closed

waitForElement not working as expect on latest react version(16.8.6) #347

aledustet opened this issue Apr 5, 2019 · 6 comments · Fixed by #346
Labels

Comments

@aledustet
Copy link

aledustet commented Apr 5, 2019

  • react-testing-library version: 6.1.1
  • react version: 16.8.6
  • node version: 11.10.1
  • yarn version: 1.13.0
  • jest-dom version: 3.1.3

What you did:

Just run yarn create react-app from-scratch --typescript
Add the react-testing-library and jest-dom to the package.json, update the App.test.tsx with:

import React from 'react';
import {render, waitForElement } from 'react-testing-library'
import 'jest-dom/extend-expect'

test('tests', async () => {
  const { getByTestId } = render(
    <div data-testid='error'>something</div>
  );

  const something = await waitForElement(() => getByTestId('error'))
  expect(something).toHaveTextContent('something')
})

What happened:

Screen Shot 2019-04-05 at 3 36 58 PM

Reproduction:

code sandbox

Problem description:

The tests pass if I downgrade to:

    "react": "16.8.1",
    "react-dom": "16.8.1",,
    "react-testing-library": "5.5.3",
    "jest-dom": "3.0.0"

Suggested solution:

I'm starting the bisect from the versions to see what might be changed.

@joual joual mentioned this issue Apr 5, 2019
4 tasks
@kentcdodds
Copy link
Member

Yup, this should be fixed in a few minutes :)

kentcdodds pushed a commit that referenced this issue Apr 5, 2019
* failing test

* act-compat change

* fix(act): ensure that the result is returned from our wrapper

Closes #345
Closes #347
@aledustet
Copy link
Author

wow @kentcdodds 34 seconds 🔥 🙇

@kentcdodds
Copy link
Member

@allcontributors[bot], please add @aledustet for bug

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @aledustet! 🎉

@kentcdodds
Copy link
Member

No problem! Thanks for taking the time to report the issue!

@kentcdodds
Copy link
Member

🎉 This issue has been resolved in version 6.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

lucbpz pushed a commit to lucbpz/react-testing-library that referenced this issue Jul 26, 2020
* docs: update README.md

* docs: update .all-contributorsrc

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants