Skip to content

Commit 34c9548

Browse files
Add test to make sure query doesn't print playground link when container has no children
1 parent 20b938a commit 34c9548

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

src/__tests__/get-by-errors.js

+11-18
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,7 @@ cases(
9797
},
9898
)
9999

100-
test.each([
101-
['getByLabelText'],
102-
['getByPlaceholderText'],
103-
['getByText'],
104-
['getByAltText'],
105-
['getByTitle'],
106-
['getByRole'],
107-
['getByTestId'],
108-
])(
100+
test.each([['getByText'], ['getByLabelText']])(
109101
'%s query will print the playground link when enabled in the config',
110102
query => {
111103
configure({printPlaygroundLink: true})
@@ -114,15 +106,7 @@ test.each([
114106
},
115107
)
116108

117-
test.each([
118-
['getByLabelText'],
119-
['getByPlaceholderText'],
120-
['getByText'],
121-
['getByAltText'],
122-
['getByTitle'],
123-
['getByRole'],
124-
['getByTestId'],
125-
])(
109+
test.each([['getByText'], ['getByLabelText']])(
126110
'%s query will NOT print the playground link when disabled in the config',
127111
query => {
128112
configure({printPlaygroundLink: false})
@@ -131,6 +115,15 @@ test.each([
131115
},
132116
)
133117

118+
test.each([['getByText'], ['getByLabelText']])(
119+
'%s query will NOT print the playground link when element has no children',
120+
query => {
121+
configure({printPlaygroundLink: true})
122+
document.body.innerHTML = ''
123+
expect(() => screen[query]('TEST QUERY')).not.toThrowError(/playground/i)
124+
},
125+
)
126+
134127
describe('*ByDisplayValue queries throw an error when there are multiple elements returned', () => {
135128
test('getByDisplayValue', () => {
136129
const {getByDisplayValue} = render(

0 commit comments

Comments
 (0)