Description
react-testing-library
version: 5.3.1react
version: 16.7.0-alpha.2typescript
version: 3.2.1node
version: 10.12.0yarn
version: 1.10.1
Relevant code or config:
const { queryByRole } = render(<Something />)
expect(queryByRole('alertdialog')).toBeFalsy()
What you did:
As you can see there is argument called text
, but it's of HTMLElement
type.
Tried the following to satisfy typings, but then it fails in runtime with error TypeError: matcher.test is not a function
apparently because the container
is nor string or a function, so it expects the RegExp.
Reproduction:
I would create one, but CodeSandbox for TypeScript is rather wonky and doesn't work correctly every time. I think that images above are a clear reproduction :) Whole repo is probably overkill
Problem description:
It's rather curious that getByRole
has no such issue.
Suggested solution:
I tried to look into it, but my current mental capacity cannot cover this. For once I don't get how getByRole
is typed correctly without any modification on react-testing-library
side, but queries are wrong. This is some advanced TypeScript technique I am failing to comprehend.
@jpavon @pbomb Looks like you touched that part before. Do you have some insight perhaps?