Page Not Found
We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
diff --git a/404.html b/404.html index ea7842db8..b701bdba4 100644 --- a/404.html +++ b/404.html @@ -1,16 +1,16 @@ - +
- -We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
*ByText
, *ByDisplayValue
, *ByPlaceholderText
queries now return host elements",id:"3-bytext-bydisplayvalue-byplaceholdertext-queries-now-return-host-elements",level:3},{value:"4. container
API has been renamed to UNSAFE_root
.",id:"4-container-api-has-been-renamed-to-unsafe_root",level:3},{value:"Full Changelog",id:"full-changelog",level:2}],p={toc:m},f="wrapper";function h(e){var t=e.components,n=(0,r.Z)(e,o);return(0,a.kt)(f,(0,i.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("admonition",{type:"note"},(0,a.kt)("p",{parentName:"admonition"},"If you use ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/testing-library/jest-native"},"Jest Native matchers"),", which we recommend, then you should upgrade it to version 5.4.2 or higher.")),(0,a.kt)("p",null,"React Native Testing Library 12 introduces a handful of breaking changes compared to 11.x versions. We believe they were necessary to improve the experience using the library and help the users ",(0,a.kt)("a",{parentName:"p",href:"https://blog.codinghorror.com/falling-into-the-pit-of-success/"},"fall into the pit of success")," when writing meaningful tests. You will find migration instructions for each and every change described below."),(0,a.kt)(l.Z,{toc:m,mdxType:"TOCInline"}),(0,a.kt)("h2",{id:"breaking-changes"},"Breaking changes"),(0,a.kt)("h3",{id:"1-all-queries-exclude-elements-hidden-from-accessibility-by-default"},"1. All queries exclude elements hidden from accessibility by default"),(0,a.kt)("p",null,"Elements that are hidden from accessiblity, e.g. elements on non-active screen when using React Navigation, now will not be matched by default by all queries. This is the effect of switching the default value for global config option ",(0,a.kt)("inlineCode",{parentName:"p"},"defaultIncludeHiddenElements"),"(api#defaultincludehiddenelements-option) to ",(0,a.kt)("inlineCode",{parentName:"p"},"false"),"."),(0,a.kt)("p",null,"Previous behaviour of matching hidden elements can be enabled on query level using ",(0,a.kt)("a",{parentName:"p",href:"api-queries#includehiddenelements-option"},"includeHiddenElements")," query options or globally using ",(0,a.kt)("inlineCode",{parentName:"p"},"defaultIncludeHiddenElements"),"(api#defaultincludehiddenelements-option) configuration option."),(0,a.kt)("h3",{id:"2-byrole-queries-now-return-only-accessibility-elements"},"2. ",(0,a.kt)("inlineCode",{parentName:"h3"},"*ByRole")," queries now return only accessibility elements"),(0,a.kt)("p",null,(0,a.kt)("inlineCode",{parentName:"p"},"*ByRole")," queries now return only accessibility elements, either explicitly marked with ",(0,a.kt)("inlineCode",{parentName:"p"},"accessible")," prop or implicit ones where this status is derived from component type itself (e.g ",(0,a.kt)("inlineCode",{parentName:"p"},"Text"),", ",(0,a.kt)("inlineCode",{parentName:"p"},"TextInput"),", ",(0,a.kt)("inlineCode",{parentName:"p"},"Switch"),", but not ",(0,a.kt)("inlineCode",{parentName:"p"},"View"),")."),(0,a.kt)("p",null,"You may need to adjust relevant components under test to make sure they pass ",(0,a.kt)("inlineCode",{parentName:"p"},"isAccessibilityElement")," check."),(0,a.kt)("h4",{id:"examples"},"Examples"),(0,a.kt)("p",null,"Let's assume we are using ",(0,a.kt)("inlineCode",{parentName:"p"},'getByRole("button")')," query."),(0,a.kt)("p",null,"Following elements will match:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},'// Explicit "accessible" prop for View\n*ByRole
queries now return only accessibility elements",id:"2-byrole-queries-now-return-only-accessibility-elements",level:3},{value:"Examples",id:"examples",level:4},{value:"3. *ByText
, *ByDisplayValue
, *ByPlaceholderText
queries now return host elements",id:"3-bytext-bydisplayvalue-byplaceholdertext-queries-now-return-host-elements",level:3},{value:"4. container
API has been renamed to UNSAFE_root
.",id:"4-container-api-has-been-renamed-to-unsafe_root",level:3},{value:"Full Changelog",id:"full-changelog",level:2}],d={toc:u},m="wrapper";function p(e){let{components:t,...n}=e;return(0,a.kt)(m,(0,i.Z)({},d,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("admonition",{type:"note"},(0,a.kt)("p",{parentName:"admonition"},"If you use ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/testing-library/jest-native"},"Jest Native matchers"),", which we recommend, then you should upgrade it to version 5.4.2 or higher.")),(0,a.kt)("p",null,"React Native Testing Library 12 introduces a handful of breaking changes compared to 11.x versions. We believe they were necessary to improve the experience using the library and help the users ",(0,a.kt)("a",{parentName:"p",href:"https://blog.codinghorror.com/falling-into-the-pit-of-success/"},"fall into the pit of success")," when writing meaningful tests. You will find migration instructions for each and every change described below."),(0,a.kt)(r.Z,{toc:u,mdxType:"TOCInline"}),(0,a.kt)("h2",{id:"breaking-changes"},"Breaking changes"),(0,a.kt)("h3",{id:"1-all-queries-exclude-elements-hidden-from-accessibility-by-default"},"1. All queries exclude elements hidden from accessibility by default"),(0,a.kt)("p",null,"Elements that are hidden from accessiblity, e.g. elements on non-active screen when using React Navigation, now will not be matched by default by all queries. This is the effect of switching the default value for global config option ",(0,a.kt)("inlineCode",{parentName:"p"},"defaultIncludeHiddenElements"),"(api#defaultincludehiddenelements-option) to ",(0,a.kt)("inlineCode",{parentName:"p"},"false"),"."),(0,a.kt)("p",null,"Previous behaviour of matching hidden elements can be enabled on query level using ",(0,a.kt)("a",{parentName:"p",href:"api-queries#includehiddenelements-option"},"includeHiddenElements")," query options or globally using ",(0,a.kt)("inlineCode",{parentName:"p"},"defaultIncludeHiddenElements"),"(api#defaultincludehiddenelements-option) configuration option."),(0,a.kt)("h3",{id:"2-byrole-queries-now-return-only-accessibility-elements"},"2. ",(0,a.kt)("inlineCode",{parentName:"h3"},"*ByRole")," queries now return only accessibility elements"),(0,a.kt)("p",null,(0,a.kt)("inlineCode",{parentName:"p"},"*ByRole")," queries now return only accessibility elements, either explicitly marked with ",(0,a.kt)("inlineCode",{parentName:"p"},"accessible")," prop or implicit ones where this status is derived from component type itself (e.g ",(0,a.kt)("inlineCode",{parentName:"p"},"Text"),", ",(0,a.kt)("inlineCode",{parentName:"p"},"TextInput"),", ",(0,a.kt)("inlineCode",{parentName:"p"},"Switch"),", but not ",(0,a.kt)("inlineCode",{parentName:"p"},"View"),")."),(0,a.kt)("p",null,"You may need to adjust relevant components under test to make sure they pass ",(0,a.kt)("inlineCode",{parentName:"p"},"isAccessibilityElement")," check."),(0,a.kt)("h4",{id:"examples"},"Examples"),(0,a.kt)("p",null,"Let's assume we are using ",(0,a.kt)("inlineCode",{parentName:"p"},'getByRole("button")')," query."),(0,a.kt)("p",null,"Following elements will match:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},'// Explicit "accessible" prop for View\n0&&(i=l.getRangeAt(0)),a.append(r),r.select(),r.selectionStart=0,r.selectionEnd=e.length;var c=!1;try{c=document.execCommand("copy")}catch(s){}r.remove(),i&&(l.removeAllRanges(),l.addRange(i)),o&&o.focus()}(t),l(!0),i.current=window.setTimeout((function(){l(!1)}),1e3)}),[t]);return(0,a.useEffect)((function(){return function(){return window.clearTimeout(i.current)}}),[]),a.createElement("button",{type:"button","aria-label":o?(0,p.I)({id:"theme.CodeBlock.copied",message:"Copied",description:"The copied button label on code blocks"}):(0,p.I)({id:"theme.CodeBlock.copyButtonAriaLabel",message:"Copy code to clipboard",description:"The ARIA label for copy code blocks button"}),title:(0,p.I)({id:"theme.CodeBlock.copy",message:"Copy",description:"The copy button label on code blocks"}),className:(0,u.Z)("clean-btn",n,We.copyButton,o&&We.copyButtonCopied),onClick:c},a.createElement("span",{className:We.copyButtonIcons,"aria-hidden":"true"},a.createElement("svg",{className:We.copyButtonIcon,viewBox:"0 0 24 24"},a.createElement("path",{d:"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"})),a.createElement("svg",{className:We.copyButtonSuccessIcon,viewBox:"0 0 24 24"},a.createElement("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"}))))}var qe={wordWrapButtonIcon:"wordWrapButtonIcon_Bwma",wordWrapButtonEnabled:"wordWrapButtonEnabled_EoeP"};function Ge(e){var t=e.className,n=e.onClick,r=e.isEnabled,o=(0,p.I)({id:"theme.CodeBlock.wordWrapToggle",message:"Toggle word wrap",description:"The title attribute for toggle word wrapping button of code block lines"});return a.createElement("button",{type:"button",onClick:n,className:(0,u.Z)("clean-btn",t,r&&qe.wordWrapButtonEnabled),"aria-label":o,title:o},a.createElement("svg",{className:qe.wordWrapButtonIcon,viewBox:"0 0 24 24","aria-hidden":"true"},a.createElement("path",{fill:"currentColor",d:"M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"})))}function Ye(e){var t,n,r,o,l,i,c,s,d,p,v,f=e.children,h=e.className,g=void 0===h?"":h,b=e.metastring,E=e.title,y=e.showLineNumbers,k=e.language,N=(0,le.L)().prism,C=N.defaultLanguage,L=N.magicComments,_=null!=(t=null!=k?k:null==(n=g.split(" ").find((function(e){return e.startsWith("language-")})))?void 0:n.replace(/language-/,""))?t:C,Z=fe(),T=(r=(0,a.useState)(!1),o=r[0],l=r[1],i=(0,a.useState)(!1),c=i[0],s=i[1],d=(0,a.useRef)(null),p=(0,a.useCallback)((function(){var e=d.current.querySelector("code");o?e.removeAttribute("style"):(e.style.whiteSpace="pre-wrap",e.style.overflowWrap="anywhere"),l((function(e){return!e}))}),[d,o]),v=(0,a.useCallback)((function(){var e=d.current,t=e.scrollWidth>e.clientWidth||d.current.querySelector("code").hasAttribute("style");s(t)}),[d]),Be(d,v),(0,a.useEffect)((function(){v()}),[o,v]),(0,a.useEffect)((function(){return window.addEventListener("resize",v,{passive:!0}),function(){window.removeEventListener("resize",v)}}),[v]),{codeBlockRef:d,isEnabled:o,isCodeScrollable:c,toggle:p}),w=function(e){var t,n;return null!=(t=null==e||null==(n=e.match(Ee))?void 0:n.groups.title)?t:""}(b)||E,x=Ce(f,{metastring:b,language:_,magicComments:L}),B=x.lineClassNames,O=x.code,H=null!=y?y:function(e){return Boolean(null==e?void 0:e.includes("showLineNumbers"))}(b);return a.createElement(Ze,{as:"div",className:(0,u.Z)(g,_&&!g.includes("language-"+_)&&"language-"+_)},w&&a.createElement("div",{className:Te.codeBlockTitle},w),a.createElement("div",{className:Te.codeBlockContent},a.createElement(Ve,(0,m.Z)({},He,{theme:Z,code:O,language:null!=_?_:"text"}),(function(e){var t=e.className,n=e.tokens,r=e.getLineProps,o=e.getTokenProps;return a.createElement("pre",{tabIndex:0,ref:T.codeBlockRef,className:(0,u.Z)(t,Te.codeBlock,"thin-scrollbar")},a.createElement("code",{className:(0,u.Z)(Te.codeBlockLines,H&&Te.codeBlockLinesWithNumbering)},n.map((function(e,t){return a.createElement(Re,{key:t,line:e,getLineProps:r,getTokenProps:o,classNames:B[t],showLineNumbers:H})}))))})),a.createElement("div",{className:Te.buttonGroup},(T.isEnabled||T.isCodeScrollable)&&a.createElement(Ge,{className:Te.codeButton,onClick:function(){return T.toggle()},isEnabled:T.isEnabled}),a.createElement(Fe,{className:Te.codeButton,code:O}))))}var $e=["children"];function Je(e){var t=e.children,n=(0,H.Z)(e,$e),r=(0,pe.Z)(),o=function(e){return a.Children.toArray(e).some((function(e){return(0,a.isValidElement)(e)}))?e:Array.isArray(e)?e.join(""):e}(t),l="string"==typeof o?Ye:we;return a.createElement(l,(0,m.Z)({key:String(r)},n),o)}var Qe={details:"details_lb9f",isBrowser:"isBrowser_bmU9",collapsibleContent:"collapsibleContent_i85q"},Xe=["summary","children"];function Ke(e){return!!e&&("SUMMARY"===e.tagName||Ke(e.parentElement))}function et(e,t){return!!e&&(e===t||et(e.parentElement,t))}function tt(e){var t=e.summary,n=e.children,r=(0,H.Z)(e,Xe),o=(0,pe.Z)(),l=(0,a.useRef)(null),i=(0,F.u)({initialState:!r.open}),c=i.collapsed,s=i.setCollapsed,d=(0,a.useState)(r.open),p=d[0],v=d[1];return a.createElement("details",(0,m.Z)({},r,{ref:l,open:p,"data-collapsed":c,className:(0,u.Z)(Qe.details,o&&Qe.isBrowser,r.className),onMouseDown:function(e){Ke(e.target)&&e.detail>1&&e.preventDefault()},onClick:function(e){e.stopPropagation();var t=e.target;Ke(t)&&et(t,l.current)&&(e.preventDefault(),c?(s(!1),v(!0)):s(!0))}}),null!=t?t:a.createElement("summary",null,"Details"),a.createElement(F.z,{lazy:!1,collapsed:c,disableSSRStyle:!0,onCollapseTransitionEnd:function(e){s(e),v(!e)}},a.createElement("div",{className:Qe.collapsibleContent},n)))}var nt={details:"details_b_Ee"},at="alert alert--info";function rt(e){var t=Object.assign({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(e),e));return a.createElement(tt,(0,m.Z)({},t,{className:(0,u.Z)(at,nt.details,t.className)}))}function ot(e){return a.createElement(se,e)}var lt={containsTaskList:"containsTaskList_mC6p"};var it={img:"img_ev3q"};var ct={admonition:"admonition_LlT9",admonitionHeading:"admonitionHeading_tbUL",admonitionIcon:"admonitionIcon_kALy",admonitionContent:"admonitionContent_S0QG"};var st={note:{infimaClassName:"secondary",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 14 16"},a.createElement("path",{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"}))},label:a.createElement(p.Z,{id:"theme.admonition.note",description:"The default label used for the Note admonition (:::note)"},"note")},tip:{infimaClassName:"success",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 12 16"},a.createElement("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"}))},label:a.createElement(p.Z,{id:"theme.admonition.tip",description:"The default label used for the Tip admonition (:::tip)"},"tip")},danger:{infimaClassName:"danger",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 12 16"},a.createElement("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"}))},label:a.createElement(p.Z,{id:"theme.admonition.danger",description:"The default label used for the Danger admonition (:::danger)"},"danger")},info:{infimaClassName:"info",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 14 16"},a.createElement("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}))},label:a.createElement(p.Z,{id:"theme.admonition.info",description:"The default label used for the Info admonition (:::info)"},"info")},caution:{infimaClassName:"warning",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 16 16"},a.createElement("path",{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"}))},label:a.createElement(p.Z,{id:"theme.admonition.caution",description:"The default label used for the Caution admonition (:::caution)"},"caution")}},ut={secondary:"note",important:"info",success:"tip",warning:"danger"};function dt(e){var t,n=function(e){var t=a.Children.toArray(e),n=t.find((function(e){var t;return a.isValidElement(e)&&"mdxAdmonitionTitle"===(null==(t=e.props)?void 0:t.mdxType)})),r=a.createElement(a.Fragment,null,t.filter((function(e){return e!==n})));return{mdxAdmonitionTitle:n,rest:r}}(e.children),r=n.mdxAdmonitionTitle,o=n.rest;return Object.assign({},e,{title:null!=(t=e.title)?t:r,children:o})}var mt={head:function(e){var t=a.Children.map(e.children,(function(e){return a.isValidElement(e)?function(e){var t;if(null!=(t=e.props)&&t.mdxType&&e.props.originalType){var n=e.props,r=(n.mdxType,n.originalType,(0,H.Z)(n,me));return a.createElement(e.props.originalType,r)}return e}(e):e}));return a.createElement(de.Z,e,t)},code:function(e){var t=["a","abbr","b","br","button","cite","code","del","dfn","em","i","img","input","ins","kbd","label","object","output","q","ruby","s","small","span","strong","sub","sup","time","u","var","wbr"];return a.Children.toArray(e.children).every((function(e){var n;return"string"==typeof e&&!e.includes("\n")||(0,a.isValidElement)(e)&&t.includes(null==(n=e.props)?void 0:n.mdxType)}))?a.createElement("code",e):a.createElement(Je,e)},a:function(e){return a.createElement(v.Z,e)},pre:function(e){var t;return a.createElement(Je,(0,a.isValidElement)(e.children)&&"code"===(null==(t=e.children.props)?void 0:t.originalType)?e.children.props:Object.assign({},e))},details:function(e){var t=a.Children.toArray(e.children),n=t.find((function(e){var t;return a.isValidElement(e)&&"summary"===(null==(t=e.props)?void 0:t.mdxType)})),r=a.createElement(a.Fragment,null,t.filter((function(e){return e!==n})));return a.createElement(rt,(0,m.Z)({},e,{summary:n}),r)},ul:function(e){return a.createElement("ul",(0,m.Z)({},e,{className:(t=e.className,(0,u.Z)(t,(null==t?void 0:t.includes("contains-task-list"))&<.containsTaskList))}));var t},img:function(e){return a.createElement("img",(0,m.Z)({loading:"lazy"},e,{className:(t=e.className,(0,u.Z)(t,it.img))}));var t},h1:function(e){return a.createElement(ot,(0,m.Z)({as:"h1"},e))},h2:function(e){return a.createElement(ot,(0,m.Z)({as:"h2"},e))},h3:function(e){return a.createElement(ot,(0,m.Z)({as:"h3"},e))},h4:function(e){return a.createElement(ot,(0,m.Z)({as:"h4"},e))},h5:function(e){return a.createElement(ot,(0,m.Z)({as:"h5"},e))},h6:function(e){return a.createElement(ot,(0,m.Z)({as:"h6"},e))},admonition:function(e){var t=dt(e),n=t.children,r=t.type,o=t.title,l=t.icon,i=function(e){var t,n=null!=(t=ut[e])?t:e,a=st[n];return a||(console.warn('No admonition config found for admonition type "'+n+'". Using Info as fallback.'),st.info)}(r),c=null!=o?o:i.label,s=i.iconComponent,d=null!=l?l:a.createElement(s,null);return a.createElement("div",{className:(0,u.Z)(y.k.common.admonition,y.k.common.admonitionType(e.type),"alert","alert--"+i.infimaClassName,ct.admonition)},a.createElement("div",{className:ct.admonitionHeading},a.createElement("span",{className:ct.admonitionIcon},d),c),a.createElement("div",{className:ct.admonitionContent},n))},mermaid:function(){return null}};function pt(e){var t=e.children;return a.createElement(ue.Zo,{components:mt},t)}function vt(e){var t,n,r,o,l=e.children,i=(t=c(),n=t.metadata,r=t.frontMatter,o=t.contentTitle,r.hide_title||void 0!==o?null:n.title);return a.createElement("div",{className:(0,u.Z)(y.k.docs.docMarkdown,"markdown")},i&&a.createElement("header",null,a.createElement(se,{as:"h1"},i)),a.createElement(pt,null,l))}var ft=n(8425),ht=n(8596),gt=n(4996);function bt(e){return a.createElement("svg",(0,m.Z)({viewBox:"0 0 24 24"},e),a.createElement("path",{d:"M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z",fill:"currentColor"}))}var Et={breadcrumbHomeIcon:"breadcrumbHomeIcon_YNFT"};function yt(){var e=(0,gt.Z)("/");return a.createElement("li",{className:"breadcrumbs__item"},a.createElement(v.Z,{"aria-label":(0,p.I)({id:"theme.docs.breadcrumbs.home",message:"Home page",description:"The ARIA label for the home page in the breadcrumbs"}),className:"breadcrumbs__link",href:e},a.createElement(bt,{className:Et.breadcrumbHomeIcon})))}var kt={breadcrumbsContainer:"breadcrumbsContainer_Z_bl"};function Nt(e){var t=e.children,n=e.href,r="breadcrumbs__link";return e.isLast?a.createElement("span",{className:r,itemProp:"name"},t):n?a.createElement(v.Z,{className:r,href:n,itemProp:"item"},a.createElement("span",{itemProp:"name"},t)):a.createElement("span",{className:r},t)}function Ct(e){var t=e.children,n=e.active,r=e.index,o=e.addMicrodata;return a.createElement("li",(0,m.Z)({},o&&{itemScope:!0,itemProp:"itemListElement",itemType:"https://schema.org/ListItem"},{className:(0,u.Z)("breadcrumbs__item",{"breadcrumbs__item--active":n})}),t,a.createElement("meta",{itemProp:"position",content:String(r+1)}))}function Lt(){var e=(0,ft.s1)(),t=(0,ht.Ns)();return e?a.createElement("nav",{className:(0,u.Z)(y.k.docs.docBreadcrumbs,kt.breadcrumbsContainer),"aria-label":(0,p.I)({id:"theme.docs.breadcrumbs.navAriaLabel",message:"Breadcrumbs",description:"The ARIA label for the breadcrumbs"})},a.createElement("ul",{className:"breadcrumbs",itemScope:!0,itemType:"https://schema.org/BreadcrumbList"},t&&a.createElement(yt,null),e.map((function(t,n){var r=n===e.length-1;return a.createElement(Ct,{key:n,active:r,index:n,addMicrodata:!!t.href},a.createElement(Nt,{href:t.href,isLast:r},t.label))})))):null}var _t={docItemContainer:"docItemContainer_Djhp",docItemCol:"docItemCol_VOVn"};function Zt(e){var t,n,r,o,l,i,s=e.children,m=(t=c(),n=t.frontMatter,r=t.toc,o=(0,d.i)(),l=n.hide_table_of_contents,i=!l&&r.length>0,{hidden:l,mobile:i?a.createElement(K,null):void 0,desktop:!i||"desktop"!==o&&"ssr"!==o?void 0:a.createElement(oe,null)});return a.createElement("div",{className:"row"},a.createElement("div",{className:(0,u.Z)("col",!m.hidden&&_t.docItemCol)},a.createElement(T,null),a.createElement("div",{className:_t.docItemContainer},a.createElement("article",null,a.createElement(Lt,null),a.createElement(w,null),m.mobile,a.createElement(vt,null,s),a.createElement(W,null)),a.createElement(g,null))),m.desktop&&a.createElement("div",{className:"col col--3"},m.desktop))}function Tt(e){var t="docs-doc-id-"+e.content.metadata.unversionedId,n=e.content;return a.createElement(i,{content:e.content},a.createElement(r.FG,{className:t},a.createElement(s,null),a.createElement(Zt,null,a.createElement(n,null))))}},3743:function(e,t,n){"use strict";n.d(t,{Z:function(){return g}});var a=n(7462),r=n(3366),o=n(7294),l=n(6668),i=["parentIndex"];function c(e){var t=e.map((function(e){return Object.assign({},e,{parentIndex:-1,children:[]})})),n=Array(7).fill(-1);t.forEach((function(e,t){var a=n.slice(2,e.level);e.parentIndex=Math.max.apply(Math,a),n[e.level]=t}));var a=[];return t.forEach((function(e){var n=e.parentIndex,o=(0,r.Z)(e,i);n>=0?t[n].children.push(o):a.push(o)})),a}function s(e){var t=e.toc,n=e.minHeadingLevel,a=e.maxHeadingLevel;return t.flatMap((function(e){var t=s({toc:e.children,minHeadingLevel:n,maxHeadingLevel:a});return function(e){return e.level>=n&&e.level<=a}(e)?[Object.assign({},e,{children:t})]:t}))}function u(e){var t=e.getBoundingClientRect();return t.top===t.bottom?u(e.parentNode):t}function d(e,t){var n,a,r=t.anchorTopOffset,o=e.find((function(e){return u(e).top>=r}));return o?function(e){return e.top>0&&e.bottom a.createElement("span",(0,u.Z)({key:t},r({token:e,key:t})))));return a.createElement("span",c,o?a.createElement(a.Fragment,null,a.createElement("span",{className:Ae.codeLineNumber}),a.createElement("span",{className:Ae.codeLineContent},i)):i,a.createElement("br",null))}function Se(e){return a.createElement("svg",(0,u.Z)({viewBox:"0 0 24 24"},e),a.createElement("path",{fill:"currentColor",d:"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"}))}function Ie(e){return a.createElement("svg",(0,u.Z)({viewBox:"0 0 24 24"},e),a.createElement("path",{fill:"currentColor",d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"}))}const Me={copyButtonCopied:"copyButtonCopied_obH4",copyButtonIcons:"copyButtonIcons_eSgA",copyButtonIcon:"copyButtonIcon_y97N",copyButtonSuccessIcon:"copyButtonSuccessIcon_LjdS"};function Pe(e){let{code:t,className:n}=e;const[o,l]=(0,a.useState)(!1),r=(0,a.useRef)(void 0),c=(0,a.useCallback)((()=>{!function(e,t){let{target:n=document.body}=void 0===t?{}:t;if("string"!=typeof e)throw new TypeError("Expected parameter `text` to be a `string`, got `"+typeof e+"`.");const a=document.createElement("textarea"),o=document.activeElement;a.value=e,a.setAttribute("readonly",""),a.style.contain="strict",a.style.position="absolute",a.style.left="-9999px",a.style.fontSize="12pt";const l=document.getSelection(),r=l.rangeCount>0&&l.getRangeAt(0);n.append(a),a.select(),a.selectionStart=0,a.selectionEnd=e.length;let c=!1;try{c=document.execCommand("copy")}catch{}a.remove(),r&&(l.removeAllRanges(),l.addRange(r)),o&&o.focus()}(t),l(!0),r.current=window.setTimeout((()=>{l(!1)}),1e3)}),[t]);return(0,a.useEffect)((()=>()=>window.clearTimeout(r.current)),[]),a.createElement("button",{type:"button","aria-label":o?(0,p.I)({id:"theme.CodeBlock.copied",message:"Copied",description:"The copied button label on code blocks"}):(0,p.I)({id:"theme.CodeBlock.copyButtonAriaLabel",message:"Copy code to clipboard",description:"The ARIA label for copy code blocks button"}),title:(0,p.I)({id:"theme.CodeBlock.copy",message:"Copy",description:"The copy button label on code blocks"}),className:(0,d.Z)("clean-btn",n,Me.copyButton,o&&Me.copyButtonCopied),onClick:c},a.createElement("span",{className:Me.copyButtonIcons,"aria-hidden":"true"},a.createElement(Se,{className:Me.copyButtonIcon}),a.createElement(Ie,{className:Me.copyButtonSuccessIcon})))}function Ue(e){return a.createElement("svg",(0,u.Z)({viewBox:"0 0 24 24"},e),a.createElement("path",{fill:"currentColor",d:"M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"}))}const ze={wordWrapButtonIcon:"wordWrapButtonIcon_Bwma",wordWrapButtonEnabled:"wordWrapButtonEnabled_EoeP"};function Ve(e){let{className:t,onClick:n,isEnabled:o}=e;const l=(0,p.I)({id:"theme.CodeBlock.wordWrapToggle",message:"Toggle word wrap",description:"The title attribute for toggle word wrapping button of code block lines"});return a.createElement("button",{type:"button",onClick:n,className:(0,d.Z)("clean-btn",t,o&&ze.wordWrapButtonEnabled),"aria-label":l,title:l},a.createElement(Ue,{className:ze.wordWrapButtonIcon,"aria-hidden":"true"}))}function De(e){var t;let{children:n,className:o="",metastring:l,title:r,showLineNumbers:c,language:i}=e;const{prism:{defaultLanguage:s,magicComments:m}}=(0,ne.L)(),p=null!=(t=null!=i?i:function(e){const t=e.split(" ").find((e=>e.startsWith("language-")));return null==t?void 0:t.replace(/language-/,"")}(o))?t:s,f=se(),h=function(){const[e,t]=(0,a.useState)(!1),[n,o]=(0,a.useState)(!1),l=(0,a.useRef)(null),r=(0,a.useCallback)((()=>{const n=l.current.querySelector("code");e?n.removeAttribute("style"):(n.style.whiteSpace="pre-wrap",n.style.overflowWrap="anywhere"),t((e=>!e))}),[l,e]),c=(0,a.useCallback)((()=>{const{scrollWidth:e,clientWidth:t}=l.current,n=e>t||l.current.querySelector("code").hasAttribute("style");o(n)}),[l]);return Ne(l,c),(0,a.useEffect)((()=>{c()}),[e,c]),(0,a.useEffect)((()=>(window.addEventListener("resize",c,{passive:!0}),()=>{window.removeEventListener("resize",c)})),[c]),{codeBlockRef:l,isEnabled:e,isCodeScrollable:n,toggle:r}}(),g=function(e){var t,n;return null!=(t=null==e||null==(n=e.match(ue))?void 0:n.groups.title)?t:""}(l)||r,{lineClassNames:b,code:v}=ge(n,{metastring:l,language:p,magicComments:m}),E=null!=c?c:function(e){return Boolean(null==e?void 0:e.includes("showLineNumbers"))}(l);return a.createElement(ve,{as:"div",className:(0,d.Z)(o,p&&!o.includes("language-"+p)&&"language-"+p)},g&&a.createElement("div",{className:Ee.codeBlockTitle},g),a.createElement("div",{className:Ee.codeBlockContent},a.createElement(He,(0,u.Z)({},Le,{theme:f,code:v,language:null!=p?p:"text"}),(e=>{let{className:t,tokens:n,getLineProps:o,getTokenProps:l}=e;return a.createElement("pre",{tabIndex:0,ref:h.codeBlockRef,className:(0,d.Z)(t,Ee.codeBlock,"thin-scrollbar")},a.createElement("code",{className:(0,d.Z)(Ee.codeBlockLines,E&&Ee.codeBlockLinesWithNumbering)},n.map(((e,t)=>a.createElement(je,{key:t,line:e,getLineProps:o,getTokenProps:l,classNames:b[t],showLineNumbers:E})))))})),a.createElement("div",{className:Ee.buttonGroup},(h.isEnabled||h.isCodeScrollable)&&a.createElement(Ve,{className:Ee.codeButton,onClick:()=>h.toggle(),isEnabled:h.isEnabled}),a.createElement(Pe,{className:Ee.codeButton,code:v}))))}function Re(e){let{children:t,...n}=e;const o=(0,ce.Z)(),l=function(e){return a.Children.toArray(e).some((e=>(0,a.isValidElement)(e)))?e:Array.isArray(e)?e.join(""):e}(t),r="string"==typeof l?De:ye;return a.createElement(r,(0,u.Z)({key:String(o)},n),l)}const We={details:"details_lb9f",isBrowser:"isBrowser_bmU9",collapsibleContent:"collapsibleContent_i85q"};function Fe(e){return!!e&&("SUMMARY"===e.tagName||Fe(e.parentElement))}function qe(e,t){return!!e&&(e===t||qe(e.parentElement,t))}function Ge(e){let{summary:t,children:n,...o}=e;const l=(0,ce.Z)(),r=(0,a.useRef)(null),{collapsed:c,setCollapsed:i}=(0,R.u)({initialState:!o.open}),[s,m]=(0,a.useState)(o.open),p=a.isValidElement(t)?t:a.createElement("summary",null,null!=t?t:"Details");return a.createElement("details",(0,u.Z)({},o,{ref:r,open:s,"data-collapsed":c,className:(0,d.Z)(We.details,l&&We.isBrowser,o.className),onMouseDown:e=>{Fe(e.target)&&e.detail>1&&e.preventDefault()},onClick:e=>{e.stopPropagation();const t=e.target;Fe(t)&&qe(t,r.current)&&(e.preventDefault(),c?(i(!1),m(!0)):i(!0))}}),p,a.createElement(R.z,{lazy:!1,collapsed:c,disableSSRStyle:!0,onCollapseTransitionEnd:e=>{i(e),m(!e)}},a.createElement("div",{className:We.collapsibleContent},n)))}const Ye={details:"details_b_Ee"},$e="alert alert--info";function Je(e){let{...t}=e;return a.createElement(Ge,(0,u.Z)({},t,{className:(0,d.Z)($e,Ye.details,t.className)}))}function Qe(e){return a.createElement(oe,e)}const Xe={containsTaskList:"containsTaskList_mC6p"};function Ke(e){if(void 0!==e)return(0,d.Z)(e,(null==e?void 0:e.includes("contains-task-list"))&&Xe.containsTaskList)}const et={img:"img_ev3q"};const tt="admonition_LlT9",nt="admonitionHeading_tbUL",at="admonitionIcon_kALy",ot="admonitionContent_S0QG";const lt={note:{infimaClassName:"secondary",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 14 16"},a.createElement("path",{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"}))},label:a.createElement(p.Z,{id:"theme.admonition.note",description:"The default label used for the Note admonition (:::note)"},"note")},tip:{infimaClassName:"success",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 12 16"},a.createElement("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"}))},label:a.createElement(p.Z,{id:"theme.admonition.tip",description:"The default label used for the Tip admonition (:::tip)"},"tip")},danger:{infimaClassName:"danger",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 12 16"},a.createElement("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"}))},label:a.createElement(p.Z,{id:"theme.admonition.danger",description:"The default label used for the Danger admonition (:::danger)"},"danger")},info:{infimaClassName:"info",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 14 16"},a.createElement("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}))},label:a.createElement(p.Z,{id:"theme.admonition.info",description:"The default label used for the Info admonition (:::info)"},"info")},caution:{infimaClassName:"warning",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 16 16"},a.createElement("path",{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"}))},label:a.createElement(p.Z,{id:"theme.admonition.caution",description:"The default label used for the Caution admonition (:::caution)"},"caution")}},rt={secondary:"note",important:"info",success:"tip",warning:"danger"};function ct(e){var t;const{mdxAdmonitionTitle:n,rest:o}=function(e){const t=a.Children.toArray(e),n=t.find((e=>{var t;return a.isValidElement(e)&&"mdxAdmonitionTitle"===(null==(t=e.props)?void 0:t.mdxType)})),o=a.createElement(a.Fragment,null,t.filter((e=>e!==n)));return{mdxAdmonitionTitle:n,rest:o}}(e.children);return{...e,title:null!=(t=e.title)?t:n,children:o}}const it={head:function(e){const t=a.Children.map(e.children,(e=>a.isValidElement(e)?function(e){var t;if(null!=(t=e.props)&&t.mdxType&&e.props.originalType){const{mdxType:t,originalType:n,...o}=e.props;return a.createElement(e.props.originalType,o)}return e}(e):e));return a.createElement(re.Z,e,t)},code:function(e){const t=["a","abbr","b","br","button","cite","code","del","dfn","em","i","img","input","ins","kbd","label","object","output","q","ruby","s","small","span","strong","sub","sup","time","u","var","wbr"];return a.Children.toArray(e.children).every((e=>{var n;return"string"==typeof e&&!e.includes("\n")||(0,a.isValidElement)(e)&&t.includes(null==(n=e.props)?void 0:n.mdxType)}))?a.createElement("code",e):a.createElement(Re,e)},a:function(e){return a.createElement(f.Z,e)},pre:function(e){var t;return a.createElement(Re,(0,a.isValidElement)(e.children)&&"code"===(null==(t=e.children.props)?void 0:t.originalType)?e.children.props:{...e})},details:function(e){const t=a.Children.toArray(e.children),n=t.find((e=>{var t;return a.isValidElement(e)&&"summary"===(null==(t=e.props)?void 0:t.mdxType)})),o=a.createElement(a.Fragment,null,t.filter((e=>e!==n)));return a.createElement(Je,(0,u.Z)({},e,{summary:n}),o)},ul:function(e){return a.createElement("ul",(0,u.Z)({},e,{className:Ke(e.className)}))},img:function(e){return a.createElement("img",(0,u.Z)({loading:"lazy"},e,{className:(t=e.className,(0,d.Z)(t,et.img))}));var t},h1:e=>a.createElement(Qe,(0,u.Z)({as:"h1"},e)),h2:e=>a.createElement(Qe,(0,u.Z)({as:"h2"},e)),h3:e=>a.createElement(Qe,(0,u.Z)({as:"h3"},e)),h4:e=>a.createElement(Qe,(0,u.Z)({as:"h4"},e)),h5:e=>a.createElement(Qe,(0,u.Z)({as:"h5"},e)),h6:e=>a.createElement(Qe,(0,u.Z)({as:"h6"},e)),admonition:function(e){const{children:t,type:n,title:o,icon:l}=ct(e),r=function(e){var t;const n=null!=(t=rt[e])?t:e,a=lt[n];return a||(console.warn('No admonition config found for admonition type "'+n+'". Using Info as fallback.'),lt.info)}(n),c=null!=o?o:r.label,{iconComponent:i}=r,s=null!=l?l:a.createElement(i,null);return a.createElement("div",{className:(0,d.Z)(y.k.common.admonition,y.k.common.admonitionType(e.type),"alert","alert--"+r.infimaClassName,tt)},a.createElement("div",{className:nt},a.createElement("span",{className:at},s),c),a.createElement("div",{className:ot},t))},mermaid:()=>null};function st(e){let{children:t}=e;return a.createElement(le.Zo,{components:it},t)}function dt(e){let{children:t}=e;const n=function(){const{metadata:e,frontMatter:t,contentTitle:n}=i();return t.hide_title||void 0!==n?null:e.title}();return a.createElement("div",{className:(0,d.Z)(y.k.docs.docMarkdown,"markdown")},n&&a.createElement("header",null,a.createElement(oe,{as:"h1"},n)),a.createElement(st,null,t))}var mt=n(2802),ut=n(8596),pt=n(4996);function ft(e){return a.createElement("svg",(0,u.Z)({viewBox:"0 0 24 24"},e),a.createElement("path",{d:"M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z",fill:"currentColor"}))}const ht={breadcrumbHomeIcon:"breadcrumbHomeIcon_YNFT"};function gt(){const e=(0,pt.Z)("/");return a.createElement("li",{className:"breadcrumbs__item"},a.createElement(f.Z,{"aria-label":(0,p.I)({id:"theme.docs.breadcrumbs.home",message:"Home page",description:"The ARIA label for the home page in the breadcrumbs"}),className:"breadcrumbs__link",href:e},a.createElement(ft,{className:ht.breadcrumbHomeIcon})))}const bt={breadcrumbsContainer:"breadcrumbsContainer_Z_bl"};function vt(e){let{children:t,href:n,isLast:o}=e;const l="breadcrumbs__link";return o?a.createElement("span",{className:l,itemProp:"name"},t):n?a.createElement(f.Z,{className:l,href:n,itemProp:"item"},a.createElement("span",{itemProp:"name"},t)):a.createElement("span",{className:l},t)}function Et(e){let{children:t,active:n,index:o,addMicrodata:l}=e;return a.createElement("li",(0,u.Z)({},l&&{itemScope:!0,itemProp:"itemListElement",itemType:"https://schema.org/ListItem"},{className:(0,d.Z)("breadcrumbs__item",{"breadcrumbs__item--active":n})}),t,a.createElement("meta",{itemProp:"position",content:String(o+1)}))}function yt(){const e=(0,mt.s1)(),t=(0,ut.Ns)();return e?a.createElement("nav",{className:(0,d.Z)(y.k.docs.docBreadcrumbs,bt.breadcrumbsContainer),"aria-label":(0,p.I)({id:"theme.docs.breadcrumbs.navAriaLabel",message:"Breadcrumbs",description:"The ARIA label for the breadcrumbs"})},a.createElement("ul",{className:"breadcrumbs",itemScope:!0,itemType:"https://schema.org/BreadcrumbList"},t&&a.createElement(gt,null),e.map(((t,n)=>{const o=n===e.length-1;return a.createElement(Et,{key:n,active:o,index:n,addMicrodata:!!t.href},a.createElement(vt,{href:t.href,isLast:o},t.label))})))):null}const kt={docItemContainer:"docItemContainer_Djhp",docItemCol:"docItemCol_VOVn"};function Nt(e){let{children:t}=e;const n=function(){const{frontMatter:e,toc:t}=i(),n=(0,m.i)(),o=e.hide_table_of_contents,l=!o&&t.length>0;return{hidden:o,mobile:l?a.createElement(J,null):void 0,desktop:!l||"desktop"!==n&&"ssr"!==n?void 0:a.createElement(te,null)}}();return a.createElement("div",{className:"row"},a.createElement("div",{className:(0,d.Z)("col",!n.hidden&&kt.docItemCol)},a.createElement(w,null),a.createElement("div",{className:kt.docItemContainer},a.createElement("article",null,a.createElement(yt,null),a.createElement(Z,null),n.mobile,a.createElement(dt,null,t),a.createElement(D,null)),a.createElement(b,null))),n.desktop&&a.createElement("div",{className:"col col--3"},n.desktop))}function Ct(e){const t="docs-doc-id-"+e.content.metadata.unversionedId,n=e.content;return a.createElement(c,{content:e.content},a.createElement(o.FG,{className:t},a.createElement(s,null),a.createElement(Nt,null,a.createElement(n,null))))}},3743:(e,t,n)=>{"use strict";n.d(t,{Z:()=>f});var a=n(7462),o=n(7294),l=n(6668);function r(e){const t=e.map((e=>({...e,parentIndex:-1,children:[]}))),n=Array(7).fill(-1);t.forEach(((e,t)=>{const a=n.slice(2,e.level);e.parentIndex=Math.max(...a),n[e.level]=t}));const a=[];return t.forEach((e=>{const{parentIndex:n,...o}=e;n>=0?t[n].children.push(o):a.push(o)})),a}function c(e){let{toc:t,minHeadingLevel:n,maxHeadingLevel:a}=e;return t.flatMap((e=>{const t=c({toc:e.children,minHeadingLevel:n,maxHeadingLevel:a});return function(e){return e.level>=n&&e.level<=a}(e)?[{...e,children:t}]:t}))}function i(e){const t=e.getBoundingClientRect();return t.top===t.bottom?i(e.parentNode):t}function s(e,t){var n;let{anchorTopOffset:a}=t;const o=e.find((e=>i(e).top>=a));if(o){var l;return function(e){return e.top>0&&e.bottom["'])(?
0&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(e,t){if(!r(t))throw TypeError("listener must be a function");var n=!1;function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},t.prototype.removeListener=function(e,t){var i,a,s,c;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(i=this._events[e]).length,a=-1,i===t||r(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(n(i)){for(c=s;c-- >0;)if(i[c]===t||i[c].listener&&i[c].listener===t){a=c;break}if(a<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(a,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},t.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},t.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},t.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},t.listenerCount=function(e,t){return e.listenerCount(t)}},8131:(e,t,r)=>{"use strict";var n=r(9374),i=r(7775),a=r(3076);function s(e,t,r){return new n(e,t,r)}s.version=r(4336),s.AlgoliaSearchHelper=n,s.SearchParameters=i,s.SearchResults=a,e.exports=s},8078:(e,t,r)=>{"use strict";var n=r(7331);function i(e,t){this.main=e,this.fn=t,this.lastResults=null}r(4853)(i,n),i.prototype.detach=function(){this.removeAllListeners(),this.main.detachDerivedHelper(this)},i.prototype.getModifiedState=function(e){return this.fn(e)},e.exports=i},2437:(e,t,r)=>{"use strict";var n=r(2344),i=r(116),a=r(9803),s={addRefinement:function(e,t,r){if(s.isRefined(e,t,r))return e;var i=""+r,a=e[t]?e[t].concat(i):[i],c={};return c[t]=a,n({},c,e)},removeRefinement:function(e,t,r){if(void 0===r)return s.clearRefinement(e,(function(e,r){return t===r}));var n=""+r;return s.clearRefinement(e,(function(e,r){return t===r&&n===e}))},toggleRefinement:function(e,t,r){if(void 0===r)throw new Error("toggleRefinement should be used with a value");return s.isRefined(e,t,r)?s.removeRefinement(e,t,r):s.addRefinement(e,t,r)},clearRefinement:function(e,t,r){if(void 0===t)return i(e)?{}:e;if("string"==typeof t)return a(e,[t]);if("function"==typeof t){var n=!1,s=Object.keys(e).reduce((function(i,a){var s=e[a]||[],c=s.filter((function(e){return!t(e,a,r)}));return c.length!==s.length&&(n=!0),i[a]=c,i}),{});return n?s:e}},isRefined:function(e,t,r){var n=Boolean(e[t])&&e[t].length>0;if(void 0===r||!n)return n;var i=""+r;return-1!==e[t].indexOf(i)}};e.exports=s},7775:(e,t,r)=>{"use strict";var n=r(2344),i=r(7888),a=r(2686),s=r(185),c=r(116),u=r(9803),o=r(8023),h=r(6801),f=r(2437);function l(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((function(e,r){return l(t[r],e)})):e===t}function m(e){var t=e?m._parseNumbers(e):{};void 0===t.userToken||h(t.userToken)||console.warn("[algoliasearch-helper] The `userToken` parameter is invalid. This can lead to wrong analytics.\n - Format: [a-zA-Z0-9_-]{1,64}"),this.facets=t.facets||[],this.disjunctiveFacets=t.disjunctiveFacets||[],this.hierarchicalFacets=t.hierarchicalFacets||[],this.facetsRefinements=t.facetsRefinements||{},this.facetsExcludes=t.facetsExcludes||{},this.disjunctiveFacetsRefinements=t.disjunctiveFacetsRefinements||{},this.numericRefinements=t.numericRefinements||{},this.tagRefinements=t.tagRefinements||[],this.hierarchicalFacetsRefinements=t.hierarchicalFacetsRefinements||{};var r=this;Object.keys(t).forEach((function(e){var n=-1!==m.PARAMETERS.indexOf(e),i=void 0!==t[e];!n&&i&&(r[e]=t[e])}))}m.PARAMETERS=Object.keys(new m),m._parseNumbers=function(e){if(e instanceof m)return e;var t={};if(["aroundPrecision","aroundRadius","getRankingInfo","minWordSizefor2Typos","minWordSizefor1Typo","page","maxValuesPerFacet","distinct","minimumAroundRadius","hitsPerPage","minProximity"].forEach((function(r){var n=e[r];if("string"==typeof n){var i=parseFloat(n);t[r]=isNaN(i)?n:i}})),Array.isArray(e.insideBoundingBox)&&(t.insideBoundingBox=e.insideBoundingBox.map((function(e){return Array.isArray(e)?e.map((function(e){return parseFloat(e)})):e}))),e.numericRefinements){var r={};Object.keys(e.numericRefinements).forEach((function(t){var n=e.numericRefinements[t]||{};r[t]={},Object.keys(n).forEach((function(e){var i=n[e].map((function(e){return Array.isArray(e)?e.map((function(e){return"string"==typeof e?parseFloat(e):e})):"string"==typeof e?parseFloat(e):e}));r[t][e]=i}))})),t.numericRefinements=r}return s({},e,t)},m.make=function(e){var t=new m(e);return(e.hierarchicalFacets||[]).forEach((function(e){if(e.rootPath){var r=t.getHierarchicalRefinement(e.name);r.length>0&&0!==r[0].indexOf(e.rootPath)&&(t=t.clearRefinements(e.name)),0===(r=t.getHierarchicalRefinement(e.name)).length&&(t=t.toggleHierarchicalFacetRefinement(e.name,e.rootPath))}})),t},m.validate=function(e,t){var r=t||{};return e.tagFilters&&r.tagRefinements&&r.tagRefinements.length>0?new Error("[Tags] Cannot switch from the managed tag API to the advanced API. It is probably an error, if it is really what you want, you should first clear the tags with clearTags method."):e.tagRefinements.length>0&&r.tagFilters?new Error("[Tags] Cannot switch from the advanced tag API to the managed API. It is probably an error, if it is not, you should first clear the tags with clearTags method."):e.numericFilters&&r.numericRefinements&&c(r.numericRefinements)?new Error("[Numeric filters] Can't switch from the advanced to the managed API. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):c(e.numericRefinements)&&r.numericFilters?new Error("[Numeric filters] Can't switch from the managed API to the advanced. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):null},m.prototype={constructor:m,clearRefinements:function(e){var t={numericRefinements:this._clearNumericRefinements(e),facetsRefinements:f.clearRefinement(this.facetsRefinements,e,"conjunctiveFacet"),facetsExcludes:f.clearRefinement(this.facetsExcludes,e,"exclude"),disjunctiveFacetsRefinements:f.clearRefinement(this.disjunctiveFacetsRefinements,e,"disjunctiveFacet"),hierarchicalFacetsRefinements:f.clearRefinement(this.hierarchicalFacetsRefinements,e,"hierarchicalFacet")};return t.numericRefinements===this.numericRefinements&&t.facetsRefinements===this.facetsRefinements&&t.facetsExcludes===this.facetsExcludes&&t.disjunctiveFacetsRefinements===this.disjunctiveFacetsRefinements&&t.hierarchicalFacetsRefinements===this.hierarchicalFacetsRefinements?this:this.setQueryParameters(t)},clearTags:function(){return void 0===this.tagFilters&&0===this.tagRefinements.length?this:this.setQueryParameters({tagFilters:void 0,tagRefinements:[]})},setIndex:function(e){return e===this.index?this:this.setQueryParameters({index:e})},setQuery:function(e){return e===this.query?this:this.setQueryParameters({query:e})},setPage:function(e){return e===this.page?this:this.setQueryParameters({page:e})},setFacets:function(e){return this.setQueryParameters({facets:e})},setDisjunctiveFacets:function(e){return this.setQueryParameters({disjunctiveFacets:e})},setHitsPerPage:function(e){return this.hitsPerPage===e?this:this.setQueryParameters({hitsPerPage:e})},setTypoTolerance:function(e){return this.typoTolerance===e?this:this.setQueryParameters({typoTolerance:e})},addNumericRefinement:function(e,t,r){var n=o(r);if(this.isNumericRefined(e,t,n))return this;var i=s({},this.numericRefinements);return i[e]=s({},i[e]),i[e][t]?(i[e][t]=i[e][t].slice(),i[e][t].push(n)):i[e][t]=[n],this.setQueryParameters({numericRefinements:i})},getConjunctiveRefinements:function(e){return this.isConjunctiveFacet(e)&&this.facetsRefinements[e]||[]},getDisjunctiveRefinements:function(e){return this.isDisjunctiveFacet(e)&&this.disjunctiveFacetsRefinements[e]||[]},getHierarchicalRefinement:function(e){return this.hierarchicalFacetsRefinements[e]||[]},getExcludeRefinements:function(e){return this.isConjunctiveFacet(e)&&this.facetsExcludes[e]||[]},removeNumericRefinement:function(e,t,r){var n=r;return void 0!==n?this.isNumericRefined(e,t,n)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(r,i){return i===e&&r.op===t&&l(r.val,o(n))}))}):this:void 0!==t?this.isNumericRefined(e,t)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(r,n){return n===e&&r.op===t}))}):this:this.isNumericRefined(e)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(t,r){return r===e}))}):this},getNumericRefinements:function(e){return this.numericRefinements[e]||{}},getNumericRefinement:function(e,t){return this.numericRefinements[e]&&this.numericRefinements[e][t]},_clearNumericRefinements:function(e){if(void 0===e)return c(this.numericRefinements)?{}:this.numericRefinements;if("string"==typeof e)return u(this.numericRefinements,[e]);if("function"==typeof e){var t=!1,r=this.numericRefinements,n=Object.keys(r).reduce((function(n,i){var a=r[i],s={};return a=a||{},Object.keys(a).forEach((function(r){var n=a[r]||[],c=[];n.forEach((function(t){e({val:t,op:r},i,"numeric")||c.push(t)})),c.length!==n.length&&(t=!0),s[r]=c})),n[i]=s,n}),{});return t?n:this.numericRefinements}},addFacet:function(e){return this.isConjunctiveFacet(e)?this:this.setQueryParameters({facets:this.facets.concat([e])})},addDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this:this.setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.concat([e])})},addHierarchicalFacet:function(e){if(this.isHierarchicalFacet(e.name))throw new Error("Cannot declare two hierarchical facets with the same name: `"+e.name+"`");return this.setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.concat([e])})},addFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsRefinements,e,t)?this:this.setQueryParameters({facetsRefinements:f.addRefinement(this.facetsRefinements,e,t)})},addExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsExcludes,e,t)?this:this.setQueryParameters({facetsExcludes:f.addRefinement(this.facetsExcludes,e,t)})},addDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return f.isRefined(this.disjunctiveFacetsRefinements,e,t)?this:this.setQueryParameters({disjunctiveFacetsRefinements:f.addRefinement(this.disjunctiveFacetsRefinements,e,t)})},addTagRefinement:function(e){if(this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.concat(e)};return this.setQueryParameters(t)},removeFacet:function(e){return this.isConjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({facets:this.facets.filter((function(t){return t!==e}))}):this},removeDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.filter((function(t){return t!==e}))}):this},removeHierarchicalFacet:function(e){return this.isHierarchicalFacet(e)?this.clearRefinements(e).setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.filter((function(t){return t.name!==e}))}):this},removeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsRefinements,e,t)?this.setQueryParameters({facetsRefinements:f.removeRefinement(this.facetsRefinements,e,t)}):this},removeExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsExcludes,e,t)?this.setQueryParameters({facetsExcludes:f.removeRefinement(this.facetsExcludes,e,t)}):this},removeDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return f.isRefined(this.disjunctiveFacetsRefinements,e,t)?this.setQueryParameters({disjunctiveFacetsRefinements:f.removeRefinement(this.disjunctiveFacetsRefinements,e,t)}):this},removeTagRefinement:function(e){if(!this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.filter((function(t){return t!==e}))};return this.setQueryParameters(t)},toggleRefinement:function(e,t){return this.toggleFacetRefinement(e,t)},toggleFacetRefinement:function(e,t){if(this.isHierarchicalFacet(e))return this.toggleHierarchicalFacetRefinement(e,t);if(this.isConjunctiveFacet(e))return this.toggleConjunctiveFacetRefinement(e,t);if(this.isDisjunctiveFacet(e))return this.toggleDisjunctiveFacetRefinement(e,t);throw new Error("Cannot refine the undeclared facet "+e+"; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets")},toggleConjunctiveFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsRefinements:f.toggleRefinement(this.facetsRefinements,e,t)})},toggleExcludeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsExcludes:f.toggleRefinement(this.facetsExcludes,e,t)})},toggleDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return this.setQueryParameters({disjunctiveFacetsRefinements:f.toggleRefinement(this.disjunctiveFacetsRefinements,e,t)})},toggleHierarchicalFacetRefinement:function(e,t){if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration");var r=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e)),i={};return void 0!==this.hierarchicalFacetsRefinements[e]&&this.hierarchicalFacetsRefinements[e].length>0&&(this.hierarchicalFacetsRefinements[e][0]===t||0===this.hierarchicalFacetsRefinements[e][0].indexOf(t+r))?-1===t.indexOf(r)?i[e]=[]:i[e]=[t.slice(0,t.lastIndexOf(r))]:i[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:n({},i,this.hierarchicalFacetsRefinements)})},addHierarchicalFacetRefinement:function(e,t){if(this.isHierarchicalFacetRefined(e))throw new Error(e+" is already refined.");if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration.");var r={};return r[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:n({},r,this.hierarchicalFacetsRefinements)})},removeHierarchicalFacetRefinement:function(e){if(!this.isHierarchicalFacetRefined(e))return this;var t={};return t[e]=[],this.setQueryParameters({hierarchicalFacetsRefinements:n({},t,this.hierarchicalFacetsRefinements)})},toggleTagRefinement:function(e){return this.isTagRefined(e)?this.removeTagRefinement(e):this.addTagRefinement(e)},isDisjunctiveFacet:function(e){return this.disjunctiveFacets.indexOf(e)>-1},isHierarchicalFacet:function(e){return void 0!==this.getHierarchicalFacetByName(e)},isConjunctiveFacet:function(e){return this.facets.indexOf(e)>-1},isFacetRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&f.isRefined(this.facetsRefinements,e,t)},isExcludeRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&f.isRefined(this.facetsExcludes,e,t)},isDisjunctiveFacetRefined:function(e,t){return!!this.isDisjunctiveFacet(e)&&f.isRefined(this.disjunctiveFacetsRefinements,e,t)},isHierarchicalFacetRefined:function(e,t){if(!this.isHierarchicalFacet(e))return!1;var r=this.getHierarchicalRefinement(e);return t?-1!==r.indexOf(t):r.length>0},isNumericRefined:function(e,t,r){if(void 0===r&&void 0===t)return Boolean(this.numericRefinements[e]);var n=this.numericRefinements[e]&&void 0!==this.numericRefinements[e][t];if(void 0===r||!n)return n;var a,s,c=o(r),u=void 0!==(a=this.numericRefinements[e][t],s=c,i(a,(function(e){return l(e,s)})));return n&&u},isTagRefined:function(e){return-1!==this.tagRefinements.indexOf(e)},getRefinedDisjunctiveFacets:function(){var e=this,t=a(Object.keys(this.numericRefinements).filter((function(t){return Object.keys(e.numericRefinements[t]).length>0})),this.disjunctiveFacets);return Object.keys(this.disjunctiveFacetsRefinements).filter((function(t){return e.disjunctiveFacetsRefinements[t].length>0})).concat(t).concat(this.getRefinedHierarchicalFacets()).sort()},getRefinedHierarchicalFacets:function(){var e=this;return a(this.hierarchicalFacets.map((function(e){return e.name})),Object.keys(this.hierarchicalFacetsRefinements).filter((function(t){return e.hierarchicalFacetsRefinements[t].length>0}))).sort()},getUnrefinedDisjunctiveFacets:function(){var e=this.getRefinedDisjunctiveFacets();return this.disjunctiveFacets.filter((function(t){return-1===e.indexOf(t)}))},managedParameters:["index","facets","disjunctiveFacets","facetsRefinements","hierarchicalFacets","facetsExcludes","disjunctiveFacetsRefinements","numericRefinements","tagRefinements","hierarchicalFacetsRefinements"],getQueryParams:function(){var e=this.managedParameters,t={},r=this;return Object.keys(this).forEach((function(n){var i=r[n];-1===e.indexOf(n)&&void 0!==i&&(t[n]=i)})),t},setQueryParameter:function(e,t){if(this[e]===t)return this;var r={};return r[e]=t,this.setQueryParameters(r)},setQueryParameters:function(e){if(!e)return this;var t=m.validate(this,e);if(t)throw t;var r=this,n=m._parseNumbers(e),i=Object.keys(this).reduce((function(e,t){return e[t]=r[t],e}),{}),a=Object.keys(n).reduce((function(e,t){var r=void 0!==e[t],i=void 0!==n[t];return r&&!i?u(e,[t]):(i&&(e[t]=n[t]),e)}),i);return new this.constructor(a)},resetPage:function(){return void 0===this.page?this:this.setPage(0)},_getHierarchicalFacetSortBy:function(e){return e.sortBy||["isRefined:desc","name:asc"]},_getHierarchicalFacetSeparator:function(e){return e.separator||" > "},_getHierarchicalRootPath:function(e){return e.rootPath||null},_getHierarchicalShowParentLevel:function(e){return"boolean"!=typeof e.showParentLevel||e.showParentLevel},getHierarchicalFacetByName:function(e){return i(this.hierarchicalFacets,(function(t){return t.name===e}))},getHierarchicalFacetBreadcrumb:function(e){if(!this.isHierarchicalFacet(e))return[];var t=this.getHierarchicalRefinement(e)[0];if(!t)return[];var r=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e));return t.split(r).map((function(e){return e.trim()}))},toString:function(){return JSON.stringify(this,null,2)}},e.exports=m},210:(e,t,r)=>{"use strict";e.exports=function(e){return function(t,r){var n=e.hierarchicalFacets[r],o=e.hierarchicalFacetsRefinements[n.name]&&e.hierarchicalFacetsRefinements[n.name][0]||"",h=e._getHierarchicalFacetSeparator(n),f=e._getHierarchicalRootPath(n),l=e._getHierarchicalShowParentLevel(n),m=a(e._getHierarchicalFacetSortBy(n)),d=t.every((function(e){return e.exhaustive})),p=function(e,t,r,n,a){return function(o,h,f){var l=o;if(f>0){var m=0;for(l=o;msetup()
",id:"setup",level:2},{value:"Options",id:"setup-options",level:3},{value:"press()
",id:"press",level:2},{value:"longPress()
",id:"longpress",level:2},{value:"Options",id:"longpress-options",level:3},{value:"type()
",id:"type",level:2},{value:"Options",id:"type-options",level:3},{value:"Sequence of events",id:"sequence-of-events",level:3},{value:"clear()
",id:"clear",level:2},{value:"Sequence of events",id:"sequence-of-events-1",level:3},{value:"scrollTo()
",id:"scrollto",level:2},{value:"Options",id:"type-options",level:3},{value:"Sequence of events",id:"sequence-of-events-2",level:3}],m={toc:u},c="wrapper";function d(e){let{components:t,...n}=e;return(0,i.kt)(c,(0,l.Z)({},m,n,{components:t,mdxType:"MDXLayout"}),(0,i.kt)(a.Z,{toc:u,mdxType:"TOCInline"}),(0,i.kt)("admonition",{type:"caution"},(0,i.kt)("p",{parentName:"admonition"},"User Event API is in beta stage."),(0,i.kt)("p",{parentName:"admonition"},"This means that we plan to keep the public API signatures to remain stable, but we might introduce breaking behavioural changes, e.g. changing the ordering or timing of emitted events, without a major version update. Hopefully, well written code should not rely on such specific details.")),(0,i.kt)("admonition",{type:"note"},(0,i.kt)("p",{parentName:"admonition"},"User Event interactions require RNTL v12.2.0 or later.")),(0,i.kt)("h2",{id:"comparison-with-fire-event-api"},"Comparison with Fire Event API"),(0,i.kt)("p",null,"Fire Event is our original event simulation API. It offers ability to invoke ",(0,i.kt)("strong",{parentName:"p"},"any event handler")," declared on ",(0,i.kt)("strong",{parentName:"p"},"either host or composite elements"),". If the element does not have ",(0,i.kt)("inlineCode",{parentName:"p"},"onEventName")," event handler for passed ",(0,i.kt)("inlineCode",{parentName:"p"},"eventName")," event, or the element is disabled, Fire Event will traverse up the component tree, looking for event handler on both host and composite elements along the way. By default it will ",(0,i.kt)("strong",{parentName:"p"},"not pass any event data"),", but the user might provide it in the last argument."),(0,i.kt)("p",null,"In contrast, User Event provides realistic event simulation for main user interactions like ",(0,i.kt)("inlineCode",{parentName:"p"},"press")," or ",(0,i.kt)("inlineCode",{parentName:"p"},"type"),". Each of the interactions will trigger a ",(0,i.kt)("strong",{parentName:"p"},"sequence of events")," corresponding to React Native runtime behavior. These events will be invoked ",(0,i.kt)("strong",{parentName:"p"},"only on host elements"),", and ",(0,i.kt)("strong",{parentName:"p"},"will automatically receive event data")," corresponding to each event."),(0,i.kt)("p",null,"If User Event supports given interaction you should always prefer it over Fire Event counterpart, as it will make your tests much more realistic and hence reliable. In other cases, e.g. when event is not supported by User Event, or when invoking event handlers on composite elements, you have to use Fire Event as the only available option."),(0,i.kt)("h2",{id:"setup"},(0,i.kt)("inlineCode",{parentName:"h2"},"setup()")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"userEvent.setup(options?: {\n delay: number;\n advanceTimers: (delay: number) => Promisepress()
",id:"press",level:2},{value:"longPress()
",id:"longpress",level:2},{value:"Options",id:"longpress-options",level:3},{value:"type()
",id:"type",level:2},{value:"Options",id:"type-options",level:3},{value:"Sequence of events",id:"sequence-of-events",level:3},{value:"clear()
",id:"clear",level:2},{value:"Sequence of events",id:"sequence-of-events-1",level:3},{value:"scrollTo()
",id:"scrollto",level:2},{value:"Options",id:"type-options",level:3},{value:"Sequence of events",id:"sequence-of-events-2",level:3}],d={toc:c},k="wrapper";function v(e){var t=e.components,n=(0,l.Z)(e,o);return(0,a.kt)(k,(0,i.Z)({},d,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)(r.Z,{toc:c,mdxType:"TOCInline"}),(0,a.kt)("admonition",{type:"caution"},(0,a.kt)("p",{parentName:"admonition"},"User Event API is in beta stage."),(0,a.kt)("p",{parentName:"admonition"},"This means that we plan to keep the public API signatures to remain stable, but we might introduce breaking behavioural changes, e.g. changing the ordering or timing of emitted events, without a major version update. Hopefully, well written code should not rely on such specific details.")),(0,a.kt)("admonition",{type:"note"},(0,a.kt)("p",{parentName:"admonition"},"User Event interactions require RNTL v12.2.0 or later.")),(0,a.kt)("h2",{id:"comparison-with-fire-event-api"},"Comparison with Fire Event API"),(0,a.kt)("p",null,"Fire Event is our original event simulation API. It offers ability to invoke ",(0,a.kt)("strong",{parentName:"p"},"any event handler")," declared on ",(0,a.kt)("strong",{parentName:"p"},"either host or composite elements"),". If the element does not have ",(0,a.kt)("inlineCode",{parentName:"p"},"onEventName")," event handler for passed ",(0,a.kt)("inlineCode",{parentName:"p"},"eventName")," event, or the element is disabled, Fire Event will traverse up the component tree, looking for event handler on both host and composite elements along the way. By default it will ",(0,a.kt)("strong",{parentName:"p"},"not pass any event data"),", but the user might provide it in the last argument."),(0,a.kt)("p",null,"In contrast, User Event provides realistic event simulation for main user interactions like ",(0,a.kt)("inlineCode",{parentName:"p"},"press")," or ",(0,a.kt)("inlineCode",{parentName:"p"},"type"),". Each of the interactions will trigger a ",(0,a.kt)("strong",{parentName:"p"},"sequence of events")," corresponding to React Native runtime behavior. These events will be invoked ",(0,a.kt)("strong",{parentName:"p"},"only on host elements"),", and ",(0,a.kt)("strong",{parentName:"p"},"will automatically receive event data")," corresponding to each event."),(0,a.kt)("p",null,"If User Event supports given interaction you should always prefer it over Fire Event counterpart, as it will make your tests much more realistic and hence reliable. In other cases, e.g. when event is not supported by User Event, or when invoking event handlers on composite elements, you have to use Fire Event as the only available option."),(0,a.kt)("h2",{id:"setup"},(0,a.kt)("inlineCode",{parentName:"h2"},"setup()")),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"userEvent.setup(options?: {\n delay: number;\n advanceTimers: (delay: number) => Promiseshallow
function",id:"removed-global-shallow-function",level:2},{value:"Removed functions",id:"removed-functions",level:2},{value:"Some ByTestId
queries behavior changes",id:"some-bytestid-queries-behavior-changes",level:2},{value:"Deprecated flushMicrotasksQueue
",id:"deprecated-flushmicrotasksqueue",level:2}],m={toc:p},f="wrapper";function v(e){var n=e.components,t=(0,i.Z)(e,l);return(0,r.kt)(f,(0,a.Z)({},m,t,{components:n,mdxType:"MDXLayout"}),(0,r.kt)("p",null,"This guide describes steps necessary to migrate from React Native Testing Library ",(0,r.kt)("inlineCode",{parentName:"p"},"v1.x")," to ",(0,r.kt)("inlineCode",{parentName:"p"},"v2.0"),"."),(0,r.kt)(o.Z,{toc:p,mdxType:"TOCInline"}),(0,r.kt)("h2",{id:"dropping-node-8"},"Dropping Node 8"),(0,r.kt)("p",null,"Node 8 reached its EOL more than 5 months ago, so it's about time to target the library to Node 10. If you used lower version, you'll have to upgrade to v10, but we recommend using the latest LTS version."),(0,r.kt)("h2",{id:"auto-cleanup"},"Auto Cleanup"),(0,r.kt)("p",null,(0,r.kt)("inlineCode",{parentName:"p"},"cleanup()")," function is now called automatically after every test if your testing framework supports ",(0,r.kt)("inlineCode",{parentName:"p"},"afterEach")," hook (like Jest, Mocha, and Jasmine)."),(0,r.kt)("p",null,"You should be able to remove all ",(0,r.kt)("inlineCode",{parentName:"p"},"afterEach(cleanup)")," calls in your code."),(0,r.kt)("p",null,"This change might break your code, if you tests are not isolated, i.e. you call ",(0,r.kt)("inlineCode",{parentName:"p"},"render")," outside ",(0,r.kt)("inlineCode",{parentName:"p"},"test")," block. Generally, you should ",(0,r.kt)("a",{parentName:"p",href:"https://kentcdodds.com/blog/test-isolation-with-react"},"keep your tests isolated"),". But if you can't or don't want to do this right away you can prevent this behavior using any of the following ways:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"by importing ",(0,r.kt)("inlineCode",{parentName:"p"},"'react-native-testing-library/pure'")," instead of ",(0,r.kt)("inlineCode",{parentName:"p"},"'react-native-testing-library'"))),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"by importing ",(0,r.kt)("inlineCode",{parentName:"p"},"'react-native-testing-library/dont-cleanup-after-each'")," before importing ",(0,r.kt)("inlineCode",{parentName:"p"},"'react-native-testing-library'"),". You can do it in a global way by using Jest's ",(0,r.kt)("inlineCode",{parentName:"p"},"setupFiles")," like this:"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre",className:"language-json"},'{\n "setupFiles": ["react-native-testing-library/dont-cleanup-after-each"];\n}\n'))),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"by setting ",(0,r.kt)("inlineCode",{parentName:"p"},"RNTL_SKIP_AUTO_CLEANUP")," env variable to ",(0,r.kt)("inlineCode",{parentName:"p"},"true"),". You can do this with ",(0,r.kt)("inlineCode",{parentName:"p"},"cross-evn")," like this:"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"cross-env RNTL_SKIP_AUTO_CLEANUP=true jest\n")))),(0,r.kt)("h2",{id:"waitfor-api-changes"},"WaitFor API changes"),(0,r.kt)("p",null,"We renamed ",(0,r.kt)("inlineCode",{parentName:"p"},"waitForElement")," function to ",(0,r.kt)("inlineCode",{parentName:"p"},"waitFor")," for consistency with React Testing Library. Additionally, the signature has slightly changed from:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-jsx"},"export default function waitForElementdebug
function",id:"removed-global-debug-function",level:2},{value:"Removed global shallow
function",id:"removed-global-shallow-function",level:2},{value:"Removed functions",id:"removed-functions",level:2},{value:"Some ByTestId
queries behavior changes",id:"some-bytestid-queries-behavior-changes",level:2},{value:"Deprecated flushMicrotasksQueue
",id:"deprecated-flushmicrotasksqueue",level:2}],d={toc:p},c="wrapper";function m(e){let{components:t,...n}=e;return(0,i.kt)(c,(0,a.Z)({},d,n,{components:t,mdxType:"MDXLayout"}),(0,i.kt)("p",null,"This guide describes steps necessary to migrate from React Native Testing Library ",(0,i.kt)("inlineCode",{parentName:"p"},"v1.x")," to ",(0,i.kt)("inlineCode",{parentName:"p"},"v2.0"),"."),(0,i.kt)(r.Z,{toc:p,mdxType:"TOCInline"}),(0,i.kt)("h2",{id:"dropping-node-8"},"Dropping Node 8"),(0,i.kt)("p",null,"Node 8 reached its EOL more than 5 months ago, so it's about time to target the library to Node 10. If you used lower version, you'll have to upgrade to v10, but we recommend using the latest LTS version."),(0,i.kt)("h2",{id:"auto-cleanup"},"Auto Cleanup"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"cleanup()")," function is now called automatically after every test if your testing framework supports ",(0,i.kt)("inlineCode",{parentName:"p"},"afterEach")," hook (like Jest, Mocha, and Jasmine)."),(0,i.kt)("p",null,"You should be able to remove all ",(0,i.kt)("inlineCode",{parentName:"p"},"afterEach(cleanup)")," calls in your code."),(0,i.kt)("p",null,"This change might break your code, if you tests are not isolated, i.e. you call ",(0,i.kt)("inlineCode",{parentName:"p"},"render")," outside ",(0,i.kt)("inlineCode",{parentName:"p"},"test")," block. Generally, you should ",(0,i.kt)("a",{parentName:"p",href:"https://kentcdodds.com/blog/test-isolation-with-react"},"keep your tests isolated"),". But if you can't or don't want to do this right away you can prevent this behavior using any of the following ways:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("p",{parentName:"li"},"by importing ",(0,i.kt)("inlineCode",{parentName:"p"},"'react-native-testing-library/pure'")," instead of ",(0,i.kt)("inlineCode",{parentName:"p"},"'react-native-testing-library'"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("p",{parentName:"li"},"by importing ",(0,i.kt)("inlineCode",{parentName:"p"},"'react-native-testing-library/dont-cleanup-after-each'")," before importing ",(0,i.kt)("inlineCode",{parentName:"p"},"'react-native-testing-library'"),". You can do it in a global way by using Jest's ",(0,i.kt)("inlineCode",{parentName:"p"},"setupFiles")," like this:"),(0,i.kt)("pre",{parentName:"li"},(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "setupFiles": ["react-native-testing-library/dont-cleanup-after-each"];\n}\n'))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("p",{parentName:"li"},"by setting ",(0,i.kt)("inlineCode",{parentName:"p"},"RNTL_SKIP_AUTO_CLEANUP")," env variable to ",(0,i.kt)("inlineCode",{parentName:"p"},"true"),". You can do this with ",(0,i.kt)("inlineCode",{parentName:"p"},"cross-evn")," like this:"),(0,i.kt)("pre",{parentName:"li"},(0,i.kt)("code",{parentName:"pre",className:"language-sh"},"cross-env RNTL_SKIP_AUTO_CLEANUP=true jest\n")))),(0,i.kt)("h2",{id:"waitfor-api-changes"},"WaitFor API changes"),(0,i.kt)("p",null,"We renamed ",(0,i.kt)("inlineCode",{parentName:"p"},"waitForElement")," function to ",(0,i.kt)("inlineCode",{parentName:"p"},"waitFor")," for consistency with React Testing Library. Additionally, the signature has slightly changed from:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-jsx"},"export default function waitForElementreact-native-testing-library
users",id:"guide-for-react-native-testing-library-users",level:2},{value:"Renaming the library",id:"renaming-the-library",level:3},{value:"New aliases",id:"new-aliases",level:3},{value:"Renaming ByPlaceholder
queries",id:"renaming-byplaceholder-queries",level:3},{value:"fireEvent
support for disabled components",id:"fireevent-support-for-disabled-components",level:3},{value:"Guide for @testing-library/react-native
users",id:"guide-for-testing-libraryreact-native-users",level:2},{value:"Renaming "wait" helpers",id:"renaming-wait-helpers",level:3},{value:"Changes to ByTestId
queries",id:"changes-to-bytestid-queries",level:3},{value:"No ByTitle
queries",id:"no-bytitle-queries",level:3},{value:"No custom Jest configuration",id:"no-custom-jest-configuration",level:3},{value:"Cleanup is included by default",id:"cleanup-is-included-by-default",level:3},{value:"No NativeTestInstance abstraction",id:"no-nativetestinstance-abstraction",level:3},{value:"No container
nor baseElement
returned from render
",id:"no-container-nor-baseelement-returned-from-render",level:3},{value:"Firing events changes",id:"firing-events-changes",level:3}],u={toc:d},p="wrapper";function m(e){let{components:t,...n}=e;return(0,a.kt)(p,(0,i.Z)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("admonition",{type:"caution"},(0,a.kt)("p",{parentName:"admonition"},"We renamed the ",(0,a.kt)("inlineCode",{parentName:"p"},"react-native-testing-library")," npm package to ",(0,a.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native"),', officially joining the "Testing Library" family \ud83c\udf89.')),(0,a.kt)("p",null,"As the version 7.0 involves merging two libraries together, there are two variants for migration guide, dependent on library you used previously:"),(0,a.kt)(r.Z,{toc:d,mdxType:"TOCInline"}),(0,a.kt)("h2",{id:"guide-for-react-native-testing-library-users"},"Guide for ",(0,a.kt)("inlineCode",{parentName:"h2"},"react-native-testing-library")," users"),(0,a.kt)("p",null,"This guide describes steps necessary to migrate from React Native Testing Library ",(0,a.kt)("inlineCode",{parentName:"p"},"v2.x")," or ",(0,a.kt)("inlineCode",{parentName:"p"},"v6.0")," to ",(0,a.kt)("inlineCode",{parentName:"p"},"v7.0"),"."),(0,a.kt)("h3",{id:"renaming-the-library"},"Renaming the library"),(0,a.kt)("ol",null,(0,a.kt)("li",{parentName:"ol"},"Install ",(0,a.kt)("inlineCode",{parentName:"li"},"@testing-library/react-native"),"."),(0,a.kt)("li",{parentName:"ol"},"Uninstall ",(0,a.kt)("inlineCode",{parentName:"li"},"react-native-testing-library"),"."),(0,a.kt)("li",{parentName:"ol"},"Rename all references of ",(0,a.kt)("inlineCode",{parentName:"li"},"react-native-testing-library")," to ",(0,a.kt)("inlineCode",{parentName:"li"},"@testing-library/react-native"),".")),(0,a.kt)("p",null,"You may have noticed a strange v2 to v7 upgrade, skipping versions 3, 4, 5 and 6. This is because we renamed the ",(0,a.kt)("inlineCode",{parentName:"p"},"react-native-testing-library")," npm package to ",(0,a.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native"),', officially joining the "Testing Library" family \ud83c\udf89. We\'re merging existing two libraries into a single one. The ',(0,a.kt)("a",{parentName:"p",href:"https://github.com/testing-library/native-testing-library"},"native-testing-library")," repository, which had v6, will soon be archived and using ",(0,a.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native")," below v7, sourced from mentioned repository, is deprecated."),(0,a.kt)("p",null,'For branding purposes we keep the "React Native Testing Library" name, similar to "React Testing Library". Only the npm published package is changing. The code repository also stays the same under Callstack governance.'),(0,a.kt)("h3",{id:"new-aliases"},"New aliases"),(0,a.kt)("p",null,"To improve compatibility with React Testing Library, and ease the migration for ",(0,a.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native")," users using version below v7, we've introduced new aliases to our accessibility queries:"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("inlineCode",{parentName:"li"},"ByLabelText")," aliasing ",(0,a.kt)("inlineCode",{parentName:"li"},"ByA11yLabel")," queries"),(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("inlineCode",{parentName:"li"},"ByHintText")," aliasing ",(0,a.kt)("inlineCode",{parentName:"li"},"ByA11yHint")," queries"),(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("inlineCode",{parentName:"li"},"ByRole")," aliasing ",(0,a.kt)("inlineCode",{parentName:"li"},"ByA11yRole")," queries")),(0,a.kt)("p",null,"We like the new names and consider removing the aliases in future releases."),(0,a.kt)("h3",{id:"renaming-byplaceholder-queries"},"Renaming ",(0,a.kt)("inlineCode",{parentName:"h3"},"ByPlaceholder")," queries"),(0,a.kt)("p",null,"To improve compatibility with React Testing Library, and to ease the migration for ",(0,a.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native")," users using version below v7, we've renamed following queries:"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("inlineCode",{parentName:"li"},"ByPlaceholder")," -> ",(0,a.kt)("inlineCode",{parentName:"li"},"ByPlaceholderText"))),(0,a.kt)("p",null,"Please replace all occurrences of these queries in your codebase."),(0,a.kt)("h3",{id:"fireevent-support-for-disabled-components"},(0,a.kt)("inlineCode",{parentName:"h3"},"fireEvent")," support for disabled components"),(0,a.kt)("p",null,"To improve compatibility with the real React Native environment ",(0,a.kt)("inlineCode",{parentName:"p"},"fireEvent"),' now performs checks whether the component is "disabled" before firing an event on it. It uses the Responder system to establish should the event fire, which resembles the actual React Native runtime closer than we used to.'),(0,a.kt)("p",null,"If your code contained any workarounds for preventing events firing on disabled events, you should now be able to remove them."),(0,a.kt)("h2",{id:"guide-for-testing-libraryreact-native-users"},"Guide for ",(0,a.kt)("inlineCode",{parentName:"h2"},"@testing-library/react-native")," users"),(0,a.kt)("p",null,"This guide describes steps necessary to migrate from ",(0,a.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native")," from ",(0,a.kt)("inlineCode",{parentName:"p"},"v6.0")," to ",(0,a.kt)("inlineCode",{parentName:"p"},"v7.0"),". Although the name stays the same, this is a different library, sourced at ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/callstack/react-native-testing-library"},"Callstack GitHub repository"),". We made sure the upgrade path is as easy for you as possible."),(0,a.kt)("h3",{id:"renaming-wait-helpers"},'Renaming "wait" helpers'),(0,a.kt)("p",null,"The ",(0,a.kt)("inlineCode",{parentName:"p"},"wait")," and ",(0,a.kt)("inlineCode",{parentName:"p"},"waitForElement")," helpers are replaced by ",(0,a.kt)("inlineCode",{parentName:"p"},"waitFor"),". Please rename all occurrences of these in your codebase."),(0,a.kt)("h3",{id:"changes-to-bytestid-queries"},"Changes to ",(0,a.kt)("inlineCode",{parentName:"h3"},"ByTestId")," queries"),(0,a.kt)("p",null,"The ",(0,a.kt)("inlineCode",{parentName:"p"},"ByTestId")," queries don't accept RegExps. Please use strings instead. We're happy to accept PRs adding this functionality :)."),(0,a.kt)("h3",{id:"no-bytitle-queries"},"No ",(0,a.kt)("inlineCode",{parentName:"h3"},"ByTitle")," queries"),(0,a.kt)("p",null,"Our library doesn't implement ",(0,a.kt)("inlineCode",{parentName:"p"},"ByTitle")," queries, which are targetting components with ",(0,a.kt)("inlineCode",{parentName:"p"},"title")," prop, specifically ",(0,a.kt)("inlineCode",{parentName:"p"},"Button")," and ",(0,a.kt)("inlineCode",{parentName:"p"},"RefreshControl"),". If your tests only use ",(0,a.kt)("inlineCode",{parentName:"p"},"ByTitle")," to target ",(0,a.kt)("inlineCode",{parentName:"p"},"Button")," components, you can replace them with ",(0,a.kt)("inlineCode",{parentName:"p"},"ByText")," queries, since React Native renders ",(0,a.kt)("inlineCode",{parentName:"p"},"Text")," under the hood."),(0,a.kt)("p",null,"If you need to query ",(0,a.kt)("inlineCode",{parentName:"p"},"RefreshControl")," component and can't figure out other way around it, you can use e.g. ",(0,a.kt)("inlineCode",{parentName:"p"},"UNSAFE_getByProps({title})")," query."),(0,a.kt)("h3",{id:"no-custom-jest-configuration"},"No custom Jest configuration"),(0,a.kt)("p",null,"Use the official React Native preset for Jest:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-diff"},'{\n "jest": {\n- "preset": "@testing-library/react-native"\n+ "preset": "react-native"\n }\n}\n')),(0,a.kt)("p",null,"We're told this also speeds up your tests startup on cold cache. Using official preset has another benefit \u2013 the library is compatible with any version of React Native without introducing breaking changes."),(0,a.kt)("h3",{id:"cleanup-is-included-by-default"},"Cleanup is included by default"),(0,a.kt)("p",null,"Cleaning up (unmounting) components after each test is included by default in the same manner as in React Testing Library. Please remove this setup file from Jest config:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-diff"},'{\n "jest": {\n- "setupFilesAfterEnv": ["@testing-library/react-native/cleanup-after-each"]\n }\n}\n')),(0,a.kt)("p",null,"You can opt-out of this behavior by running tests with ",(0,a.kt)("inlineCode",{parentName:"p"},"RNTL_SKIP_AUTO_CLEANUP=true")," flag or importing from ",(0,a.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native/pure"),". We encourage you to keep the default though."),(0,a.kt)("h3",{id:"no-nativetestinstance-abstraction"},"No ",(0,a.kt)("a",{parentName:"h3",href:"https://www.native-testing-library.com/docs/api-test-instance"},"NativeTestInstance")," abstraction"),(0,a.kt)("p",null,"We don't provide any abstraction over ",(0,a.kt)("inlineCode",{parentName:"p"},"ReactTestInstance")," returned by queries, but allow to use it directly to access queried component's ",(0,a.kt)("inlineCode",{parentName:"p"},"props")," or ",(0,a.kt)("inlineCode",{parentName:"p"},"type")," for that example."),(0,a.kt)("h3",{id:"no-container-nor-baseelement-returned-from-render"},"No ",(0,a.kt)("inlineCode",{parentName:"h3"},"container")," nor ",(0,a.kt)("inlineCode",{parentName:"h3"},"baseElement")," returned from ",(0,a.kt)("inlineCode",{parentName:"h3"},"render")),(0,a.kt)("p",null,"There's no ",(0,a.kt)("inlineCode",{parentName:"p"},"container")," returned from the ",(0,a.kt)("inlineCode",{parentName:"p"},"render")," function. If you must, use ",(0,a.kt)("inlineCode",{parentName:"p"},"react-test-renderer")," directly, although we advise against doing so. We also don't implement ",(0,a.kt)("inlineCode",{parentName:"p"},"baseElement")," because of that, since there's no ",(0,a.kt)("inlineCode",{parentName:"p"},"document.documentElement")," nor ",(0,a.kt)("inlineCode",{parentName:"p"},"container"),"."),(0,a.kt)("h3",{id:"firing-events-changes"},"Firing events changes"),(0,a.kt)("p",null,"There are slight differences in how ",(0,a.kt)("inlineCode",{parentName:"p"},"fireEvent")," works in both libraries:"),(0,a.kt)("ol",null,(0,a.kt)("li",{parentName:"ol"},"Our library doesn't perform validation checks for events fired upon tested components."),(0,a.kt)("li",{parentName:"ol"},"Signature is different:",(0,a.kt)("pre",{parentName:"li"},(0,a.kt)("code",{parentName:"pre",className:"language-diff"},"-fireEvent[eventName](node: FiberRoot, eventProperties: NativeTestEvent)\n+fireEvent(element: ReactTestInstance, eventName: string, ...data: ArrayByPlaceholder
queries",id:"renaming-byplaceholder-queries",level:3},{value:"fireEvent
support for disabled components",id:"fireevent-support-for-disabled-components",level:3},{value:"Guide for @testing-library/react-native
users",id:"guide-for-testing-libraryreact-native-users",level:2},{value:"Renaming "wait" helpers",id:"renaming-wait-helpers",level:3},{value:"Changes to ByTestId
queries",id:"changes-to-bytestid-queries",level:3},{value:"No ByTitle
queries",id:"no-bytitle-queries",level:3},{value:"No custom Jest configuration",id:"no-custom-jest-configuration",level:3},{value:"Cleanup is included by default",id:"cleanup-is-included-by-default",level:3},{value:"No NativeTestInstance abstraction",id:"no-nativetestinstance-abstraction",level:3},{value:"No container
nor baseElement
returned from render
",id:"no-container-nor-baseelement-returned-from-render",level:3},{value:"Firing events changes",id:"firing-events-changes",level:3}],m={toc:p},v="wrapper";function f(e){var t=e.components,n=(0,a.Z)(e,l);return(0,r.kt)(v,(0,i.Z)({},m,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"We renamed the ",(0,r.kt)("inlineCode",{parentName:"p"},"react-native-testing-library")," npm package to ",(0,r.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native"),', officially joining the "Testing Library" family \ud83c\udf89.')),(0,r.kt)("p",null,"As the version 7.0 involves merging two libraries together, there are two variants for migration guide, dependent on library you used previously:"),(0,r.kt)(o.Z,{toc:p,mdxType:"TOCInline"}),(0,r.kt)("h2",{id:"guide-for-react-native-testing-library-users"},"Guide for ",(0,r.kt)("inlineCode",{parentName:"h2"},"react-native-testing-library")," users"),(0,r.kt)("p",null,"This guide describes steps necessary to migrate from React Native Testing Library ",(0,r.kt)("inlineCode",{parentName:"p"},"v2.x")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"v6.0")," to ",(0,r.kt)("inlineCode",{parentName:"p"},"v7.0"),"."),(0,r.kt)("h3",{id:"renaming-the-library"},"Renaming the library"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},"Install ",(0,r.kt)("inlineCode",{parentName:"li"},"@testing-library/react-native"),"."),(0,r.kt)("li",{parentName:"ol"},"Uninstall ",(0,r.kt)("inlineCode",{parentName:"li"},"react-native-testing-library"),"."),(0,r.kt)("li",{parentName:"ol"},"Rename all references of ",(0,r.kt)("inlineCode",{parentName:"li"},"react-native-testing-library")," to ",(0,r.kt)("inlineCode",{parentName:"li"},"@testing-library/react-native"),".")),(0,r.kt)("p",null,"You may have noticed a strange v2 to v7 upgrade, skipping versions 3, 4, 5 and 6. This is because we renamed the ",(0,r.kt)("inlineCode",{parentName:"p"},"react-native-testing-library")," npm package to ",(0,r.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native"),', officially joining the "Testing Library" family \ud83c\udf89. We\'re merging existing two libraries into a single one. The ',(0,r.kt)("a",{parentName:"p",href:"https://github.com/testing-library/native-testing-library"},"native-testing-library")," repository, which had v6, will soon be archived and using ",(0,r.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native")," below v7, sourced from mentioned repository, is deprecated."),(0,r.kt)("p",null,'For branding purposes we keep the "React Native Testing Library" name, similar to "React Testing Library". Only the npm published package is changing. The code repository also stays the same under Callstack governance.'),(0,r.kt)("h3",{id:"new-aliases"},"New aliases"),(0,r.kt)("p",null,"To improve compatibility with React Testing Library, and ease the migration for ",(0,r.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native")," users using version below v7, we've introduced new aliases to our accessibility queries:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"ByLabelText")," aliasing ",(0,r.kt)("inlineCode",{parentName:"li"},"ByA11yLabel")," queries"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"ByHintText")," aliasing ",(0,r.kt)("inlineCode",{parentName:"li"},"ByA11yHint")," queries"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"ByRole")," aliasing ",(0,r.kt)("inlineCode",{parentName:"li"},"ByA11yRole")," queries")),(0,r.kt)("p",null,"We like the new names and consider removing the aliases in future releases."),(0,r.kt)("h3",{id:"renaming-byplaceholder-queries"},"Renaming ",(0,r.kt)("inlineCode",{parentName:"h3"},"ByPlaceholder")," queries"),(0,r.kt)("p",null,"To improve compatibility with React Testing Library, and to ease the migration for ",(0,r.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native")," users using version below v7, we've renamed following queries:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"ByPlaceholder")," -> ",(0,r.kt)("inlineCode",{parentName:"li"},"ByPlaceholderText"))),(0,r.kt)("p",null,"Please replace all occurrences of these queries in your codebase."),(0,r.kt)("h3",{id:"fireevent-support-for-disabled-components"},(0,r.kt)("inlineCode",{parentName:"h3"},"fireEvent")," support for disabled components"),(0,r.kt)("p",null,"To improve compatibility with the real React Native environment ",(0,r.kt)("inlineCode",{parentName:"p"},"fireEvent"),' now performs checks whether the component is "disabled" before firing an event on it. It uses the Responder system to establish should the event fire, which resembles the actual React Native runtime closer than we used to.'),(0,r.kt)("p",null,"If your code contained any workarounds for preventing events firing on disabled events, you should now be able to remove them."),(0,r.kt)("h2",{id:"guide-for-testing-libraryreact-native-users"},"Guide for ",(0,r.kt)("inlineCode",{parentName:"h2"},"@testing-library/react-native")," users"),(0,r.kt)("p",null,"This guide describes steps necessary to migrate from ",(0,r.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native")," from ",(0,r.kt)("inlineCode",{parentName:"p"},"v6.0")," to ",(0,r.kt)("inlineCode",{parentName:"p"},"v7.0"),". Although the name stays the same, this is a different library, sourced at ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/callstack/react-native-testing-library"},"Callstack GitHub repository"),". We made sure the upgrade path is as easy for you as possible."),(0,r.kt)("h3",{id:"renaming-wait-helpers"},'Renaming "wait" helpers'),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"wait")," and ",(0,r.kt)("inlineCode",{parentName:"p"},"waitForElement")," helpers are replaced by ",(0,r.kt)("inlineCode",{parentName:"p"},"waitFor"),". Please rename all occurrences of these in your codebase."),(0,r.kt)("h3",{id:"changes-to-bytestid-queries"},"Changes to ",(0,r.kt)("inlineCode",{parentName:"h3"},"ByTestId")," queries"),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"ByTestId")," queries don't accept RegExps. Please use strings instead. We're happy to accept PRs adding this functionality :)."),(0,r.kt)("h3",{id:"no-bytitle-queries"},"No ",(0,r.kt)("inlineCode",{parentName:"h3"},"ByTitle")," queries"),(0,r.kt)("p",null,"Our library doesn't implement ",(0,r.kt)("inlineCode",{parentName:"p"},"ByTitle")," queries, which are targetting components with ",(0,r.kt)("inlineCode",{parentName:"p"},"title")," prop, specifically ",(0,r.kt)("inlineCode",{parentName:"p"},"Button")," and ",(0,r.kt)("inlineCode",{parentName:"p"},"RefreshControl"),". If your tests only use ",(0,r.kt)("inlineCode",{parentName:"p"},"ByTitle")," to target ",(0,r.kt)("inlineCode",{parentName:"p"},"Button")," components, you can replace them with ",(0,r.kt)("inlineCode",{parentName:"p"},"ByText")," queries, since React Native renders ",(0,r.kt)("inlineCode",{parentName:"p"},"Text")," under the hood."),(0,r.kt)("p",null,"If you need to query ",(0,r.kt)("inlineCode",{parentName:"p"},"RefreshControl")," component and can't figure out other way around it, you can use e.g. ",(0,r.kt)("inlineCode",{parentName:"p"},"UNSAFE_getByProps({title})")," query."),(0,r.kt)("h3",{id:"no-custom-jest-configuration"},"No custom Jest configuration"),(0,r.kt)("p",null,"Use the official React Native preset for Jest:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-diff"},'{\n "jest": {\n- "preset": "@testing-library/react-native"\n+ "preset": "react-native"\n }\n}\n')),(0,r.kt)("p",null,"We're told this also speeds up your tests startup on cold cache. Using official preset has another benefit \u2013 the library is compatible with any version of React Native without introducing breaking changes."),(0,r.kt)("h3",{id:"cleanup-is-included-by-default"},"Cleanup is included by default"),(0,r.kt)("p",null,"Cleaning up (unmounting) components after each test is included by default in the same manner as in React Testing Library. Please remove this setup file from Jest config:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-diff"},'{\n "jest": {\n- "setupFilesAfterEnv": ["@testing-library/react-native/cleanup-after-each"]\n }\n}\n')),(0,r.kt)("p",null,"You can opt-out of this behavior by running tests with ",(0,r.kt)("inlineCode",{parentName:"p"},"RNTL_SKIP_AUTO_CLEANUP=true")," flag or importing from ",(0,r.kt)("inlineCode",{parentName:"p"},"@testing-library/react-native/pure"),". We encourage you to keep the default though."),(0,r.kt)("h3",{id:"no-nativetestinstance-abstraction"},"No ",(0,r.kt)("a",{parentName:"h3",href:"https://www.native-testing-library.com/docs/api-test-instance"},"NativeTestInstance")," abstraction"),(0,r.kt)("p",null,"We don't provide any abstraction over ",(0,r.kt)("inlineCode",{parentName:"p"},"ReactTestInstance")," returned by queries, but allow to use it directly to access queried component's ",(0,r.kt)("inlineCode",{parentName:"p"},"props")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"type")," for that example."),(0,r.kt)("h3",{id:"no-container-nor-baseelement-returned-from-render"},"No ",(0,r.kt)("inlineCode",{parentName:"h3"},"container")," nor ",(0,r.kt)("inlineCode",{parentName:"h3"},"baseElement")," returned from ",(0,r.kt)("inlineCode",{parentName:"h3"},"render")),(0,r.kt)("p",null,"There's no ",(0,r.kt)("inlineCode",{parentName:"p"},"container")," returned from the ",(0,r.kt)("inlineCode",{parentName:"p"},"render")," function. If you must, use ",(0,r.kt)("inlineCode",{parentName:"p"},"react-test-renderer")," directly, although we advise against doing so. We also don't implement ",(0,r.kt)("inlineCode",{parentName:"p"},"baseElement")," because of that, since there's no ",(0,r.kt)("inlineCode",{parentName:"p"},"document.documentElement")," nor ",(0,r.kt)("inlineCode",{parentName:"p"},"container"),"."),(0,r.kt)("h3",{id:"firing-events-changes"},"Firing events changes"),(0,r.kt)("p",null,"There are slight differences in how ",(0,r.kt)("inlineCode",{parentName:"p"},"fireEvent")," works in both libraries:"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},"Our library doesn't perform validation checks for events fired upon tested components."),(0,r.kt)("li",{parentName:"ol"},"Signature is different:",(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre",className:"language-diff"},"-fireEvent[eventName](node: FiberRoot, eventProperties: NativeTestEvent)\n+fireEvent(element: ReactTestInstance, eventName: string, ...data: ArraygetAllBy*
queries",id:"getallby-queries",level:3},{value:"queryBy*
queries",id:"queryby-queries",level:3},{value:"queryAllBy*
queries",id:"queryallby-queries",level:3},{value:"findBy*
queries",id:"findby-queries",level:3},{value:"findAllBy*
queries",id:"findallby-queries",level:3},{value:"Query Predicates",id:"query-predicates",level:2},{value:"ByRole
",id:"byrole",level:3},{value:"Options",id:"byrole-options",level:4},{value:"ByText
",id:"bytext",level:3},{value:"ByPlaceholderText
",id:"byplaceholdertext",level:3},{value:"ByDisplayValue
",id:"bydisplayvalue",level:3},{value:"ByTestId
",id:"bytestid",level:3},{value:"ByLabelText
",id:"bylabeltext",level:3},{value:"ByHintText
, ByA11yHint
, ByAccessibilityHint
",id:"byhinttext-bya11yhint-byaccessibilityhint",level:3},{value:"ByA11yState
, ByAccessibilityState
(deprecated)",id:"bya11ystate-byaccessibilitystate-deprecated",level:3},{value:"ByA11yValue
, ByAccessibilityValue
(deprecated)",id:"bya11yvalue-byaccessibilityvalue-deprecated",level:3},{value:"Common options",id:"common-options",level:3},{value:"includeHiddenElements
option",id:"includehiddenelements-option",level:4},{value:"TextMatch type",id:"textmatch-type",level:2},{value:"Examples",id:"examples",level:3},{value:"Options",id:"text-match-options",level:3},{value:"Precision",id:"precision",level:4},{value:"Normalization",id:"normalization",level:4},{value:"Normalization Examples",id:"normalization-examples",level:5},{value:"Legacy unit testing helpers",id:"legacy-unit-testing-helpers",level:2},{value:"UNSAFE_ByType
",id:"unsafe_bytype",level:3},{value:"UNSAFE_ByProps
",id:"unsafe_byprops",level:3}],u={toc:m},y="wrapper";function k(e){var t=e.components,n=(0,i.Z)(e,o);return(0,l.kt)(y,(0,a.Z)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,l.kt)(r.Z,{toc:m,mdxType:"TOCInline"}),(0,l.kt)("h2",{id:"query-variants"},"Query Variants"),(0,l.kt)("blockquote",null,(0,l.kt)("p",{parentName:"blockquote"},(0,l.kt)("inlineCode",{parentName:"p"},"getBy*")," queries are shown by default in the ",(0,l.kt)("a",{parentName:"p",href:"#queries"},"query documentation"),"\nbelow.")),(0,l.kt)("h3",{id:"getby-queries"},(0,l.kt)("inlineCode",{parentName:"h3"},"getBy*")," queries"),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"getBy*")," queries return the first matching node for a query, and throw an error if no elements match or if more than one match is found. If you need to find more than one element, then use ",(0,l.kt)("inlineCode",{parentName:"p"},"getAllBy"),"."),(0,l.kt)("h3",{id:"getallby-queries"},(0,l.kt)("inlineCode",{parentName:"h3"},"getAllBy*")," queries"),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"getAllBy*")," queries return an array of all matching nodes for a query, and throw an error if no elements match."),(0,l.kt)("h3",{id:"queryby-queries"},(0,l.kt)("inlineCode",{parentName:"h3"},"queryBy*")," queries"),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"queryBy*")," queries return the first matching node for a query, and return ",(0,l.kt)("inlineCode",{parentName:"p"},"null")," if no elements match. This is useful for asserting an element that is not present. This throws if more than one match is found (use ",(0,l.kt)("inlineCode",{parentName:"p"},"queryAllBy")," instead)."),(0,l.kt)("h3",{id:"queryallby-queries"},(0,l.kt)("inlineCode",{parentName:"h3"},"queryAllBy*")," queries"),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"queryAllBy*")," queries return an array of all matching nodes for a query, and return an empty array (",(0,l.kt)("inlineCode",{parentName:"p"},"[]"),") when no elements match."),(0,l.kt)("h3",{id:"findby-queries"},(0,l.kt)("inlineCode",{parentName:"h3"},"findBy*")," queries"),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"findBy*")," queries return a promise which resolves when a matching element is found. The promise is rejected if no elements match or if more than one match is found after a default timeout of 1000 ms. If you need to find more than one element, then use ",(0,l.kt)("inlineCode",{parentName:"p"},"findAllBy*"),"."),(0,l.kt)("h3",{id:"findallby-queries"},(0,l.kt)("inlineCode",{parentName:"h3"},"findAllBy*")," queries"),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"findAllBy*")," queries return a promise which resolves to an array of matching elements. The promise is rejected if no elements match after a default timeout of 1000 ms."),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},(0,l.kt)("inlineCode",{parentName:"p"},"findBy*")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"findAllBy*")," queries accept optional ",(0,l.kt)("inlineCode",{parentName:"p"},"waitForOptions")," object argument which can contain ",(0,l.kt)("inlineCode",{parentName:"p"},"timeout"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"interval")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"onTimeout")," properies which have the same meaning as respective options for ",(0,l.kt)("a",{parentName:"p",href:"api#waitfor"},(0,l.kt)("inlineCode",{parentName:"a"},"waitFor"))," function.")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"In cases when your ",(0,l.kt)("inlineCode",{parentName:"p"},"findBy*")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"findAllBy*")," queries throw when not able to find matching elements it is useful to pass ",(0,l.kt)("inlineCode",{parentName:"p"},"onTimeout: () => { screen.debug(); }")," callback using ",(0,l.kt)("inlineCode",{parentName:"p"},"waitForOptions")," parameter.")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"In order to properly use ",(0,l.kt)("inlineCode",{parentName:"p"},"findBy*")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"findAllBy*")," queries you need at least React >=16.9.0 (featuring async ",(0,l.kt)("inlineCode",{parentName:"p"},"act"),") or React Native >=0.61 (which comes with React >=16.9.0).")),(0,l.kt)("h2",{id:"query-predicates"},"Query Predicates"),(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Note: most methods like this one return a ",(0,l.kt)("a",{parentName:"em",href:"https://reactjs.org/docs/test-renderer.html#testinstance"},(0,l.kt)("inlineCode",{parentName:"a"},"ReactTestInstance"))," with following properties that you may be interested in:")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-typescript"},"type ReactTestInstance = {\n type: string | Function;\n props: { [propName: string]: any };\n parent: ReactTestInstance | null;\n children: ArraygetBy*
queries",id:"getby-queries",level:3},{value:"getAllBy*
queries",id:"getallby-queries",level:3},{value:"queryBy*
queries",id:"queryby-queries",level:3},{value:"queryAllBy*
queries",id:"queryallby-queries",level:3},{value:"findBy*
queries",id:"findby-queries",level:3},{value:"findAllBy*
queries",id:"findallby-queries",level:3},{value:"Query Predicates",id:"query-predicates",level:2},{value:"ByRole
",id:"byrole",level:3},{value:"Options",id:"byrole-options",level:4},{value:"ByText
",id:"bytext",level:3},{value:"ByPlaceholderText
",id:"byplaceholdertext",level:3},{value:"ByDisplayValue
",id:"bydisplayvalue",level:3},{value:"ByTestId
",id:"bytestid",level:3},{value:"ByLabelText
",id:"bylabeltext",level:3},{value:"ByHintText
, ByA11yHint
, ByAccessibilityHint
",id:"byhinttext-bya11yhint-byaccessibilityhint",level:3},{value:"ByA11yState
, ByAccessibilityState
(deprecated)",id:"bya11ystate-byaccessibilitystate-deprecated",level:3},{value:"ByA11yValue
, ByAccessibilityValue
(deprecated)",id:"bya11yvalue-byaccessibilityvalue-deprecated",level:3},{value:"Common options",id:"common-options",level:3},{value:"includeHiddenElements
option",id:"includehiddenelements-option",level:4},{value:"TextMatch type",id:"textmatch-type",level:2},{value:"Examples",id:"examples",level:3},{value:"Options",id:"text-match-options",level:3},{value:"Precision",id:"precision",level:4},{value:"Normalization",id:"normalization",level:4},{value:"Normalization Examples",id:"normalization-examples",level:5},{value:"Legacy unit testing helpers",id:"legacy-unit-testing-helpers",level:2},{value:"UNSAFE_ByType
",id:"unsafe_bytype",level:3},{value:"UNSAFE_ByProps
",id:"unsafe_byprops",level:3}],d={toc:p},m="wrapper";function u(e){let{components:t,...n}=e;return(0,i.kt)(m,(0,a.Z)({},d,n,{components:t,mdxType:"MDXLayout"}),(0,i.kt)(l.Z,{toc:p,mdxType:"TOCInline"}),(0,i.kt)("h2",{id:"query-variants"},"Query Variants"),(0,i.kt)("blockquote",null,(0,i.kt)("p",{parentName:"blockquote"},(0,i.kt)("inlineCode",{parentName:"p"},"getBy*")," queries are shown by default in the ",(0,i.kt)("a",{parentName:"p",href:"#queries"},"query documentation"),"\nbelow.")),(0,i.kt)("h3",{id:"getby-queries"},(0,i.kt)("inlineCode",{parentName:"h3"},"getBy*")," queries"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"getBy*")," queries return the first matching node for a query, and throw an error if no elements match or if more than one match is found. If you need to find more than one element, then use ",(0,i.kt)("inlineCode",{parentName:"p"},"getAllBy"),"."),(0,i.kt)("h3",{id:"getallby-queries"},(0,i.kt)("inlineCode",{parentName:"h3"},"getAllBy*")," queries"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"getAllBy*")," queries return an array of all matching nodes for a query, and throw an error if no elements match."),(0,i.kt)("h3",{id:"queryby-queries"},(0,i.kt)("inlineCode",{parentName:"h3"},"queryBy*")," queries"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"queryBy*")," queries return the first matching node for a query, and return ",(0,i.kt)("inlineCode",{parentName:"p"},"null")," if no elements match. This is useful for asserting an element that is not present. This throws if more than one match is found (use ",(0,i.kt)("inlineCode",{parentName:"p"},"queryAllBy")," instead)."),(0,i.kt)("h3",{id:"queryallby-queries"},(0,i.kt)("inlineCode",{parentName:"h3"},"queryAllBy*")," queries"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"queryAllBy*")," queries return an array of all matching nodes for a query, and return an empty array (",(0,i.kt)("inlineCode",{parentName:"p"},"[]"),") when no elements match."),(0,i.kt)("h3",{id:"findby-queries"},(0,i.kt)("inlineCode",{parentName:"h3"},"findBy*")," queries"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"findBy*")," queries return a promise which resolves when a matching element is found. The promise is rejected if no elements match or if more than one match is found after a default timeout of 1000 ms. If you need to find more than one element, then use ",(0,i.kt)("inlineCode",{parentName:"p"},"findAllBy*"),"."),(0,i.kt)("h3",{id:"findallby-queries"},(0,i.kt)("inlineCode",{parentName:"h3"},"findAllBy*")," queries"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"findAllBy*")," queries return a promise which resolves to an array of matching elements. The promise is rejected if no elements match after a default timeout of 1000 ms."),(0,i.kt)("admonition",{type:"info"},(0,i.kt)("p",{parentName:"admonition"},(0,i.kt)("inlineCode",{parentName:"p"},"findBy*")," and ",(0,i.kt)("inlineCode",{parentName:"p"},"findAllBy*")," queries accept optional ",(0,i.kt)("inlineCode",{parentName:"p"},"waitForOptions")," object argument which can contain ",(0,i.kt)("inlineCode",{parentName:"p"},"timeout"),", ",(0,i.kt)("inlineCode",{parentName:"p"},"interval")," and ",(0,i.kt)("inlineCode",{parentName:"p"},"onTimeout")," properies which have the same meaning as respective options for ",(0,i.kt)("a",{parentName:"p",href:"api#waitfor"},(0,i.kt)("inlineCode",{parentName:"a"},"waitFor"))," function.")),(0,i.kt)("admonition",{type:"info"},(0,i.kt)("p",{parentName:"admonition"},"In cases when your ",(0,i.kt)("inlineCode",{parentName:"p"},"findBy*")," and ",(0,i.kt)("inlineCode",{parentName:"p"},"findAllBy*")," queries throw when not able to find matching elements it is useful to pass ",(0,i.kt)("inlineCode",{parentName:"p"},"onTimeout: () => { screen.debug(); }")," callback using ",(0,i.kt)("inlineCode",{parentName:"p"},"waitForOptions")," parameter.")),(0,i.kt)("admonition",{type:"info"},(0,i.kt)("p",{parentName:"admonition"},"In order to properly use ",(0,i.kt)("inlineCode",{parentName:"p"},"findBy*")," and ",(0,i.kt)("inlineCode",{parentName:"p"},"findAllBy*")," queries you need at least React >=16.9.0 (featuring async ",(0,i.kt)("inlineCode",{parentName:"p"},"act"),") or React Native >=0.61 (which comes with React >=16.9.0).")),(0,i.kt)("h2",{id:"query-predicates"},"Query Predicates"),(0,i.kt)("p",null,(0,i.kt)("em",{parentName:"p"},"Note: most methods like this one return a ",(0,i.kt)("a",{parentName:"em",href:"https://reactjs.org/docs/test-renderer.html#testinstance"},(0,i.kt)("inlineCode",{parentName:"a"},"ReactTestInstance"))," with following properties that you may be interested in:")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-typescript"},"type ReactTestInstance = {\n type: string | Function;\n props: { [propName: string]: any };\n parent: ReactTestInstance | null;\n children: Arraynpm
",id:"using-npm",level:4},{value:"Additional Jest matchers",id:"additional-jest-matchers",level:3},{value:"Using yarn
",id:"using-yarn-1",level:4},{value:"Using npm
",id:"using-npm-1",level:4},{value:"Flow",id:"flow",level:3},{value:"Example",id:"example",level:2}],d={toc:u},m="wrapper";function g(e){var t=e.components,n=(0,a.Z)(e,o);return(0,i.kt)(m,(0,r.Z)({},d,n,{components:t,mdxType:"MDXLayout"}),(0,i.kt)("h2",{id:"the-problem"},"The problem"),(0,i.kt)("p",null,"You want to write maintainable tests for your React Native components. As a part of this goal, you want your tests to avoid including implementation details of your components and rather focus on making your tests give you the confidence for which they are intended. As part of this, you want your testbase to be maintainable in the long run so refactors of your components (changes to implementation but not functionality) don't break your tests and slow you and your team down."),(0,i.kt)("h2",{id:"this-solution"},"This solution"),(0,i.kt)("p",null,"The React Native Testing Library (RNTL) is a lightweight solution for testing React Native components. It provides light utility functions on top of ",(0,i.kt)("inlineCode",{parentName:"p"},"react-test-renderer"),", in a way that encourages better testing practices. Its primary guiding principle is:"),(0,i.kt)("blockquote",null,(0,i.kt)("p",{parentName:"blockquote"},"The more your tests resemble the way your software is used, the more confidence they can give you.")),(0,i.kt)("p",null,"This project is inspired by ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/testing-library/react-testing-library"},"React Testing Library"),". Tested to work with Jest, but it should work with other test runners as well."),(0,i.kt)("p",null,"You can find the source of ",(0,i.kt)("inlineCode",{parentName:"p"},"QuestionsBoard")," component and this example ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/callstack/react-native-testing-library/blob/main/src/__tests__/questionsBoard.test.tsx"},"here"),"."),(0,i.kt)("h2",{id:"installation"},"Installation"),(0,i.kt)("p",null,"Open a Terminal in your project's folder and run:"),(0,i.kt)("h4",{id:"using-yarn"},"Using ",(0,i.kt)("inlineCode",{parentName:"h4"},"yarn")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-sh"},"yarn add --dev @testing-library/react-native\n")),(0,i.kt)("h4",{id:"using-npm"},"Using ",(0,i.kt)("inlineCode",{parentName:"h4"},"npm")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-sh"},"npm install --save-dev @testing-library/react-native\n")),(0,i.kt)("p",null,"This library has a ",(0,i.kt)("inlineCode",{parentName:"p"},"peerDependencies")," listing for ",(0,i.kt)("inlineCode",{parentName:"p"},"react-test-renderer"),". Make sure that your ",(0,i.kt)("inlineCode",{parentName:"p"},"react-test-renderer")," version matches exactly your ",(0,i.kt)("inlineCode",{parentName:"p"},"react")," version."),(0,i.kt)("admonition",{type:"info"},(0,i.kt)("p",{parentName:"admonition"},"In order to properly use helpers for async tests (",(0,i.kt)("inlineCode",{parentName:"p"},"findBy")," queries and ",(0,i.kt)("inlineCode",{parentName:"p"},"waitFor"),") you need at least React >=16.9.0 (featuring async ",(0,i.kt)("inlineCode",{parentName:"p"},"act"),") or React Native >=0.61 (which comes with React >=16.9.0).")),(0,i.kt)("h3",{id:"additional-jest-matchers"},"Additional Jest matchers"),(0,i.kt)("p",null,"In order to use additional React Native-specific Jest matchers from ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/testing-library/jest-native"},"@testing-library/jest-native")," package add it to your project:"),(0,i.kt)("h4",{id:"using-yarn-1"},"Using ",(0,i.kt)("inlineCode",{parentName:"h4"},"yarn")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-sh"},"yarn add --dev @testing-library/jest-native\n")),(0,i.kt)("h4",{id:"using-npm-1"},"Using ",(0,i.kt)("inlineCode",{parentName:"h4"},"npm")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-sh"},"npm install --save-dev @testing-library/jest-native\n")),(0,i.kt)("p",null,"Then automatically add it to your jest tests by using ",(0,i.kt)("inlineCode",{parentName:"p"},"setupFilesAfterEnv")," option in your Jest configuration (it's usually located either in ",(0,i.kt)("inlineCode",{parentName:"p"},"package.json")," under ",(0,i.kt)("inlineCode",{parentName:"p"},'"jest"')," key or in a ",(0,i.kt)("inlineCode",{parentName:"p"},"jest.config.js")," file):"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "preset": "react-native",\n "setupFilesAfterEnv": ["@testing-library/jest-native/extend-expect"]\n}\n')),(0,i.kt)("h3",{id:"flow"},"Flow"),(0,i.kt)("p",null,"Note for ",(0,i.kt)("a",{parentName:"p",href:"https://flow.org"},"Flow")," users \u2013 you'll also need to install typings for ",(0,i.kt)("inlineCode",{parentName:"p"},"react-test-renderer"),":"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-sh"},"flow-typed install react-test-renderer\n")),(0,i.kt)("h2",{id:"example"},"Example"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-jsx"},"import { render, screen, fireEvent } from '@testing-library/react-native';\nimport { QuestionsBoard } from '../QuestionsBoard';\n\ntest('form submits two answers', () => {\n const allQuestions = ['q1', 'q2'];\n const mockFn = jest.fn();\n\n render(yarn
",id:"using-yarn",level:4},{value:"Using npm
",id:"using-npm",level:4},{value:"Additional Jest matchers",id:"additional-jest-matchers",level:3},{value:"Using yarn
",id:"using-yarn-1",level:4},{value:"Using npm
",id:"using-npm-1",level:4},{value:"Flow",id:"flow",level:3},{value:"Example",id:"example",level:2}],c={toc:p},u="wrapper";function d(e){let{components:t,...n}=e;return(0,a.kt)(u,(0,r.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("h2",{id:"the-problem"},"The problem"),(0,a.kt)("p",null,"You want to write maintainable tests for your React Native components. As a part of this goal, you want your tests to avoid including implementation details of your components and rather focus on making your tests give you the confidence for which they are intended. As part of this, you want your testbase to be maintainable in the long run so refactors of your components (changes to implementation but not functionality) don't break your tests and slow you and your team down."),(0,a.kt)("h2",{id:"this-solution"},"This solution"),(0,a.kt)("p",null,"The React Native Testing Library (RNTL) is a lightweight solution for testing React Native components. It provides light utility functions on top of ",(0,a.kt)("inlineCode",{parentName:"p"},"react-test-renderer"),", in a way that encourages better testing practices. Its primary guiding principle is:"),(0,a.kt)("blockquote",null,(0,a.kt)("p",{parentName:"blockquote"},"The more your tests resemble the way your software is used, the more confidence they can give you.")),(0,a.kt)("p",null,"This project is inspired by ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/testing-library/react-testing-library"},"React Testing Library"),". Tested to work with Jest, but it should work with other test runners as well."),(0,a.kt)("p",null,"You can find the source of ",(0,a.kt)("inlineCode",{parentName:"p"},"QuestionsBoard")," component and this example ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/callstack/react-native-testing-library/blob/main/src/__tests__/questionsBoard.test.tsx"},"here"),"."),(0,a.kt)("h2",{id:"installation"},"Installation"),(0,a.kt)("p",null,"Open a Terminal in your project's folder and run:"),(0,a.kt)("h4",{id:"using-yarn"},"Using ",(0,a.kt)("inlineCode",{parentName:"h4"},"yarn")),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-sh"},"yarn add --dev @testing-library/react-native\n")),(0,a.kt)("h4",{id:"using-npm"},"Using ",(0,a.kt)("inlineCode",{parentName:"h4"},"npm")),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-sh"},"npm install --save-dev @testing-library/react-native\n")),(0,a.kt)("p",null,"This library has a ",(0,a.kt)("inlineCode",{parentName:"p"},"peerDependencies")," listing for ",(0,a.kt)("inlineCode",{parentName:"p"},"react-test-renderer"),". Make sure that your ",(0,a.kt)("inlineCode",{parentName:"p"},"react-test-renderer")," version matches exactly your ",(0,a.kt)("inlineCode",{parentName:"p"},"react")," version."),(0,a.kt)("admonition",{type:"info"},(0,a.kt)("p",{parentName:"admonition"},"In order to properly use helpers for async tests (",(0,a.kt)("inlineCode",{parentName:"p"},"findBy")," queries and ",(0,a.kt)("inlineCode",{parentName:"p"},"waitFor"),") you need at least React >=16.9.0 (featuring async ",(0,a.kt)("inlineCode",{parentName:"p"},"act"),") or React Native >=0.61 (which comes with React >=16.9.0).")),(0,a.kt)("h3",{id:"additional-jest-matchers"},"Additional Jest matchers"),(0,a.kt)("p",null,"In order to use additional React Native-specific Jest matchers from ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/testing-library/jest-native"},"@testing-library/jest-native")," package add it to your project:"),(0,a.kt)("h4",{id:"using-yarn-1"},"Using ",(0,a.kt)("inlineCode",{parentName:"h4"},"yarn")),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-sh"},"yarn add --dev @testing-library/jest-native\n")),(0,a.kt)("h4",{id:"using-npm-1"},"Using ",(0,a.kt)("inlineCode",{parentName:"h4"},"npm")),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-sh"},"npm install --save-dev @testing-library/jest-native\n")),(0,a.kt)("p",null,"Then automatically add it to your jest tests by using ",(0,a.kt)("inlineCode",{parentName:"p"},"setupFilesAfterEnv")," option in your Jest configuration (it's usually located either in ",(0,a.kt)("inlineCode",{parentName:"p"},"package.json")," under ",(0,a.kt)("inlineCode",{parentName:"p"},'"jest"')," key or in a ",(0,a.kt)("inlineCode",{parentName:"p"},"jest.config.js")," file):"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-json"},'{\n "preset": "react-native",\n "setupFilesAfterEnv": ["@testing-library/jest-native/extend-expect"]\n}\n')),(0,a.kt)("h3",{id:"flow"},"Flow"),(0,a.kt)("p",null,"Note for ",(0,a.kt)("a",{parentName:"p",href:"https://flow.org"},"Flow")," users \u2013 you'll also need to install typings for ",(0,a.kt)("inlineCode",{parentName:"p"},"react-test-renderer"),":"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-sh"},"flow-typed install react-test-renderer\n")),(0,a.kt)("h2",{id:"example"},"Example"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-jsx"},"import { render, screen, fireEvent } from '@testing-library/react-native';\nimport { QuestionsBoard } from '../QuestionsBoard';\n\ntest('form submits two answers', () => {\n const allQuestions = ['q1', 'q2'];\n const mockFn = jest.fn();\n\n render(toBeOnTheScreen()
",id:"tobeonthescreen",level:3},{value:"Element Content",id:"element-content",level:2},{value:"toHaveTextContent()
",id:"tohavetextcontent",level:3},{value:"toContainElement()
",id:"tocontainelement",level:3},{value:"toBeEmptyElement()
",id:"tobeemptyelement",level:3},{value:"Element State",id:"element-state",level:2},{value:"toHaveDisplayValue()
",id:"tohavedisplayvalue",level:3},{value:"toHaveAccessibilityValue()
",id:"tohaveaccessibilityvalue",level:3},{value:"toBeEnabled()
/ toBeDisabled
",id:"tobeenabled",level:3},{value:"toBeSelected()
",id:"tobeselected",level:3},{value:"toBeChecked()
/ toBePartiallyChecked()
",id:"tobechecked",level:3},{value:"toBeExpanded()
/ toBeCollapsed()
",id:"tobeexpanded",level:3},{value:"toBeBusy()
",id:"tobebusy",level:3},{value:"Element Styles",id:"element-styles",level:2},{value:"toBeVisible()
",id:"tobevisible",level:3},{value:"toHaveStyle()
",id:"tohavestyle",level:3},{value:"Other",id:"other",level:2},{value:"toHaveAccessibleName()
",id:"tohaveaccessiblename",level:3},{value:"toHaveProp()
",id:"tohaveprop",level:3}],p={toc:d},m="wrapper";function h(e){let{components:t,...n}=e;return(0,l.kt)(m,(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,l.kt)("admonition",{type:"note"},(0,l.kt)("p",{parentName:"admonition"},"Built-in Jest matchers require RNTL v12.4.0 or later.")),(0,l.kt)("p",null,"This guide describes built-in Jest matchers, we recommend using these matchers as they provide more readable tests, better accessibility support, and a better developer experience."),(0,l.kt)("p",null,"If you are already using legacy Jest Native matchers we have a ",(0,l.kt)("a",{parentName:"p",href:"migration-jest-native"},"migration guide")," for moving to the built-in matchers."),(0,l.kt)(i.Z,{toc:d,mdxType:"TOCInline"}),(0,l.kt)("h2",{id:"element-existence"},"Element Existence"),(0,l.kt)("h3",{id:"tobeonthescreen"},(0,l.kt)("inlineCode",{parentName:"h3"},"toBeOnTheScreen()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toBeOnTheScreen()\n")),(0,l.kt)("p",null,"This allows you to assert whether an element is attached to the element tree or not. If you hold a reference to an element and it gets unmounted during the test it will no longer pass this assertion."),(0,l.kt)("h2",{id:"element-content"},"Element Content"),(0,l.kt)("h3",{id:"tohavetextcontent"},(0,l.kt)("inlineCode",{parentName:"h3"},"toHaveTextContent()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toHaveTextContent(\n text: string | RegExp,\n options?: {\n exact?: boolean;\n normalizer?: (text: string) => string;\n },\n)\n")),(0,l.kt)("p",null,"This allows you to assert whether the given element has the given text content or not. It accepts either ",(0,l.kt)("inlineCode",{parentName:"p"},"string")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"RegExp")," matchers, as well as ",(0,l.kt)("a",{parentName:"p",href:"/react-native-testing-library/docs/api-queries#text-match-options"},"text match options")," of ",(0,l.kt)("inlineCode",{parentName:"p"},"exact")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"normalizer"),"."),(0,l.kt)("h3",{id:"tocontainelement"},(0,l.kt)("inlineCode",{parentName:"h3"},"toContainElement()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(container).toContainElement(\n element: ReactTestInstance | null,\n)\n")),(0,l.kt)("p",null,"This allows you to assert whether the given container element does contain another host element."),(0,l.kt)("h3",{id:"tobeemptyelement"},(0,l.kt)("inlineCode",{parentName:"h3"},"toBeEmptyElement()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toBeEmptyElement()\n")),(0,l.kt)("p",null,"This allows you to assert whether the given element does not have any host child elements or text content."),(0,l.kt)("h2",{id:"element-state"},"Element State"),(0,l.kt)("h3",{id:"tohavedisplayvalue"},(0,l.kt)("inlineCode",{parentName:"h3"},"toHaveDisplayValue()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toHaveDisplayValue(\n value: string | RegExp,\n options?: {\n exact?: boolean;\n normalizer?: (text: string) => string;\n },\n)\n")),(0,l.kt)("p",null,"This allows you to assert whether the given ",(0,l.kt)("inlineCode",{parentName:"p"},"TextInput")," element has a specified display value. It accepts either ",(0,l.kt)("inlineCode",{parentName:"p"},"string")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"RegExp")," matchers, as well as ",(0,l.kt)("a",{parentName:"p",href:"/react-native-testing-library/docs/api-queries#text-match-options"},"text match options")," of ",(0,l.kt)("inlineCode",{parentName:"p"},"exact")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"normalizer"),"."),(0,l.kt)("h3",{id:"tohaveaccessibilityvalue"},(0,l.kt)("inlineCode",{parentName:"h3"},"toHaveAccessibilityValue()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toHaveAccessibilityValue(\n value: {\n min?: number;\n max?: number;\n now?: number;\n text?: string | RegExp;\n },\n)\n")),(0,l.kt)("p",null,"This allows you to assert whether the given element has a specified accessible value."),(0,l.kt)("p",null,"This matcher will assert accessibility value based on ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-valuemin"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-valuemax"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-valuenow"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-valuetext")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"accessibilityValue")," props. Only defined value entries will be used in the assertion, the element might have additional accessibility value entries and still be matched."),(0,l.kt)("p",null,"When querying by ",(0,l.kt)("inlineCode",{parentName:"p"},"text")," entry a string or ",(0,l.kt)("inlineCode",{parentName:"p"},"RegExp")," might be used."),(0,l.kt)("h3",{id:"tobeenabled"},(0,l.kt)("inlineCode",{parentName:"h3"},"toBeEnabled()")," / ",(0,l.kt)("inlineCode",{parentName:"h3"},"toBeDisabled")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toBeEnabled()\nexpect(element).toBeDisabled()\n")),(0,l.kt)("p",null,"These allow you to assert whether the given element is enabled or disabled from the user's perspective. It relies on the accessibility disabled state as set by ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-disabled")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"accessibilityState.disabled")," props. It will consider a given element disabled when it or any of its ancestors is disabled."),(0,l.kt)("admonition",{type:"note"},(0,l.kt)("p",{parentName:"admonition"},"These matchers are the negation of each other, and both are provided to avoid double negations in your assertions.")),(0,l.kt)("h3",{id:"tobeselected"},(0,l.kt)("inlineCode",{parentName:"h3"},"toBeSelected()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toBeSelected()\n")),(0,l.kt)("p",null,"This allows you to assert whether the given element is selected from the user's perspective. It relies on the accessibility selected state as set by ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-selected")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"accessibilityState.selected")," props."),(0,l.kt)("h3",{id:"tobechecked"},(0,l.kt)("inlineCode",{parentName:"h3"},"toBeChecked()")," / ",(0,l.kt)("inlineCode",{parentName:"h3"},"toBePartiallyChecked()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toBeChecked()\nexpect(element).toBePartiallyChecked()\n")),(0,l.kt)("p",null,"These allow you to assert whether the given element is checked or partially checked from the user's perspective. It relies on the accessibility checked state as set by ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-checked")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"accessibilityState.checked")," props."),(0,l.kt)("admonition",{type:"note"},(0,l.kt)("ul",{parentName:"admonition"},(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"toBeChecked()")," matcher works only on elements with the ",(0,l.kt)("inlineCode",{parentName:"li"},"checkbox")," or ",(0,l.kt)("inlineCode",{parentName:"li"},"radio")," role."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"toBePartiallyChecked()")," matcher works only on elements with the ",(0,l.kt)("inlineCode",{parentName:"li"},"checkbox")," role."))),(0,l.kt)("h3",{id:"tobeexpanded"},(0,l.kt)("inlineCode",{parentName:"h3"},"toBeExpanded()")," / ",(0,l.kt)("inlineCode",{parentName:"h3"},"toBeCollapsed()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toBeExpanded()\nexpect(element).toBeCollapsed()\n")),(0,l.kt)("p",null,"These allows you to assert whether the given element is expanded or collapsed from the user's perspective. It relies on the accessibility disabled state as set by ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-expanded")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"accessibilityState.expanded")," props."),(0,l.kt)("admonition",{type:"note"},(0,l.kt)("p",{parentName:"admonition"},"These matchers are the negation of each other for expandable elements (elements with explicit ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-expanded")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"accessibilityState.expanded")," props). However, both won't pass for non-expandable elements (ones without explicit ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-expanded")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"accessibilityState.expanded")," props).")),(0,l.kt)("h3",{id:"tobebusy"},(0,l.kt)("inlineCode",{parentName:"h3"},"toBeBusy()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toBeBusy()\n")),(0,l.kt)("p",null,"This allows you to assert whether the given element is busy from the user's perspective. It relies on the accessibility selected state as set by ",(0,l.kt)("inlineCode",{parentName:"p"},"aria-busy")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"accessibilityState.busy")," props."),(0,l.kt)("h2",{id:"element-styles"},"Element Styles"),(0,l.kt)("h3",{id:"tobevisible"},(0,l.kt)("inlineCode",{parentName:"h3"},"toBeVisible()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toBeVisible()\n")),(0,l.kt)("p",null,"This allows you to assert whether the given element is visible from the user's perspective. "),(0,l.kt)("p",null,"The element is considered invisible when itself or any of its ancestors has ",(0,l.kt)("inlineCode",{parentName:"p"},"display: none")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"opacity: 0")," styles, as well as when it's hidden from accessibility."),(0,l.kt)("h3",{id:"tohavestyle"},(0,l.kt)("inlineCode",{parentName:"h3"},"toHaveStyle()")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-ts"},"expect(element).toHaveStyle(\n style: StyleProp