@@ -74,7 +74,9 @@ test(`should not suggest if the suggestion would give different results`, () =>
7474} )
7575
7676test ( 'should suggest by label over title' , ( ) => {
77- renderIntoDocument ( `<label><span>bar</span><input title="foo" /></label>` )
77+ renderIntoDocument (
78+ `<label><span>bar</span><input type="password" title="foo" /></label>` ,
79+ )
7880
7981 expect ( ( ) => screen . getByTitle ( 'foo' ) ) . toThrowError (
8082 / g e t B y L a b e l T e x t \( \/ b a r \/ i \) / ,
@@ -181,7 +183,7 @@ test('escapes regular expressions in suggestion', () => {
181183
182184test ( 'should suggest getByLabelText when no role available' , ( ) => {
183185 renderIntoDocument (
184- `<label for="foo">Username</label><input data-testid="foo" id="foo" />` ,
186+ `<label for="foo">Username</label><input type="password" data-testid="foo" id="foo" />` ,
185187 )
186188 expect ( ( ) => screen . getByTestId ( 'foo' ) ) . toThrowError (
187189 / g e t B y L a b e l T e x t \( \/ u s e r n a m e \/ i \) / ,
@@ -232,19 +234,21 @@ test.each([
232234
233235test ( `should suggest label over placeholder text` , ( ) => {
234236 renderIntoDocument (
235- `<label for="foo">Username </label><input id="foo" data-testid="foo" placeholder="Username " />` ,
237+ `<label for="foo">Password </label><input type="password" id="foo" data-testid="foo" placeholder="Password " />` ,
236238 )
237239
238- expect ( ( ) => screen . getByPlaceholderText ( 'Username ' ) ) . toThrowError (
239- / g e t B y L a b e l T e x t \( \/ u s e r n a m e \/ i \) / ,
240+ expect ( ( ) => screen . getByPlaceholderText ( 'Password ' ) ) . toThrowError (
241+ / g e t B y L a b e l T e x t \( \/ p a s s w o r d \/ i \) / ,
240242 )
241243} )
242244
243245test ( `should suggest getByPlaceholderText` , ( ) => {
244- renderIntoDocument ( `<input data-testid="foo" placeholder="Username" />` )
246+ renderIntoDocument (
247+ `<input type="password" data-testid="foo" placeholder="Password" />` ,
248+ )
245249
246250 expect ( ( ) => screen . getByTestId ( 'foo' ) ) . toThrowError (
247- / g e t B y P l a c e h o l d e r T e x t \( \/ u s e r n a m e \/ i \) / ,
251+ / g e t B y P l a c e h o l d e r T e x t \( \/ p a s s w o r d \/ i \) / ,
248252 )
249253} )
250254
@@ -257,25 +261,27 @@ test(`should suggest getByText for simple elements`, () => {
257261} )
258262
259263test ( `should suggest getByDisplayValue` , ( ) => {
260- renderIntoDocument ( `<input id="lastName" data-testid="lastName" />` )
264+ renderIntoDocument (
265+ `<input type="password" id="password" data-testid="password" />` ,
266+ )
261267
262- document . getElementById ( 'lastName ' ) . value = 'Prine' // RIP John Prine
268+ document . getElementById ( 'password ' ) . value = 'Prine' // RIP John Prine
263269
264- expect ( ( ) => screen . getByTestId ( 'lastName ' ) ) . toThrowError (
270+ expect ( ( ) => screen . getByTestId ( 'password ' ) ) . toThrowError (
265271 / g e t B y D i s p l a y V a l u e \( \/ p r i n e \/ i \) / ,
266272 )
267273} )
268274
269275test ( `should suggest getByAltText` , ( ) => {
270276 renderIntoDocument ( `
271- <input data-testid="input" alt="last name " />
277+ <input type="password" data-testid="input" alt="password " />
272278 <map name="workmap">
273279 <area data-testid="area" shape="rect" coords="34,44,270,350" alt="Computer">
274280 </map>
275281 ` )
276282
277283 expect ( ( ) => screen . getByTestId ( 'input' ) ) . toThrowError (
278- / g e t B y A l t T e x t \( \/ l a s t n a m e \/ i \) / ,
284+ / g e t B y A l t T e x t \( \/ p a s s w o r d \/ i \) / ,
279285 )
280286 expect ( ( ) => screen . getByTestId ( 'area' ) ) . toThrowError (
281287 / g e t B y A l t T e x t \( \/ c o m p u t e r \/ i \) / ,
0 commit comments