DefinitelyTyped / DefinitelyTyped/DefinitelyTyped
[react-bootstrap-typeahead] InputProps and Typeahead do not allow by default to add properties like data-testid
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 51.4k
- Forks
- 30.4k
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 108
Description
Version 5.1.4
Steps to reproduce
// App.tsx
export default () => (
<Typeahead
data-testid='search-bar-input'
placeholder="Test"
filterBy={() => true}
autoFocus={true}
options={[]}
/>
)
Then import that file into a test using react-testing-library
// App.test.tsx
import { render } from '@testing-library/react';
import App from './App';
it('should be focused', async () => {
const { getByTestId, container } = render();
// console.log(container.innerHTML)
const input = getByTestId('search-bar-input')
expect(input).toHaveFocus()
});
Expected Behavior
It should pass the test
Actual Behavior
It cannot find search-bar-input
If we do a console.log(container.innerHTML)the result has no 'search-bar-input' at all
Temporally workaround
inputProps={{
'data-testid': 'search-bar-input',
} as InputProps}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Typeahead and InputProps definitions implicated by the App.tsx reproduction. Run App.test.tsx with React Testing Library and confirm that data-testid is available on the rendered input; done means the provided getByTestId lookup and focus assertion pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100