@@ -107,7 +107,7 @@ The example below will find the input node for the following DOM structures:
107
107
<!-- Native-->
108
108
109
109
``` javascript
110
- import { getByLabelText } from ' dom- testing-library'
110
+ import { getByLabelText } from ' @ testing-library/dom '
111
111
112
112
const container = document .body
113
113
const inputNode = getByLabelText (container, ' Username' )
@@ -116,7 +116,7 @@ const inputNode = getByLabelText(container, 'Username')
116
116
<!-- React-->
117
117
118
118
``` js
119
- import { render } from ' react- testing-library'
119
+ import { render } from ' @ testing-library/react '
120
120
121
121
const { getByLabelText } = render (< Login / > )
122
122
@@ -172,7 +172,7 @@ matches the given [`TextMatch`](#textmatch).
172
172
<!-- Native-->
173
173
174
174
``` js
175
- import { getByPlaceholderText } from ' dom- testing-library'
175
+ import { getByPlaceholderText } from ' @ testing-library/dom '
176
176
177
177
const container = document .body
178
178
const inputNode = getByPlaceholderText (container, ' Username' )
@@ -181,7 +181,7 @@ const inputNode = getByPlaceholderText(container, 'Username')
181
181
<!-- React-->
182
182
183
183
``` js
184
- import { render } from ' react- testing-library'
184
+ import { render } from ' @ testing-library/react '
185
185
186
186
const { getByPlaceholderText } = render (< MyComponent / > )
187
187
const inputNode = getByPlaceholderText (' Username' )
@@ -229,7 +229,7 @@ matching the given [`TextMatch`](#textmatch).
229
229
<!-- Native-->
230
230
231
231
``` js
232
- import { getByText } from ' dom- testing-library'
232
+ import { getByText } from ' @ testing-library/dom '
233
233
234
234
const container = document .body
235
235
const aboutAnchorNode = getByText (container, / about/ i )
@@ -238,7 +238,7 @@ const aboutAnchorNode = getByText(container, /about/i)
238
238
<!-- React-->
239
239
240
240
``` js
241
- import { render } from ' react- testing-library'
241
+ import { render } from ' @ testing-library/react '
242
242
243
243
const { getByText } = render (< MyComponent / > )
244
244
const aboutAnchorNode = getByText (/ about/ i )
@@ -305,7 +305,7 @@ as it's deprecated).
305
305
<!-- Native-->
306
306
307
307
``` js
308
- import { getByAltText } from ' dom- testing-library'
308
+ import { getByAltText } from ' @ testing-library/dom '
309
309
310
310
const container = document .body
311
311
const incrediblesPosterImg = getByAltText (container, / incredibles. *? poster/ i )
@@ -314,7 +314,7 @@ const incrediblesPosterImg = getByAltText(container, /incredibles.*? poster/i)
314
314
<!-- React-->
315
315
316
316
``` js
317
- import { render } from ' react- testing-library'
317
+ import { render } from ' @ testing-library/react '
318
318
319
319
const { getByAltText } = render (< MyComponent / > )
320
320
const incrediblesPosterImg = getByAltText (/ incredibles. *? poster/ i )
@@ -360,7 +360,7 @@ Will also find a `title` element within an SVG.
360
360
<!-- Native-->
361
361
362
362
``` js
363
- import { getByTitle } from ' dom- testing-library'
363
+ import { getByTitle } from ' @ testing-library/dom '
364
364
365
365
const container = document .body
366
366
const deleteElement = getByTitle (container, ' Delete' )
@@ -370,7 +370,7 @@ const closeElement = getByTitle(container, 'Close')
370
370
<!-- React-->
371
371
372
372
``` js
373
- import { render } from ' react- testing-library'
373
+ import { render } from ' @ testing-library/react '
374
374
375
375
const { getByTitle } = render (< MyComponent / > )
376
376
const deleteElement = getByTitle (' Delete' )
@@ -419,7 +419,7 @@ document.getElementById('lastName').value = 'Norris'
419
419
<!-- Native-->
420
420
421
421
``` js
422
- import { getByDisplayValue } from ' dom- testing-library'
422
+ import { getByDisplayValue } from ' @ testing-library/dom '
423
423
424
424
const container = document .body
425
425
const lastNameInput = getByDisplayValue (container, ' Norris' )
@@ -428,7 +428,7 @@ const lastNameInput = getByDisplayValue(container, 'Norris')
428
428
<!-- React-->
429
429
430
430
``` js
431
- import { render } from ' react- testing-library'
431
+ import { render } from ' @ testing-library/react '
432
432
433
433
const { getByDisplayValue } = render (< MyComponent / > )
434
434
const lastNameInput = getByDisplayValue (' Norris' )
@@ -457,7 +457,7 @@ document.getElementById('messageTextArea').value = 'Hello World'
457
457
<!-- Native-->
458
458
459
459
``` js
460
- import { getByDisplayValue } from ' dom- testing-library'
460
+ import { getByDisplayValue } from ' @ testing-library/dom '
461
461
462
462
const container = document .body
463
463
const messageTextArea = getByDisplayValue (container, ' Hello World' )
@@ -466,7 +466,7 @@ const messageTextArea = getByDisplayValue(container, 'Hello World')
466
466
<!-- React-->
467
467
468
468
``` js
469
- import { render } from ' react- testing-library'
469
+ import { render } from ' @ testing-library/react '
470
470
471
471
const { getByDisplayValue } = render (< MyComponent / > )
472
472
const messageTextArea = getByDisplayValue (' Hello World' )
@@ -499,7 +499,7 @@ matches the given [`TextMatch`](#textmatch).
499
499
<!-- Native-->
500
500
501
501
``` js
502
- import { getByDisplayValue } from ' dom- testing-library'
502
+ import { getByDisplayValue } from ' @ testing-library/dom '
503
503
504
504
const container = document .body
505
505
const selectElement = getByDisplayValue (container, ' Alaska' )
@@ -508,7 +508,7 @@ const selectElement = getByDisplayValue(container, 'Alaska')
508
508
<!-- React-->
509
509
510
510
``` js
511
- import { render } from ' react- testing-library'
511
+ import { render } from ' @ testing-library/react '
512
512
513
513
const { getByDisplayValue } = render (< MyComponent / > )
514
514
const selectElement = getByDisplayValue (' Alaska' )
@@ -549,7 +549,7 @@ accepts a [`TextMatch`](#textmatch)).
549
549
<!-- Native-->
550
550
551
551
``` js
552
- import { getByRole } from ' dom- testing-library'
552
+ import { getByRole } from ' @ testing-library/dom '
553
553
554
554
const container = document .body
555
555
const dialogContainer = getByRole (container, ' dialog' )
@@ -558,7 +558,7 @@ const dialogContainer = getByRole(container, 'dialog')
558
558
<!-- React-->
559
559
560
560
``` js
561
- import { render } from ' react- testing-library'
561
+ import { render } from ' @ testing-library/react '
562
562
563
563
const { getByRole } = render (< MyComponent / > )
564
564
const dialogContainer = getByRole (' dialog' )
@@ -599,7 +599,7 @@ also accepts a [`TextMatch`](#textmatch)).
599
599
<!-- Native-->
600
600
601
601
``` js
602
- import { getByTestId } from ' dom- testing-library'
602
+ import { getByTestId } from ' @ testing-library/dom '
603
603
604
604
const container = document .body
605
605
const usernameInput = getByTestId (container, ' username-input' )
@@ -608,7 +608,7 @@ const usernameInput = getByTestId(container, 'username-input')
608
608
<!-- React-->
609
609
610
610
``` js
611
- import { render } from ' react- testing-library'
611
+ import { render } from ' @ testing-library/react '
612
612
613
613
const { getByTestId } = render (< MyComponent / > )
614
614
const usernameInput = getByTestId (' username-input' )
@@ -632,7 +632,7 @@ cy.getByTestId('username-input').should('exist')
632
632
633
633
#### Overriding ` data-testid `
634
634
635
- The ` ...ByTestId ` functions in ` dom-testing-library ` use the attribute
635
+ The ` ...ByTestId ` functions in ` DOM Testing Library ` use the attribute
636
636
` data-testid ` by default, following the precedent set by
637
637
[ React Native Web] ( https://github.com/testing-library/react-testing-library/issues/1 )
638
638
which uses a ` testID ` prop to emit a ` data-testid ` attribute on the element, and
@@ -661,7 +661,7 @@ affect the precision of string matching:
661
661
662
662
### Normalization
663
663
664
- Before running any matching logic against text in the DOM, ` dom-testing-library `
664
+ Before running any matching logic against text in the DOM, ` DOM Testing Library `
665
665
automatically normalizes that text. By default, normalization consists of
666
666
trimming whitespace from the start and end of text, and collapsing multiple
667
667
adjacent whitespace characters into a single space.
0 commit comments