Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
bhtibrewal
left a comment
There was a problem hiding this comment.
Good work on the tests, left 2 small comments
|
|
||
| fireEvent.keyDown(input, { key: 'A', code: 'KeyA' }); | ||
|
|
||
| expect(splitNSearch).toBeCalledTimes(2); |
There was a problem hiding this comment.
Should we reset the times called?
If some new tests above are added which do the same or we update some, then the rest of the test will fail as toBeCalledTimes would change
And when reading the title of the tests, and seeing the times it called its a little bit confusing as I would have thought it to be 0, but seeing it 2 will have to see actually how many times its being called
| const searchBar = screen.getByRole('textbox'); | ||
| expect(searchBar).toBeInTheDocument(); | ||
|
|
||
| const searchButton = screen.getByRole('button'); | ||
| expect(searchButton.innerHTML).toBe('Search'); | ||
|
|
||
| const label = screen.getByLabelText('Users'); | ||
| expect(label).toBeInTheDocument(); |
There was a problem hiding this comment.
Should we use test selector to get the components on the page?
If some new button or some new element is added in the file before the search button, won't the test fail?
There was a problem hiding this comment.
For this you can use screen.getByRole('button', { name: 'Search'}); This would get the specific element with role button and with text "Search".
There was a problem hiding this comment.
There was a problem hiding this comment.
Add tests for the standup dashboard page and search bar component
Test Coverage:
