Skip to content

Commit

Permalink
test: add missing test for suggestions (#1215)
Browse files Browse the repository at this point in the history
* test: add missing test for suggestions

* fix: cleanup in afterEach

* Check we actually suggest

* TODO: reword+fixup

---------

Co-authored-by: eps1lon <[email protected]>
  • Loading branch information
MatanBobi and eps1lon authored Mar 8, 2023
1 parent 4da0f39 commit 3f64545
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/__tests__/suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ beforeAll(() => {
})

afterEach(() => {
configure({testIdAttribute: 'data-testid'})
configure({testIdAttribute: 'data-testid', throwSuggestions: true})
console.warn.mockClear()
})

Expand Down Expand Up @@ -103,6 +103,17 @@ 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(
"try this:\ngetByRole('button', { name: /submit/i })",
)
})

test('should suggest getByRole when used with getBy', () => {
renderIntoDocument(`<button data-testid="foo">submit</button>`)

Expand Down

0 comments on commit 3f64545

Please sign in to comment.