@@ -18,10 +18,11 @@ const queryByA11yRole = queryByProp.bind(null, 'accessibilityRole');
1818const queryAllByA11yRole = queryAllByProp . bind ( null , 'accessibilityRole' ) ;
1919
2020function queryAllByText (
21- { rootInstance } ,
21+ container ,
2222 text ,
2323 { types = [ Text , TextInput ] , exact = true , collapseWhitespace, trim, normalizer } = { } ,
2424) {
25+ const rootInstance = container . root ;
2526 const matcher = exact ? matches : fuzzyMatches ;
2627 const matchNormalizer = makeNormalizer ( { collapseWhitespace, trim, normalizer } ) ;
2728
@@ -42,8 +43,8 @@ function queryByText(...args) {
4243// 1. The error messages are specific to each one and depend on arguments
4344// 2. The stack trace will look better because it'll have a helpful method name.
4445
45- function getAllByTestId ( { rootInstance , container } , id , ...rest ) {
46- const els = queryAllByTestId ( { rootInstance , container } , id , ...rest ) ;
46+ function getAllByTestId ( container , id , ...rest ) {
47+ const els = queryAllByTestId ( container , id , ...rest ) ;
4748 if ( ! els . length ) {
4849 throw getElementError ( `Unable to find an element with the testID: ${ id } ` , container ) ;
4950 }
@@ -54,8 +55,8 @@ function getByTestId(...args) {
5455 return firstResultOrNull ( getAllByTestId , ...args ) ;
5556}
5657
57- function getAllByA11yRole ( { rootInstance , container } , value , ...rest ) {
58- const els = queryAllByA11yRole ( { rootInstance , container } , value , ...rest ) ;
58+ function getAllByA11yRole ( container , value , ...rest ) {
59+ const els = queryAllByA11yRole ( container , value , ...rest ) ;
5960 if ( ! els . length ) {
6061 throw getElementError ( `Unable to find an element by accessibilityRole="${ value } ".` , container ) ;
6162 }
@@ -66,8 +67,8 @@ function getByA11yRole(...args) {
6667 return firstResultOrNull ( getAllByA11yRole , ...args ) ;
6768}
6869
69- function getAllByValue ( { rootInstance , container } , value , ...rest ) {
70- const els = queryAllByValue ( { rootInstance , container } , value , ...rest ) ;
70+ function getAllByValue ( container , value , ...rest ) {
71+ const els = queryAllByValue ( container , value , ...rest ) ;
7172 if ( ! els . length ) {
7273 throw getElementError ( `Unable to find an element with the value: ${ value } .` , container ) ;
7374 }
@@ -78,8 +79,8 @@ function getByValue(...args) {
7879 return firstResultOrNull ( getAllByValue , ...args ) ;
7980}
8081
81- function getAllByA11yLabel ( { rootInstance , container } , text , ...rest ) {
82- const els = queryAllByA11yLabel ( { rootInstance , container } , text , ...rest ) ;
82+ function getAllByA11yLabel ( container , text , ...rest ) {
83+ const els = queryAllByA11yLabel ( container , text , ...rest ) ;
8384 if ( ! els . length ) {
8485 throw getElementError ( `Unable to find an element by accessibilityLabel="${ text } "` , container ) ;
8586 }
@@ -90,8 +91,8 @@ function getByA11yLabel(...args) {
9091 return firstResultOrNull ( getAllByA11yLabel , ...args ) ;
9192}
9293
93- function getAllByPlaceholder ( { rootInstance , container } , text , ...rest ) {
94- const els = queryAllByPlaceholder ( { rootInstance , container } , text , ...rest ) ;
94+ function getAllByPlaceholder ( container , text , ...rest ) {
95+ const els = queryAllByPlaceholder ( container , text , ...rest ) ;
9596 if ( ! els . length ) {
9697 throw getElementError (
9798 `Unable to find an element with the placeholder text of: ${ text } ` ,
@@ -105,8 +106,8 @@ function getByPlaceholder(...args) {
105106 return firstResultOrNull ( getAllByPlaceholder , ...args ) ;
106107}
107108
108- function getAllByText ( { rootInstance , container } , text , ...rest ) {
109- const els = queryAllByText ( { rootInstance , container } , text , ...rest ) ;
109+ function getAllByText ( container , text , ...rest ) {
110+ const els = queryAllByText ( container , text , ...rest ) ;
110111 if ( ! els . length ) {
111112 throw getElementError (
112113 `Unable to find an element with the text: ${ text } . This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.` ,
@@ -121,9 +122,9 @@ function getByText(...args) {
121122}
122123
123124function makeFinder ( getter ) {
124- return ( testInstance , text , options , waitForElementOptions ) =>
125+ return ( testContainer , text , options , waitForElementOptions ) =>
125126 waitForElement (
126- ( instance = testInstance ) => getter ( instance , text , options ) ,
127+ ( container = testContainer ) => getter ( container , text , options ) ,
127128 waitForElementOptions ,
128129 ) ;
129130}
0 commit comments