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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions