Skip to content

Commit 2209724

Browse files
authored
Merge branch 'main' into feat/byrole-disabled
2 parents eeebfc2 + fb069c9 commit 2209724

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@
6565
"aria-query": "^5.0.0",
6666
"chalk": "^4.1.0",
6767
"dom-accessibility-api": "^0.5.9",
68-
"lz-string": "^1.4.4",
68+
"lz-string": "^1.5.0",
6969
"pretty-format": "^27.0.2"
7070
},
7171
"devDependencies": {
7272
"@testing-library/jest-dom": "^5.11.6",
73-
"@types/lz-string": "^1.3.34",
7473
"jest-in-case": "^1.0.2",
7574
"jest-snapshot-serializer-ansi": "^1.0.0",
7675
"jest-watch-select-projects": "^2.0.0",

src/__tests__/suggestions.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ beforeAll(() => {
66
configure({throwSuggestions: true})
77
})
88

9+
beforeEach(() => {
10+
// We're testing suggestions of find* queries but we're not interested in their time-related behavior.
11+
// Real timers would make the test suite slower for no reason.
12+
jest.useFakeTimers()
13+
})
14+
915
afterEach(() => {
10-
configure({testIdAttribute: 'data-testid'})
16+
jest.useRealTimers()
17+
configure({testIdAttribute: 'data-testid', throwSuggestions: true})
1118
console.warn.mockClear()
1219
})
1320

@@ -103,6 +110,17 @@ test('should not suggest when suggest is turned off for a query', () => {
103110
).not.toThrowError()
104111
})
105112

113+
test('should suggest when suggest is turned on for a specific query but disabled in config', () => {
114+
configure({throwSuggestions: false})
115+
renderIntoDocument(`
116+
<button data-testid="foo">submit</button>
117+
<button data-testid="foot">another</button>`)
118+
119+
expect(() => screen.getByTestId('foo', {suggest: true})).toThrowError(
120+
"try this:\ngetByRole('button', { name: /submit/i })",
121+
)
122+
})
123+
106124
test('should suggest getByRole when used with getBy', () => {
107125
renderIntoDocument(`<button data-testid="foo">submit</button>`)
108126

0 commit comments

Comments
 (0)