Skip to content
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

Queries and RenderResult use incompatible types #841

Closed
pawbor opened this issue Dec 2, 2020 · 3 comments
Closed

Queries and RenderResult use incompatible types #841

pawbor opened this issue Dec 2, 2020 · 3 comments
Labels
duplicate This issue or pull request already exists

Comments

@pawbor
Copy link

pawbor commented Dec 2, 2020

  • @testing-library/react version: 11.2.2
  • Testing Framework and version: irrelevant
  • DOM Environment: irrelevant

Relevant code or config:

it('example', () => {
  const { container } = render(<span>foo</span>); // container type is Element

  getByText(container as HTMLElement, 'foo'); // can't use container here without casting to HTMLElement
});

What you did:

I tried to use container in custom query.

What happened:

Types do not match without manual casting.

Reproduction:

https://codesandbox.io/s/react-testing-library-demo-forked-bt601?file=/src/__tests__/hello.tsx

Suggested solution:

Loosening type requirements for element provided to Queries

@MatanBobi
Copy link
Member

Hi @pawbor, thanks for taking the time to open this :)
This one looks like a duplicate of testing-library/dom-testing-library#838.
@nickmccurdy is already working on a fix for this I believe.

@pawbor
Copy link
Author

pawbor commented Dec 2, 2020

Thank you! <3 I really appreciate all the work put in this library.

@nickserv
Copy link
Member

nickserv commented Dec 3, 2020

You can follow testing-library/dom-testing-library#834

@nickserv nickserv closed this as completed Dec 3, 2020
@nickserv nickserv added the duplicate This issue or pull request already exists label Dec 3, 2020
MatanBobi referenced this issue Dec 6, 2020
Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants