Skip to content

Commit 3f64545

Browse files
MatanBobieps1lon
andauthored
test: add missing test for suggestions (#1215)
* test: add missing test for suggestions * fix: cleanup in afterEach * Check we actually suggest * TODO: reword+fixup --------- Co-authored-by: eps1lon <[email protected]>
1 parent 4da0f39 commit 3f64545

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/__tests__/suggestions.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ beforeAll(() => {
77
})
88

99
afterEach(() => {
10-
configure({testIdAttribute: 'data-testid'})
10+
configure({testIdAttribute: 'data-testid', throwSuggestions: true})
1111
console.warn.mockClear()
1212
})
1313

@@ -103,6 +103,17 @@ test('should not suggest when suggest is turned off for a query', () => {
103103
).not.toThrowError()
104104
})
105105

106+
test('should suggest when suggest is turned on for a specific query but disabled in config', () => {
107+
configure({throwSuggestions: false})
108+
renderIntoDocument(`
109+
<button data-testid="foo">submit</button>
110+
<button data-testid="foot">another</button>`)
111+
112+
expect(() => screen.getByTestId('foo', {suggest: true})).toThrowError(
113+
"try this:\ngetByRole('button', { name: /submit/i })",
114+
)
115+
})
116+
106117
test('should suggest getByRole when used with getBy', () => {
107118
renderIntoDocument(`<button data-testid="foo">submit</button>`)
108119

0 commit comments

Comments
 (0)