Coding task · JavaScript and React course · Module 13: Testing React

Practice: Search and Filter

An input with type="search" has the searchbox role, and a select has the combobox role, so the test finds them with getByRole or getByLabelText. queryAllByRole('listitem') returns an empty array when nothing matches instead of throwing an error, which makes it a good way to check that an element disappeared. The test also checks that both filters work together and that the full list comes back after clearing the field.

Task

Finish the SearchFilter search in the space object atlas. ___BLANK1___: an object matches the search when its name contains the typed text, where neither letter case nor spaces at the start and end of the typed text matter (empty text matches everything). ___BLANK2___: an object matches the category when All is selected (the value 'all') or when its category equals the selected one. ___BLANK3___: when no object is left after filtering, a message with role="status" is shown instead of the list. The test types text into the search field (the searchbox role), picks a category from the list and checks the list items.