-
Notifications
You must be signed in to change notification settings - Fork 470
test: add missing test for suggestions #1215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
652bad8
6d62cc6
ab0f71a
f48356c
183d075
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,16 @@ test('should not suggest when suggest is turned off for a query', () => { | |
).not.toThrowError() | ||
}) | ||
|
||
test('should suggest when suggest is turned on for a specific query but disabled in config', () => { | ||
configure({throwSuggestions: false}) | ||
renderIntoDocument(` | ||
<button data-testid="foo">submit</button> | ||
<button data-testid="foot">another</button>`) | ||
|
||
expect(() => screen.getByTestId('foo', {suggest: true})).toThrowError() | ||
configure({throwSuggestions: true}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These setup+cleanup tasks need to be in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is the only test needing them, I didn't want to add the overhead of running that code in a 'beforeEach' and 'afterEach' so I changed it at the beginning and returned it to what the 'beforeAll' hook defined. Do you think it will be better in this case to do it in the hooks instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. every setup/cleanup for tests needs to be in hooks for the the reason I explained: once a test fails, the whole test run is tainted because because its cleanup didn't run. This can be super confusing if you try to debug the last test that fails when the only reason for that test failure is the first test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, that's a good point, thanks. |
||
}) | ||
|
||
test('should suggest getByRole when used with getBy', () => { | ||
renderIntoDocument(`<button data-testid="foo">submit</button>`) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really testing whether we're suggesting anything. Just that an error is thrown. I'll see if a snapshot makes more sense