99< script defer src ="/react-native-testing-library/static/js/lib-react.49604bf759.js "> </ script >
1010< script defer src ="/react-native-testing-library/static/js/lib-router.a0df4de158.js "> </ script >
1111< script defer src ="/react-native-testing-library/static/js/2482.4740a55c68.js "> </ script >
12- < script defer src ="/react-native-testing-library/static/js/index.5d61bfb5d3 .js "> </ script >
12+ < script defer src ="/react-native-testing-library/static/js/index.57322732e5 .js "> </ script >
1313< meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
1414< meta name ="generator " content ="Rspress v2.0.9 ">
1515< meta property ="og:url " content ="https://oss.callstack.com/react-native-testing-library/ ">
@@ -48,7 +48,7 @@ <h3 class="rp-toc-include" id="example"><a href="#example" class="rp-header-anch
4848< span class ="line "> </ span >
4949< span class ="line "> < span style ="color:var(--shiki-token-comment) "> // Follow-up assertions do not need to be async, as we already waited for sign in operation to complete</ span > </ span >
5050< span class ="line "> < span style ="color:var(--shiki-token-function) "> expect</ span > < span style ="color:var(--shiki-foreground) "> (</ span > </ span >
51- < span class ="line "> < span style ="color:var(--shiki-token-constant) "> screen</ span > < span style ="color:var(--shiki-token-function) "> .queryByRole</ span > < span style ="color:var(--shiki-foreground) "> (</ span > < span style ="color:var(--shiki-token-string-expression) "> 'header'</ span > < span style ="color:var(--shiki-token-punctuation) "> ,</ span > < span style ="color:var(--shiki-foreground) "> { name</ span > < span style ="color:var(--shiki-token-keyword) "> :</ span > < span style ="color:var(--shiki-token-string-expression) "> 'Sign in to Hello World App'</ span > < span style ="color:var(--shiki-foreground) "> })</ span > </ span >
51+ < span class ="line "> < span style ="color:var(--shiki-token-constant) "> screen</ span > < span style ="color:var(--shiki-token-function) "> .queryByRole</ span > < span style ="color:var(--shiki-foreground) "> (</ span > < span style ="color:var(--shiki-token-string-expression) "> 'header'</ span > < span style ="color:var(--shiki-token-punctuation) "> ,</ span > < span style ="color:var(--shiki-foreground) "> { name</ span > < span style ="color:var(--shiki-token-keyword) "> :</ span > < span style ="color:var(--shiki-token-string-expression) "> 'Sign in to Hello World App'</ span > < span style ="color:var(--shiki-foreground) "> })</ span > < span style =" color:var(--shiki-token-punctuation) " > , </ span > < /span >
5252< span class ="line "> < span style ="color:var(--shiki-foreground) "> ).</ span > < span style ="color:var(--shiki-token-constant) "> not</ span > < span style ="color:var(--shiki-token-function) "> .toBeOnTheScreen</ span > < span style ="color:var(--shiki-foreground) "> ();</ span > </ span >
5353< span class ="line "> < span style ="color:var(--shiki-token-function) "> expect</ span > < span style ="color:var(--shiki-foreground) "> (</ span > < span style ="color:var(--shiki-token-constant) "> screen</ span > < span style ="color:var(--shiki-token-function) "> .queryByLabelText</ span > < span style ="color:var(--shiki-foreground) "> (</ span > < span style ="color:var(--shiki-token-string-expression) "> 'Username'</ span > < span style ="color:var(--shiki-foreground) "> )).</ span > < span style ="color:var(--shiki-token-constant) "> not</ span > < span style ="color:var(--shiki-token-function) "> .toBeOnTheScreen</ span > < span style ="color:var(--shiki-foreground) "> ();</ span > </ span >
5454< span class ="line "> < span style ="color:var(--shiki-token-function) "> expect</ span > < span style ="color:var(--shiki-foreground) "> (</ span > < span style ="color:var(--shiki-token-constant) "> screen</ span > < span style ="color:var(--shiki-token-function) "> .queryByLabelText</ span > < span style ="color:var(--shiki-foreground) "> (</ span > < span style ="color:var(--shiki-token-string-expression) "> 'Password'</ span > < span style ="color:var(--shiki-foreground) "> )).</ span > < span style ="color:var(--shiki-token-constant) "> not</ span > < span style ="color:var(--shiki-token-function) "> .toBeOnTheScreen</ span > < span style ="color:var(--shiki-foreground) "> ();</ span > </ span >
@@ -81,7 +81,7 @@ <h3 class="rp-toc-include" id="waitfor-function"><a href="#waitfor-function" cla
8181< span class ="line "> < span style ="color:var(--shiki-foreground) "> options</ span > < span style ="color:var(--shiki-token-keyword) "> ?:</ span > < span style ="color:var(--shiki-foreground) "> {</ span > </ span >
8282< span class ="line "> < span style ="color:var(--shiki-foreground) "> timeout</ span > < span style ="color:var(--shiki-token-keyword) "> :</ span > < span style ="color:var(--shiki-token-constant) "> number</ span > < span style ="color:var(--shiki-foreground) "> ;</ span > </ span >
8383< span class ="line "> < span style ="color:var(--shiki-foreground) "> interval</ span > < span style ="color:var(--shiki-token-keyword) "> :</ span > < span style ="color:var(--shiki-token-constant) "> number</ span > < span style ="color:var(--shiki-foreground) "> ;</ span > </ span >
84- < span class ="line "> < span style ="color:var(--shiki-foreground) "> }</ span > </ span >
84+ < span class ="line "> < span style ="color:var(--shiki-foreground) "> }</ span > < span style =" color:var(--shiki-token-punctuation) " > , </ span > < /span >
8585< span class ="line "> < span style ="color:var(--shiki-foreground) "> )</ span > < span style ="color:var(--shiki-token-keyword) "> :</ span > < span style ="color:var(--shiki-token-function) "> Promise</ span > < span style ="color:var(--shiki-foreground) "> <</ span > < span style ="color:var(--shiki-token-function) "> T</ span > < span style ="color:var(--shiki-foreground) "> >;</ span > </ span > </ code > </ pre > </ div > < div class ="rp-code-button-group "> < button class ="rp-code-button-group__button rp-code-wrap-button " title ="Toggle code wrap "> < svg xmlns ="http://www.w3.org/2000/svg " width ="32 " height ="32 " viewBox ="0 0 24 24 " class ="rp-code-button-group__icon rp-code-button-group__icon--wrapped "> < path fill ="currentColor " d ="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z "> </ path > </ svg > < svg xmlns ="http://www.w3.org/2000/svg " width ="32 " height ="32 " viewBox ="0 0 24 24 " class ="rp-code-button-group__icon rp-code-button-group__icon--wrap "> < path fill ="currentColor " d ="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z "> </ path > </ svg > </ button > < button class ="rp-code-button-group__button rp-code-copy-button " title ="Copy code "> < svg xmlns ="http://www.w3.org/2000/svg " width ="272 " height ="272 " viewBox ="0 0 272 272 " class ="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy "> < path fill ="currentColor " fill-rule ="evenodd " d ="M45.883 23.368h123.823v22.514H68.396v146.336H45.883zm45.026 45.027H225.99v180.107H90.91zm22.514 22.513v135.08h90.053V90.908z " clip-rule ="evenodd "> </ path > </ svg > < svg xmlns ="http://www.w3.org/2000/svg " width ="271 " height ="271 " viewBox ="0 0 271 271 " class ="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success "> < path fill ="currentColor " d ="M112.687 203.223H90.174v-22.514h22.512v-22.514h22.512v22.514h-22.511zm-22.514-22.514H67.66v-22.514h22.513zm-22.514-22.514H45.146v-22.512H67.66zm90.054 0h-22.514v-22.512h22.514zm22.514-22.512h-22.514v-22.514h22.514zm22.513-22.514h-22.513V90.655h22.513zm22.514-22.514H202.74V68.143h22.514z "> </ path > </ svg > </ button > </ div > </ div > </ div >
8686< p > It accepts an < code > expectation</ code > to be validated and repeats the check every defined interval until it no longer throws an error. Similarly to < code > findBy*</ code > queries they accept < code > timeout</ code > and < code > interval</ code > options and have the same default values of 1000ms for timeout, and a checking interval of 50 ms.</ p >
8787< h4 class ="rp-toc-include " id ="example-2 "> < a href ="#example-2 " class ="rp-header-anchor rp-link " aria-hidden ="true "> #</ a > Example</ h4 >
@@ -94,7 +94,7 @@ <h3 class="rp-toc-include" id="waitforelementtoberemoved-function"><a href="#wai
9494< span class ="line "> < span style ="color:var(--shiki-foreground) "> options</ span > < span style ="color:var(--shiki-token-keyword) "> ?:</ span > < span style ="color:var(--shiki-foreground) "> {</ span > </ span >
9595< span class ="line "> < span style ="color:var(--shiki-foreground) "> timeout</ span > < span style ="color:var(--shiki-token-keyword) "> :</ span > < span style ="color:var(--shiki-token-constant) "> number</ span > < span style ="color:var(--shiki-foreground) "> ;</ span > </ span >
9696< span class ="line "> < span style ="color:var(--shiki-foreground) "> interval</ span > < span style ="color:var(--shiki-token-keyword) "> :</ span > < span style ="color:var(--shiki-token-constant) "> number</ span > < span style ="color:var(--shiki-foreground) "> ;</ span > </ span >
97- < span class ="line "> < span style ="color:var(--shiki-foreground) "> }</ span > </ span >
97+ < span class ="line "> < span style ="color:var(--shiki-foreground) "> }</ span > < span style =" color:var(--shiki-token-punctuation) " > , </ span > < /span >
9898< span class ="line "> < span style ="color:var(--shiki-foreground) "> )</ span > < span style ="color:var(--shiki-token-keyword) "> :</ span > < span style ="color:var(--shiki-token-function) "> Promise</ span > < span style ="color:var(--shiki-foreground) "> <</ span > < span style ="color:var(--shiki-token-function) "> T</ span > < span style ="color:var(--shiki-foreground) "> > {}</ span > </ span > </ code > </ pre > </ div > < div class ="rp-code-button-group "> < button class ="rp-code-button-group__button rp-code-wrap-button " title ="Toggle code wrap "> < svg xmlns ="http://www.w3.org/2000/svg " width ="32 " height ="32 " viewBox ="0 0 24 24 " class ="rp-code-button-group__icon rp-code-button-group__icon--wrapped "> < path fill ="currentColor " d ="M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z "> </ path > </ svg > < svg xmlns ="http://www.w3.org/2000/svg " width ="32 " height ="32 " viewBox ="0 0 24 24 " class ="rp-code-button-group__icon rp-code-button-group__icon--wrap "> < path fill ="currentColor " d ="M16 7H3V5h13zM3 19h13v-2H3zm19-7-4-3v2H3v2h15v2z "> </ path > </ svg > </ button > < button class ="rp-code-button-group__button rp-code-copy-button " title ="Copy code "> < svg xmlns ="http://www.w3.org/2000/svg " width ="272 " height ="272 " viewBox ="0 0 272 272 " class ="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy "> < path fill ="currentColor " fill-rule ="evenodd " d ="M45.883 23.368h123.823v22.514H68.396v146.336H45.883zm45.026 45.027H225.99v180.107H90.91zm22.514 22.513v135.08h90.053V90.908z " clip-rule ="evenodd "> </ path > </ svg > < svg xmlns ="http://www.w3.org/2000/svg " width ="271 " height ="271 " viewBox ="0 0 271 271 " class ="rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success "> < path fill ="currentColor " d ="M112.687 203.223H90.174v-22.514h22.512v-22.514h22.512v22.514h-22.511zm-22.514-22.514H67.66v-22.514h22.513zm-22.514-22.514H45.146v-22.512H67.66zm90.054 0h-22.514v-22.512h22.514zm22.514-22.512h-22.514v-22.514h22.514zm22.513-22.514h-22.513V90.655h22.513zm22.514-22.514H202.74V68.143h22.514z "> </ path > </ svg > </ button > </ div > </ div > </ div >
9999< p > This function is, in a way, the negation of < code > waitFor</ code > as it expects the initial expectation to be true (not throw an error), only to turn invalid (start throwing errors) on subsequent runs. It operates using the same < code > timeout</ code > and < code > interval</ code > parameters as < code > findBy*</ code > queries and < code > waitFor</ code > .</ p >
100100< h4 class ="rp-toc-include " id ="example-3 "> < a href ="#example-3 " class ="rp-header-anchor rp-link " aria-hidden ="true "> #</ a > Example</ h4 >
0 commit comments