-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(render): add new query capabilities for improved tests (#17)
**What**: Add the following methods - queryByText - getByText - queryByPlaceholderText - getByPlaceholderText - queryByLabelText - getByLabelText **Why**: Closes #16 These will really improve the usability of this module. These also align much better with the guiding principles 👍 **How**: - Created a `queries.js` file where we have all the logic for the queries and their associated getter functions - Migrate tests where it makes sense - Update docs considerably. **Checklist**: * [x] Documentation * [x] Tests * [x] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? --> * [ ] Added myself to contributors table N/A
- Loading branch information
Kent C. Dodds
authored
Mar 23, 2018
1 parent
2eb804a
commit 12c7ed1
Showing
16 changed files
with
541 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`getByTestId finds matching element 1`] = ` | ||
<span | ||
data-testid="test-component" | ||
/> | ||
`; | ||
|
||
exports[`getByTestId throws error when no matching element exists 1`] = `"Unable to find element by [data-testid=\\"unknown-data-testid\\"]"`; | ||
|
||
exports[`queryByTestId finds matching element 1`] = ` | ||
<span | ||
data-testid="test-component" | ||
/> | ||
`; | ||
exports[`get throws a useful error message 1`] = `"Unable to find a label with the text of: LucyRicardo"`; | ||
|
||
exports[`get throws a useful error message 2`] = `"Unable to find an element with the placeholder text of: LucyRicardo"`; | ||
|
||
exports[`get throws a useful error message 3`] = `"Unable to find an element with the text: LucyRicardo. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible."`; | ||
|
||
exports[`get throws a useful error message 4`] = `"Unable to find an element by: [data-testid=\\"LucyRicardo\\"]"`; | ||
|
||
exports[`label with no form control 1`] = `"Found a label with the text of: alone, however no form control was found associated to that label. Make sure you're using the \\"for\\" attribute or \\"aria-labelledby\\" attribute correctly."`; | ||
|
||
exports[`totally empty label 1`] = `"Found a label with the text of: , however no form control was found associated to that label. Make sure you're using the \\"for\\" attribute or \\"aria-labelledby\\" attribute correctly."`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.