Skip to content

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

Closed
@aledustet

Description

@aledustet
  • 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.

Activity

kentcdodds

kentcdodds commented on Apr 5, 2019

@kentcdodds
Member

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

added a commit that references this issue on Apr 5, 2019
021ef9d
aledustet

aledustet commented on Apr 5, 2019

@aledustet
Author

wow @kentcdodds 34 seconds 🔥 🙇

kentcdodds

kentcdodds commented on Apr 5, 2019

@kentcdodds
Member

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

allcontributors

allcontributors commented on Apr 5, 2019

@allcontributors
Contributor

@kentcdodds

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

kentcdodds

kentcdodds commented on Apr 5, 2019

@kentcdodds
Member

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

kentcdodds

kentcdodds commented on Apr 5, 2019

@kentcdodds
Member

🎉 This issue has been resolved in version 6.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @kentcdodds@aledustet

      Issue actions

        waitForElement not working as expect on latest react version(16.8.6) · Issue #347 · testing-library/react-testing-library