Datasets:
Download web/detox.github.io/reference/site/docs/api/internals/index.html from Qwen/RecreationBench: direct link, hf CLI and curl.
- Browser
- Download file 162 kB
-
https://huggingface.co/datasets/Qwen/RecreationBench/resolve/main/web/detox.github.io/reference/site/docs/api/internals/index.html
- Command line
-
hf download hf://datasets/Qwen/RecreationBench/web/detox.github.io/reference/site/docs/api/internals/index.html
-
curl -L -o index.html https://huggingface.co/datasets/Qwen/RecreationBench/resolve/main/web/detox.github.io/reference/site/docs/api/internals/index.html
162 kB
| <html class="docs-wrapper docs-doc-page docs-version-20.x plugin-docs plugin-id-default docs-doc-id-api/internals show--consent" data-has-hydrated="true" data-rh="lang,dir,class,data-has-hydrated" data-theme="dark" dir="ltr" lang="en"><head> | |
| <meta charset="utf-8"/> | |
| <meta content="Docusaurus v2.4.3" name="generator"/> | |
| <title>Internals API | Detox</title><meta content="summary_large_image" data-rh="true" name="twitter:card"/><meta content="en" data-rh="true" name="docusaurus_locale"/><meta content="en" data-rh="true" name="docsearch:language"/><meta content="20.x" data-rh="true" name="docusaurus_version"/><meta content="docs-default-20.x" data-rh="true" name="docusaurus_tag"/><meta content="20.x" data-rh="true" name="docsearch:version"/><meta content="docs-default-20.x" data-rh="true" name="docsearch:docusaurus_tag"/><meta content="Internals API | Detox" data-rh="true" property="og:title"/><meta content="This section might be more volatile than the other ones, yet we'll do our best to adhere to Semantic Release standards even here." data-rh="true" name="description"/><meta content="This section might be more volatile than the other ones, yet we'll do our best to adhere to Semantic Release standards even here." data-rh="true" property="og:description"/><link data-rh="true" href="/img/favicon.ico" rel="icon"/><link crossorigin="anonymous" data-rh="true" href="/_404.html" rel="preconnect"/><link href="/blog/rss.xml" rel="alternate" title="Detox RSS Feed" type="application/rss+xml"/> | |
| <link href="/blog/atom.xml" rel="alternate" title="Detox Atom Feed" type="application/atom+xml"/> | |
| <link href="/_404.html" rel="preconnect"/> | |
| <link href="/_404.html" rel="preconnect"/> | |
| <link href="/_404.html" rel="preconnect"/> | |
| <script>window.dataLayer=window.dataLayer||[]</script> | |
| <link href="/opensearch.xml" rel="search" title="Detox" type="application/opensearchdescription+xml"/> | |
| <script async="" src="/_cdn/platform.twitter.com/widgets.js"></script><link href="/assets/css/styles.2561cce4.css" rel="stylesheet"/> | |
| <link as="script" href="/assets/js/runtime~main.12cb17c3.js" rel="preload"/> | |
| <link as="script" href="/assets/js/main.899efd46.js" rel="preload"/> | |
| <link data-rh="true" href="/docs/api/internals/" rel="canonical"/><link data-rh="true" href="/docs/api/internals/" hreflang="en" rel="alternate"/><link data-rh="true" href="/docs/api/internals/" hreflang="x-default" rel="alternate"/><meta content="width=device-width, initial-scale=1.0" data-rh="true" name="viewport"/><meta content="/docs/api/internals/" data-rh="true" property="og:url"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/f14c3b1d.750d68cc.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/79ac7843.08fb5e78.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/9a34b858.98ca0ede.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/5b12c1a9.ead7646c.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/bab8a798.39e6da23.js" rel="prefetch"/><link href="/assets/js/c4f5d8e4.1d727c7d.js" rel="prefetch"/><link href="/assets/js/0ef19a76.b6a3804a.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/85addd09.f2a5fda6.js" rel="prefetch"/><link href="/assets/js/5fc994c2.0a3b56b5.js" rel="prefetch"/><link href="/assets/js/0ef19a76.b6a3804a.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/935f2afb.d4cfcd14.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/1a01fdf1.df8f2b8f.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/d9894068.9ef62e7b.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/373c35af.5d2e051c.js" rel="prefetch"/><link href="/assets/js/a6aa9e1f.f7d63002.js" rel="prefetch"/><link href="/assets/js/181d712d.f728104a.js" rel="prefetch"/><link href="/assets/js/814f3328.368bc5eb.js" rel="prefetch"/><link href="/assets/js/83eb08f7.4d5ec241.js" rel="prefetch"/><link href="/assets/js/9292650b.f26ac725.js" rel="prefetch"/><link href="/assets/js/933bed1e.d56d75f0.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/7358fe14.7552c7a7.js" rel="prefetch"/><link href="/_cdn/unpkg.com/@68publishers/cookie-consent/dist/cookie-consent.css" rel="stylesheet"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/7accbb75.e3d53ef1.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/a622d695.ad67fb36.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/96997528.38ed49ad.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/2cf03b61.a8da21dc.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/20110cf9.78831dd9.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/9a6ca8b8.7d954869.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/4e8770ad.7c56d7b4.js" rel="prefetch"/><link href="/assets/js/a8a1de49.bab92bdd.js" rel="prefetch"/><link href="/assets/js/3fb5a56d.b5c89c21.js" rel="prefetch"/><link href="/assets/js/d350cff3.43602b60.js" rel="prefetch"/><link href="/assets/js/17896441.b40a6528.js" rel="prefetch"/><link href="/assets/js/71949878.06587ec8.js" rel="prefetch"/></head> | |
| <body class="navigation-with-keyboard" data-rh="class" style="overflow: visible;"> | |
| <script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"dark")}()</script><div id="__docusaurus"><div class="banner_SLir"><a class="link_SNdm" href="/_404.html" rel="noopener noreferrer" target="_blank"><span class="uaFlag_wtbk"></span> This project is created with substantial contributions from our Ukrainian colleagues.<!-- --> <span class="hashtag_KSDo">#StandWithUkraine</span></a></div><div aria-label="Skip to main content" role="region"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-expanded="false" aria-label="Toggle navigation bar" class="navbar__toggle clean-btn" type="button"><svg aria-hidden="true" fill="currentColor" height="12" viewbox="0 0 19 12" width="19"><rect height="1" rx="0.5" stroke="currentColor" stroke-linecap="round" width="18" x="0.5" y="5.5"></rect><rect height="1" rx="0.5" stroke="currentColor" stroke-linecap="round" width="18" x="0.5" y="10.5"></rect><rect height="1" rx="0.5" stroke="currentColor" stroke-linecap="round" width="18" x="0.5" y="0.5"></rect></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img alt="Detox Logo" class="themedImage_ToTc themedImage--dark_i4oU" src="/img/logo.png"/></div><b class="navbar__title text--truncate">Detox</b></a><a class="navbar__item navbar__link" href="/docs/introduction/getting-started">Docs</a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/docs/config/overview">API</a><a class="navbar__item navbar__link" href="/docs/contributing">Contribute</a><a class="navbar__item navbar__link" href="/blog">Blog</a><a class="navbar__item navbar__link header-showcase-link" href="/showcase">Showcase</a></div><div class="navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a aria-expanded="false" aria-haspopup="true" class="navbar__link" href="/docs/introduction/getting-started" role="button">20.x</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/docs/next/api/internals">Next</a></li><li><a aria-current="page" class="dropdown__link dropdown__link--active" href="/docs/api/internals">20.x</a></li><li><a class="dropdown__link" href="/docs/19.x/">19.x</a></li></ul></div><a aria-label="GitHub repository" class="navbar__item navbar__link header-github-link" href="/_404.html" rel="noopener noreferrer" target="_blank"></a><div class="toggle_vylO colorModeToggle_DEke"><button aria-label="Switch between dark and light mode (currently dark mode)" aria-live="polite" class="clean-btn toggleButton_gllP" title="Switch between dark and light mode (currently dark mode)" type="button"><svg class="lightToggleIcon_pyhR" height="24" viewbox="0 0 24 24" width="24"><path d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z" fill="currentColor"></path></svg><svg class="darkToggleIcon_wfgR" height="24" viewbox="0 0 24 24" width="24"><path d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z" fill="currentColor"></path></svg></button></div><div class="searchWrapper_jYdA searchBox_ZlJk"><button aria-label="Search (Ctrl+K)" class="DocSearch DocSearch-Button" type="button"><span class="DocSearch-Button-Container"><svg aria-hidden="true" class="DocSearch-Search-Icon" height="20" viewbox="0 0 20 20" width="20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" fill="none" fill-rule="evenodd" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"><svg class="DocSearch-Control-Key-Icon" height="15" width="15"><path d="M4.505 4.496h2M5.505 5.496v5M8.216 4.496l.055 5.993M10 7.5c.333.333.5.667.5 1v2M12.326 4.5v5.996M8.384 4.496c1.674 0 2.116 0 2.116 1.5s-.442 1.5-2.116 1.5M3.205 9.303c-.09.448-.277 1.21-1.241 1.203C1 10.5.5 9.513.5 8V7c0-1.57.5-2.5 1.464-2.494.964.006 1.134.598 1.24 1.342M12.553 10.5h1.953" fill="none" stroke="currentColor" stroke-linecap="square" stroke-width="1.2"></path></svg></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div></div></div><div class="navbar-sidebar__backdrop" role="presentation"></div></nav><div class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX" id="__docusaurus_skipToContent_fallback"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebarViewport_Xe31"><div class="sidebar_njMd"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a aria-expanded="false" class="menu__link menu__link--sublist menu__link--sublist-caret" href="#">Config file</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a aria-expanded="false" class="menu__link menu__link--sublist menu__link--sublist-caret" href="#">Command Line Interface</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a aria-expanded="false" class="menu__link menu__link--sublist menu__link--sublist-caret" href="#">Client API</a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a aria-current="page" class="menu__link menu__link--active" href="/docs/api/internals">Internals API</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a aria-expanded="false" class="menu__link menu__link--sublist menu__link--sublist-caret" href="#">Tech Articles</a></div></li></ul></nav></div></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><nav aria-label="Breadcrumbs" class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/"><svg class="breadcrumbHomeIcon_YNFT" viewbox="0 0 24 24"><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"></path></svg></a></li><li class="breadcrumbs__item breadcrumbs__item--active" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem"><span class="breadcrumbs__link" itemprop="name">Internals API</span><meta content="1" itemprop="position"/></li></ul></nav><span class="theme-doc-version-badge badge badge--secondary">Version: 20.x</span><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button class="clean-btn tocCollapsibleButton_TO0P" type="button">On this page</button></div><div class="theme-doc-markdown markdown"><h1>Internals API</h1><div class="theme-admonition theme-admonition-caution alert alert--warning admonition_LlT9"><div class="admonitionHeading_tbUL"><span class="admonitionIcon_kALy"><svg viewbox="0 0 16 16"><path 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" fill-rule="evenodd"></path></svg></span>caution</div><div class="admonitionContent_S0QG"><p>This section might be more volatile than the other ones, yet we'll do our best to adhere to Semantic Release standards even here.</p></div></div><p>Detox Internals might be useful for developing advanced enterprise presets or when you are planning to integrate with a third-party test runner like <a href="/_404.html" rel="noopener noreferrer" target="_blank">Mocha</a>, <a href="/_404.html" rel="noopener noreferrer" target="_blank">Ava</a>, <a href="/_404.html" rel="noopener noreferrer" target="_blank">Vitest</a> or other ones.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="lifecycle">Lifecycle<a aria-label="Direct link to Lifecycle" class="hash-link" href="#lifecycle" title="Direct link to Lifecycle"></a></h2><p>The purpose of <strong>Internals API</strong> is mostly to align the lifecycles of Detox and a test runner underneath. | |
| Although it is generic enough, there is no denying that its design has been influenced by our official integration with Jest test runner. | |
| That's why it might be better to start the overview from Jest lifecycle first, and then move on to Detox lifecycle and how they fit together.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="jest-lifecycle">Jest lifecycle<a aria-label="Direct link to Jest lifecycle" class="hash-link" href="#jest-lifecycle" title="Direct link to Jest lifecycle"></a></h3><p><img alt="UML sequence diagram" class="img_ev3q" height="594" loading="eager" src="/assets/images/jest-diagram-d957dd3e62301816b44197ef0a4abee0.svg" width="717"/></p><ol><li><p>Jest's main process starts from resolving and evaluating its config file, e.g. <code>jest.config.js</code>:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">module</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method-variable function-variable method function property-access" style="color: rgb(80, 250, 123);">exports</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">function</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">return</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">globalSetup</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'/path/to/globalSetup.js'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">globalTeardown</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'/path/to/globalTeardown.js'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">reporters</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">[</span><span class="token string" style="color: rgb(255, 121, 198);">'/path/to/reporter.js'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">]</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">/* ... jest config ... */</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div></li><li><p>If a <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>globalSetup</code></a> handler is defined, it is resolved and executed in the main process:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">module</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method-variable function-variable method function property-access" style="color: rgb(80, 250, 123);">exports</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">function</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ... global setup code ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div></li><li><p>The next come <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>reporters</code></a>, one of the longest-living entities in the test session. After instantiating reporters, Jest calls their <code>onRunStart</code> method:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">class</span><span class="token plain"> </span><span class="token class-name">Reporter</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">onRunStart</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token parameter">aggregatedResults</span><span class="token parameter punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token parameter"> options</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ... reporter code ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div></li><li><p>If Jest is not running in band (see <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>-i, --runInBand</code></a>), and if it has <em>N</em> <a href="/_404.html" rel="noopener noreferrer" target="_blank">workers</a> (<em>N > 1</em>), then it spawns <em>N</em> child processes that keep taking test files one after another, running their tests inside and reporting back to the reporters:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">class</span><span class="token plain"> </span><span class="token class-name">Reporter</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">onTestFileResult</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token parameter">test</span><span class="token parameter punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token parameter"> testResult</span><span class="token parameter punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token parameter"> aggregatedResult</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ... reporter code ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>Otherwise, Jest runs all the tests in the main process without spawning any other processes, but the reporting flow itself remains the same, as can be seen in the diagram:</p><p><img alt="UML sequence diagram" class="img_ev3q" height="616" loading="eager" src="/assets/images/jest-diagram-runInBand-b0e7564080d4f6a0a03e4dbcf6b0da7f.svg" width="591"/></p></li><li><p>After all the tests have been executed, Jest calls <code>onRunComplete</code> in the reporters, and this is the final phase for any reporter:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">class</span><span class="token plain"> </span><span class="token class-name">Reporter</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">onRunComplete</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token parameter">testContexts</span><span class="token parameter punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token parameter"> results</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ... reporter code ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div></li><li><p>The last user-controlled hook is the global teardown. If a <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>globalTeardown</code></a> handler is defined, it is resolved and executed in the main process:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">module</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method-variable function-variable method function property-access" style="color: rgb(80, 250, 123);">exports</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">function</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ... global teardown code ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div></li></ol><h3 class="anchor anchorWithStickyNavbar_LWe7" id="detox-lifecycle">Detox lifecycle<a aria-label="Direct link to Detox lifecycle" class="hash-link" href="#detox-lifecycle" title="Direct link to Detox lifecycle"></a></h3><p>Theoretically, Detox CLI could be totally agnostic about the test runner under the hood, but that would deprive us of some convenience. | |
| For instance, there is a <a href="/docs/config/testRunner#testrunnerretries-number">retry mechanism</a>, built into Detox CLI, which can schedule extra runs for failed test files. | |
| This requirement obliges Detox context to live longer than any test runner, and requires from the test runner to be able to report back to Detox CLI, whereas the resulting child process hierarchy can be broad and multi-tiered, e.g.:</p><div class="language-plain codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-plain codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">└── detox test ...</span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> └── jest ... --maxWorkers N</span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> ├── jest-worker (1)</span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> ├── ...</span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> └── jest-worker (N)</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>Even if we run Jest directly, without Detox CLI, there's still a one-to-many relationship between its processes:</p><div class="language-plain codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-plain codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">└── jest ... --maxWorkers N</span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> ├── jest-worker (1)</span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> ├── ...</span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> └── jest-worker (N)</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>So, if we want to be on the safe side, every process should be able to communicate with the root process, where we have the primary context of Detox, and vice versa. | |
| Retrying failed tests is just one of numerous needs, and there are more:</p><ul><li>the primary context (and workers themselves, at times) needs to know how many workers are there;</li><li>the workers should request from the primary context to allocate a device and return it back when they are done;</li><li>any secondary context should be able to tell whether this is a first time it is running, or it is an <em>N</em>-th attempt already;</li></ul><p>This list can be continued and might expand even more with time, but the point is that Detox contexts will get instantiated as many times as child processes are created during the test session, and it should be something trivial to synchronize the primary and the secondary contexts to ensure a seamless experience.</p><p>It is worth mentioning that Jest's main process is ill-suited for taking a device and running the tests, as its purpose is to orchestrate the entire test session and not run the tests themselves. | |
| This means that not all secondary contexts of Detox are "born equal" – most of them will be allocating a device for running tests, but at least one will be merely communicating with the primary context.</p><p>This is exactly the reason why we call <a href="#initoptions-promise"><code>init()</code></a> in every child process, but sometimes it is not just a simple call, but an <a href="#initoptions-promise"><code>init({ workerId: null })</code></a> override to avoid creating a worker. | |
| However, the fact of initializing without a worker does not mean we can't call <a href="#installworkeroptions-promise"><code>installWorker()</code></a> later. For example, if it turns out that Jest is running in a single process, then instead of creating two Detox contexts within the same process, we're going to reuse the existing one and just supplement it with the worker itself.</p><p>There's one more implicit thing that happens at the very beginning of <a href="#initoptions-promise"><code>init([options])</code></a> method, and that is the config resolution. It is also available as a separate method, <a href="#resolveconfigoptions-promise"><code>resolveConfig([options])</code></a> based on the following considerations. | |
| When you use a test runner directly, without Detox CLI (e.g. <code>jest …</code> instead of <code>detox test …</code>), then the test runner config gets resolved earlier than Detox config itself. That creates a dangerous scenario for dynamically generated configs:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockTitle_Ktv7">jest.config.js</div><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">const</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> config </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">require</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'detox/internals'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">module</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method-variable function-variable method function property-access" style="color: rgb(80, 250, 123);">exports</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token arrow operator">=></span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">if</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token plain">config</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">device</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">type</span><span class="token plain"> </span><span class="token operator">===</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'ios.simulator'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">return</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">/* iOS-specific preset */</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">else</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">return</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">/* Android-specific preset */</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>The problem in this case is that we are accessing an unresolved (yet) config. Of course, one could assume that it is possible to overcome with a plain <a href="#initoptions-promise"><code>init()</code></a> call like this:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockTitle_Ktv7">bad-idea.config.js</div><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">const</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> init</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"> config </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">require</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'detox/internals'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">module</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method-variable function-variable method function property-access" style="color: rgb(80, 250, 123);">exports</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token arrow operator">=></span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">init</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">if</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token plain">config</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">device</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">type</span><span class="token plain"> </span><span class="token operator">===</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'ios.simulator'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ... use config now ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>This solution will work, but it is rather a bad one, since Jest config resolution is an asymmetrical step compared to <code>globalSetup</code> and <code>globalTeardown</code>. While solving one problem, it creates another one. Consider running this:</p><div class="language-sh codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-sh codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">jest --config bad-idea.config.js --showConfig</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>For reference, when Jest runs with a <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>--showConfig</code></a> option, all it does is <em>to resolve the config and to print it</em>. Hence, neither <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>globalSetup</code></a> nor <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>globalTeardown</code></a> will be called, and the test runner will hang up since there's no one to call the <a href="#cleanup-promise"><code>cleanup()</code></a> method which stops the <a href="/_404.html" rel="noopener noreferrer" target="_blank">IPC server</a> used for the communication between the primary and the secondary contexts.</p><p>Still, we have to be able to access the config early, and that is exactly why <a href="#initoptions-promise"><code>init()</code></a> method is a composite of <a href="#resolveconfigoptions-promise"><code>resolveConfig()</code></a>, the <em>actual</em> init, and <a href="#installworkeroptions-promise"><code>installWorker()</code></a>. We could describe what it does on the high level with the following pseudocode:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">function</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">init</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token parameter">options </span><span class="token parameter operator">=</span><span class="token parameter"> </span><span class="token parameter punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token parameter punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> config </span><span class="token operator">=</span><span class="token plain"> config </span><span class="token operator">||</span><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">resolveConfig</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> logger</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method function property-access" style="color: rgb(80, 250, 123);">init</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token plain">config</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> ipcServer</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method function property-access" style="color: rgb(80, 250, 123);">init</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token plain">config</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ... init more things ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">if</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token plain">options</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">workerId</span><span class="token plain"> </span><span class="token operator">!=</span><span class="token plain"> </span><span class="token keyword null nil" style="color: rgb(189, 147, 249); font-style: italic;">null</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">installWorker</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>In other words, it will resolve config only if it has not been resolved before, and install a worker unless it has been forbidden explicitly. | |
| And even that we can <a href="#installworkeroptions-promise"><code>installWorker()</code></a> later if we ever need it.</p><p>Now, when many details are clarified, we can review the actual sequence diagrams step by step. There are four scenarios depending on the initiator (Detox CLI or the test runner itself) and on child process hierarchy (a single process or parent-children).</p><p>A few words about the diagram and its conventions:</p><ul><li>The <code>ClassName.0</code>, <code>ClassName.1</code>, …, <code>ClassName.N</code> suffixes mean the index of the instance of the class created.</li><li><code>DetoxCircusEnvironment.N</code> is our custom <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>testEnvironment</code></a> created one or multiple times in every Jest worker. Make sure to read about Jest <a href="/_404.html" rel="noopener noreferrer" target="_blank">test environments</a> and look at the example section there for better understanding.</li></ul><div class="tabs-container tabList__CuJ"><ul aria-orientation="horizontal" class="tabs" role="tablist"><li aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active" role="tab" tabindex="0">detox test … --maxWorkers N</li><li aria-selected="false" class="tabs__item tabItem_LNqP" role="tab" tabindex="-1">jest … --maxWorkers N</li><li aria-selected="false" class="tabs__item tabItem_LNqP" role="tab" tabindex="-1">detox test … --runInBand</li><li aria-selected="false" class="tabs__item tabItem_LNqP" role="tab" tabindex="-1">jest … --runInBand</li></ul><div class="margin-top--md"><div class="tabItem_Ymn6" role="tabpanel"><p><img alt="UML sequence diagram" class="img_ev3q" height="831" loading="eager" src="/assets/images/boot-cli-many-workers-95ab2193ce10864c0742f01ffd30b58b.svg" width="1190"/></p></div><div class="tabItem_Ymn6" hidden="" role="tabpanel"><p><img alt="UML sequence diagram" class="img_ev3q" height="682" loading="eager" src="/assets/images/boot-jest-many-workers-ce60aaacc2101a9b810d2d22fe0df51b.svg" width="962"/></p></div><div class="tabItem_Ymn6" hidden="" role="tabpanel"><p><img alt="UML sequence diagram" class="img_ev3q" height="743" loading="eager" src="/assets/images/boot-cli-single-worker-6672b7356e2146d40f39f80145780949.svg" width="842"/></p></div><div class="tabItem_Ymn6" hidden="" role="tabpanel"><p><img alt="UML sequence diagram" class="img_ev3q" height="565" loading="eager" src="/assets/images/boot-jest-single-worker-278e1383ad4f31570f073fa12689aec6.svg" width="598"/></p></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="methods">Methods<a aria-label="Direct link to Methods" class="hash-link" href="#methods" title="Direct link to Methods"></a></h2><div class="theme-admonition theme-admonition-info alert alert--info admonition_LlT9"><div class="admonitionHeading_tbUL"><span class="admonitionIcon_kALy"><svg viewbox="0 0 14 16"><path 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" fill-rule="evenodd"></path></svg></span>info</div><div class="admonitionContent_S0QG"><p>Feel free to browse through <a href="/_404.html" rel="noopener noreferrer" target="_blank">the typings file</a> provided by Detox.</p></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="resolveconfigoptions-promiseruntimeconfig"><code>resolveConfig([options])</code> <!-- -->[<!-- -->Promise<RuntimeConfig<!-- -->><!-- -->]<a aria-label="Direct link to resolveconfigoptions-promiseruntimeconfig" class="hash-link" href="#resolveconfigoptions-promiseruntimeconfig" title="Direct link to resolveconfigoptions-promiseruntimeconfig"></a></h3><p>Use sparingly for cases when you need to read Detox config before <a href="#initoptions-promise"><code>init()</code></a> is called.</p><p>If you use Detox with Jest, our default integration, the only place where you might need it is your <code>jest.config.js</code>, e.g.:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockTitle_Ktv7">jest.config.js</div><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">const</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> resolveConfig </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">require</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'detox/internals'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">module</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method-variable function-variable method function property-access" style="color: rgb(80, 250, 123);">exports</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token arrow operator">=></span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">/** @type {DetoxInternals.RuntimeConfig} */</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">const</span><span class="token plain"> config </span><span class="token operator">=</span><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">resolveConfig</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">return</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">/* Jest config */</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>For example, you could use that to evaluate the <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>maxWorkers</code></a> count depending on the device type, | |
| but please mind, though, that Detox allows to override test runner options via its own config, e.g.:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockTitle_Ktv7">detox.config.js</div><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token comment" style="color: rgb(98, 114, 164);">/** @type {Detox.DetoxConfig} */</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">module</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">exports</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">apps</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">/* ... */</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">devices</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">/* ... */</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">configurations</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token string-property property">'ios.sim.release'</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">app</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'ios.release'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">device</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'iphone'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">testRunner</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">args</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line theme-code-block-highlighted-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">maxWorkers</span><span class="token operator">:</span><span class="token plain"> process</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">env</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token constant" style="color: rgb(189, 147, 249);">CI</span><span class="token plain"> </span><span class="token operator">===</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'true'</span><span class="token plain"> </span><span class="token operator">?</span><span class="token plain"> </span><span class="token number">3</span><span class="token plain"> </span><span class="token operator">:</span><span class="token plain"> </span><span class="token keyword nil" style="color: rgb(189, 147, 249); font-style: italic;">undefined</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token string-property property">'android.emu.release'</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">app</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'android.release'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">device</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'nexus'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">testRunner</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">args</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line theme-code-block-highlighted-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">maxWorkers</span><span class="token operator">:</span><span class="token plain"> process</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">env</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token constant" style="color: rgb(189, 147, 249);">CI</span><span class="token plain"> </span><span class="token operator">===</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'true'</span><span class="token plain"> </span><span class="token operator">?</span><span class="token plain"> </span><span class="token number">2</span><span class="token plain"> </span><span class="token operator">:</span><span class="token plain"> </span><span class="token keyword nil" style="color: rgb(189, 147, 249); font-style: italic;">undefined</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>This trick shown above allows to forward extra CLI arguments to <code>jest</code> conditionally, e.g. when running in CI mode:</p><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-bash codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token assign-left variable" style="color: rgb(189, 147, 249); font-style: italic;">CI</span><span class="token operator">=</span><span class="token plain">true detox </span><span class="token builtin class-name" style="color: rgb(189, 147, 249);">test</span><span class="token plain"> -c ios.sim.release</span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token comment" style="color: rgb(98, 114, 164);"># jest --config e2e/jest.config.js --maxWorkers 3</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="getstatus-enum"><code>getStatus()</code> <!-- -->[<!-- -->enum]<a aria-label="Direct link to getstatus-enum" class="hash-link" href="#getstatus-enum" title="Direct link to getstatus-enum"></a></h3><p>Returns one of statuses depending on what’s going with the current Detox context:</p><ul><li><code>inactive</code> – before <a href="#initoptions-promise"><code>init()</code></a> and after <a href="#cleanup-promise"><code>cleanup()</code></a> is called.</li><li><code>init</code> – while <a href="#initoptions-promise"><code>init()</code></a> is executing.</li><li><code>active</code> – after <a href="#initoptions-promise"><code>init()</code></a> and before <a href="#cleanup-promise"><code>cleanup()</code></a> is called.</li><li><code>cleanup</code> – while <a href="#cleanup-promise"><code>cleanup</code></a> is executing.</li></ul><h3 class="anchor anchorWithStickyNavbar_LWe7" id="initoptions-promise"><code>init([options])</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to initoptions-promise" class="hash-link" href="#initoptions-promise" title="Direct link to initoptions-promise"></a></h3><p>This is the phase where:</p><ul><li>a primary Detox context resolves its configuration, starts the logger, IPC server, and more;</li><li>a secondary Detox context connects to IPC server and registers itself;</li><li>if <code>workerId</code> is not null, <a href="#installworkeroptions-promise">installs the worker</a>;</li></ul><p>Accepts an optional parameter, <code>options</code> object with the following properties, <em>all optional</em> as well:</p><ul><li><code>cwd</code> (string) – current working directory, used to <a href="/docs/config/overview#path-conventions">resolve Detox config</a>.</li><li><code>argv</code> (key-value map) – <strong>Internal!</strong>. CLI arguments parsed by Detox CLI.</li><li><code>testRunnerArgv</code> (key-value map) – CLI arguments to be forwarded to the test runner.</li><li><code>override</code> (Partial<Detox.DetoxConfig<!-- -->><!-- -->) – ad-hoc adjustments to deep merge with the file-based config.</li><li><code>global</code> – reference to a custom <a href="/_404.html" rel="noopener noreferrer" target="_blank">global</a> scope, usually needed when your test runner <a href="/_404.html" rel="noopener noreferrer" target="_blank">uses sandboxing</a>. | |
| This prevents creating issues when a Detox context cannot be accessed from within the sandboxed environment.</li><li><code>workerId</code> – (string <!-- -->|<!-- --> null) a unique ID, e.g. <code>worker-1</code>, <code>worker-2</code>. Giving <code>null</code> disables installing the worker.</li></ul><h3 class="anchor anchorWithStickyNavbar_LWe7" id="installworkeroptions-promise"><code>installWorker([options])</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to installworkeroptions-promise" class="hash-link" href="#installworkeroptions-promise" title="Direct link to installworkeroptions-promise"></a></h3><p>This is the phase where Detox loads its expectation library and boots a device. You don't need to call it separately | |
| unless you use <a href="#initoptions-promise"><code>init({ workerId: null })</code></a> override.</p><p>Accepts an optional parameter, <code>options</code> object with the following properties, <em>all optional</em> as well:</p><ul><li><code>global</code> – reference to a custom <a href="/_404.html" rel="noopener noreferrer" target="_blank">global</a> scope, usually needed when your test runner <a href="/_404.html" rel="noopener noreferrer" target="_blank">uses sandboxing</a>. | |
| This prevents creating issues when a Detox context cannot be accessed from within the sandboxed environment.</li><li><code>workerId</code> – (string <!-- -->|<!-- --> null) a unique ID, e.g. <code>worker-1</code>, <code>worker-2</code>. Giving <code>null</code> disables installing the worker.</li></ul><h3 class="anchor anchorWithStickyNavbar_LWe7" id="uninstallworker-promise"><code>uninstallWorker()</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to uninstallworker-promise" class="hash-link" href="#uninstallworker-promise" title="Direct link to uninstallworker-promise"></a></h3><p>Deallocates the device. Most Client API (<a href="/docs/api/device"><code>device</code></a>, <a href="/docs/api/matchers"><code>by</code></a>, <a href="/docs/api/actions"><code>element</code></a>, <a href="/docs/api/expect"><code>expect</code></a>) will stop working, except for <a href="/docs/api/logger">the logger</a>.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="cleanup-promise"><code>cleanup()</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to cleanup-promise" class="hash-link" href="#cleanup-promise" title="Direct link to cleanup-promise"></a></h3><p>This method should be called when the main or child process is about to exit. Under the hood, it:</p><ul><li><a href="#uninstallworker-promise">uninstalls the worker</a> if there is a worker installed;</li><li>a secondary Detox context disconnects from the <a href="/_404.html" rel="noopener noreferrer" target="_blank">IPC server</a>;</li><li>a primary Detox context stops the IPC server and collects the log artifacts.</li></ul><h2 class="anchor anchorWithStickyNavbar_LWe7" id="optional-lifecycle">Optional lifecycle<a aria-label="Direct link to Optional lifecycle" class="hash-link" href="#optional-lifecycle" title="Direct link to Optional lifecycle"></a></h2><h3 class="anchor anchorWithStickyNavbar_LWe7" id="reporttestresultsarray-promise"><code>reportTestResults(array)</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to reporttestresultsarray-promise" class="hash-link" href="#reporttestresultsarray-promise" title="Direct link to reporttestresultsarray-promise"></a></h3><div class="theme-admonition theme-admonition-note alert alert--secondary admonition_LlT9"><div class="admonitionHeading_tbUL"><span class="admonitionIcon_kALy"><svg viewbox="0 0 14 16"><path 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" fill-rule="evenodd"></path></svg></span>note</div><div class="admonitionContent_S0QG"><p>This method has an effect only when the tests are run via <a href="/docs/cli/test">Detox CLI</a>.</p></div></div><p>Reports to the primary context about failed tests that could have been re-run if <a href="/docs/cli/test#options"><code>-R, --retries</code></a> mechanism is enabled.</p><p>It takes one argument, an array of test file reports. Each report is an object with the following properties:</p><ul><li><code>testFilePath</code> (string) — global or relative path to the failed test file;</li><li><code>success</code> (boolean) — whether the test passed or not;</li><li><code>testExecError</code> (optional error) — top-level error, use it only if the entire test file failed, e.g. due to a syntax error or environment setup failure;</li><li><code>isPermanentFailure</code> (optional boolean) — if the test failed, it should tell whether the failure is permanent. Permanent failure means that the test file should not be re-run. For instance, we use it to <a href="/docs/config/testRunner#testrunnerjestretryaftercircusretries-boolean">prevent double retries</a>: with Detox CLI and with <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>jest.retryTimes()</code></a>.</li></ul><h3 class="anchor anchorWithStickyNavbar_LWe7" id="onrundescribestartevent-promise"><code>onRunDescribeStart(event)</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to onrundescribestartevent-promise" class="hash-link" href="#onrundescribestartevent-promise" title="Direct link to onrundescribestartevent-promise"></a></h3><p><strong>Requires an installed worker.</strong> | |
| Reports that the test runner started executing a test suite, e.g. a <code>beforeAll</code> hook or a first test:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">onRunDescribeStart</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">name</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'Suite name'</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="onteststartevent-promise"><code>onTestStart(event)</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to onteststartevent-promise" class="hash-link" href="#onteststartevent-promise" title="Direct link to onteststartevent-promise"></a></h3><p><strong>Requires an installed worker.</strong> | |
| Reports that the test runner started executing a specific test. Use <code>invocations</code> when a test is being re-run after a failure:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">onTestStart</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">title</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'should do something expected'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">fullName</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'Suite name should do something expected'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">invocations</span><span class="token operator">:</span><span class="token plain"> </span><span class="token number">1</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">status</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'running'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="onhookfailureevent-promise"><code>onHookFailure(event)</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to onhookfailureevent-promise" class="hash-link" href="#onhookfailureevent-promise" title="Direct link to onhookfailureevent-promise"></a></h3><p><strong>Requires an installed worker.</strong> | |
| Reports about an error in the midst of <code>beforeAll</code>, <code>beforeEach</code>, <code>afterEach</code>, <code>afterAll</code> or any other hook. We use it, for example, to generate <a href="/docs/config/artifacts">screenshot artifacts</a> like <code>beforeAllFailure.png</code>.</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">onHookFailure</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">error</span><span class="token operator">:</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">new</span><span class="token plain"> </span><span class="token class-name">Error</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'Some assertion failed'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">hook</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'beforeEach'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="ontestfnfailureevent-promise"><code>onTestFnFailure(event)</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to ontestfnfailureevent-promise" class="hash-link" href="#ontestfnfailureevent-promise" title="Direct link to ontestfnfailureevent-promise"></a></h3><p><strong>Requires an installed worker.</strong> | |
| Reports about an error in the midst of a test function. We use it, for example, to generate <a href="/docs/config/artifacts">screenshot artifacts</a> like <code>testFnFailure.png</code>.</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">onTestFnFailure</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token literal-property property">error</span><span class="token operator">:</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">new</span><span class="token plain"> </span><span class="token class-name">Error</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'Some assertion failed'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="ontestdoneevent-promise"><code>onTestDone(event)</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to ontestdoneevent-promise" class="hash-link" href="#ontestdoneevent-promise" title="Direct link to ontestdoneevent-promise"></a></h3><p><strong>Requires an installed worker.</strong> | |
| Reports the final status of the test, <code>passed</code> or <code>failed</code>, e.g.:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">onTestDone</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">title</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'should do something expected'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">fullName</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'Suite name should do something expected'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">invocations</span><span class="token operator">:</span><span class="token plain"> </span><span class="token number">1</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">status</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'failed'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">timedOut</span><span class="token operator">:</span><span class="token plain"> </span><span class="token boolean">false</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>Besides collecting <a href="/docs/config/artifacts">log, screenshot and video artifacts</a>, this hook resets the pending network requests – | |
| these are usually some actions to which the app did not respond during the test. Setting <code>timedOut: true</code> tells Detox to dump those pending requests, if there are any.</p><p>If your test runner supports re-running internally the failed tests, and, for example, your test passes on the second attempt, you would call the method with something like this:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">onTestDone</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">title</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'should do something expected'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">fullName</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'Suite name should do something expected'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">invocations</span><span class="token operator">:</span><span class="token plain"> </span><span class="token number">2</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token literal-property property">status</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'passed'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="onrundescribefinishevent-promise"><code>onRunDescribeFinish(event)</code> <!-- -->[<!-- -->Promise]<a aria-label="Direct link to onrundescribefinishevent-promise" class="hash-link" href="#onrundescribefinishevent-promise" title="Direct link to onrundescribefinishevent-promise"></a></h3><p><strong>Requires an installed worker.</strong> | |
| Reports that the test runner has finished executing a test suite, e.g. all the <code>afterAll</code> hooks have been executed or the last test has finished running:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">onRunDescribeFinish</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token literal-property property">name</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'Suite name'</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="properties">Properties<a aria-label="Direct link to Properties" class="hash-link" href="#properties" title="Direct link to Properties"></a></h2><h3 class="anchor anchorWithStickyNavbar_LWe7" id="config-runtimeconfig"><code>config</code> <!-- -->[<!-- -->RuntimeConfig]<a aria-label="Direct link to config-runtimeconfig" class="hash-link" href="#config-runtimeconfig" title="Direct link to config-runtimeconfig"></a></h3><p>Open <a href="/_404.html" rel="noopener noreferrer" target="_blank">the typings file</a> and search for <code>RuntimeConfig</code>.</p><p>For the most part, this config is identical to what we describe in <a href="/docs/config/overview">Config docs</a>, except that it is non-optional. | |
| In other words, even if you never customized your <a href="/docs/config/session">Session config</a>, you'll still be able to access some default | |
| values safely, without null checks.</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">const</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> config </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">require</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'detox/internals'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">typeof</span><span class="token plain"> config</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">session</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">autoStart</span><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// "boolean"</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="session-sessionstate"><code>session</code> <!-- -->[<!-- -->SessionState]<a aria-label="Direct link to session-sessionstate" class="hash-link" href="#session-sessionstate" title="Direct link to session-sessionstate"></a></h3><p>The session state contains the following read-only properties:</p><ul><li><code>id</code> (string) – randomly generated ID for the entire Detox test session, including retries.</li><li><code>testResults</code> (DetoxTestFileReport[]) – results of the prior test file executions, used by Detox CLI retry mechanism.</li><li><code>testSessionIndex</code> (number) – the retry index of the test session: <code>0..<retriesCount></code>.</li><li><code>workersCount</code> (number) – count of Detox contexts with a worker installed. | |
| If we oversimplify it, it reflects the count of allocated devices in the current test session.</li></ul><p>The session state, including the resolved config, is serialized by the primary context, so that the secondary Detox contexts can read it synchronously from a file at the earliest point possible. | |
| After the secondary contexts connect to the IPC server hosted by the primary context, they register themselves and get the up-to-date session state. | |
| The IPC server broadcasts the updates to all the connected contexts on every action like <a href="#installworkeroptions-promise"><code>installWorker()</code></a> or <a href="#reporttestresultsarray-promise"><code>reportTestResults()</code></a>.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="log-logger"><code>log</code> <!-- -->[<!-- -->Logger]<a aria-label="Direct link to log-logger" class="hash-link" href="#log-logger" title="Direct link to log-logger"></a></h3><p>See <a href="/docs/api/logger">Logger API</a> for all the details.</p><p>The only difference from the Client API here is that you don't have a predefined <code>user</code> category, i.e.:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">const</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token literal-property property">log</span><span class="token operator">:</span><span class="token plain"> logClient </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">require</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'detox'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">const</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token literal-property property">log</span><span class="token operator">:</span><span class="token plain"> logInternal </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">require</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'detox/internals'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token comment" style="color: rgb(98, 114, 164);">// oversimplified, it looks like:</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain">logClient </span><span class="token operator">==</span><span class="token plain"> logInternal</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method function property-access" style="color: rgb(80, 250, 123);">child</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token literal-property property">cat</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'user'</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>For example, we leverage this for adding more <code>lifecycle</code> events in our integration with Jest:</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockTitle_Ktv7">detox/runners/jest/testEnvironment/index.js</div><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">class</span><span class="token plain"> </span><span class="token class-name">DetoxCircusEnvironment</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">extends</span><span class="token plain"> </span><span class="token class-name">NodeEnvironment</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">constructor</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token parameter">config</span><span class="token parameter punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token parameter"> context</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">super</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token comment" style="color: rgb(98, 114, 164);">/* ... */</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> log</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">trace</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method function property-access" style="color: rgb(80, 250, 123);">begin</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token literal-property property">cat</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'lifecycle'</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"> context</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">testPath</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">// ...</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="tracing"><code>tracing</code><a aria-label="Direct link to tracing" class="hash-link" href="#tracing" title="Direct link to tracing"></a></h3><p>An advanced API useful for creating reports based on logged Detox events.</p><h4 class="anchor anchorWithStickyNavbar_LWe7" id="tracingcreateeventstream"><code>tracing.createEventStream()</code><a aria-label="Direct link to tracingcreateeventstream" class="hash-link" href="#tracingcreateeventstream" title="Direct link to tracingcreateeventstream"></a></h4><p>Creates a readable stream of the currently recorded events in | |
| <a href="/_404.html" rel="noopener noreferrer" target="_blank">Chrome Trace Event format</a>.</p><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color: #F8F8F2; --prism-background-color: #282A36;"><div class="codeBlockContent_biex"><pre class="prism-code language-js codeBlock_bY9V thin-scrollbar" tabindex="0"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">const</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> tracing </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"> </span><span class="token operator">=</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">require</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'detox/internals'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain" style="display: inline-block;"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">async</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">function</span><span class="token plain"> </span><span class="token function" style="color: rgb(80, 250, 123);">processDetoxEvents</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">await</span><span class="token plain"> </span><span class="token keyword" style="color: rgb(189, 147, 249); font-style: italic;">new</span><span class="token plain"> </span><span class="token class-name">Promise</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token parameter">resolve</span><span class="token parameter punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token parameter"> reject</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token arrow operator">=></span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> tracing</span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method function property-access" style="color: rgb(80, 250, 123);">createEventStream</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method function property-access" style="color: rgb(80, 250, 123);">on</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'end'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"> resolve</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method function property-access" style="color: rgb(80, 250, 123);">on</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'error'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"> reject</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token method function property-access" style="color: rgb(80, 250, 123);">on</span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token string" style="color: rgb(255, 121, 198);">'data'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">,</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token parameter">event</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token arrow operator">=></span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">if</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token plain">event</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">ph</span><span class="token plain"> </span><span class="token operator">===</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'B'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">/* duration event (begin) */</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">if</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token plain">event</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">ph</span><span class="token plain"> </span><span class="token operator">===</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'E'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">/* duration event (end) */</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token keyword control-flow" style="color: rgb(189, 147, 249); font-style: italic;">if</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">(</span><span class="token plain">event</span><span class="token punctuation" style="color: rgb(248, 248, 242);">.</span><span class="token property-access">ph</span><span class="token plain"> </span><span class="token operator">===</span><span class="token plain"> </span><span class="token string" style="color: rgb(255, 121, 198);">'i'</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">{</span><span class="token plain"> </span><span class="token comment" style="color: rgb(98, 114, 164);">/* instant event */</span><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"> </span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><span class="token punctuation" style="color: rgb(248, 248, 242);">)</span><span class="token punctuation" style="color: rgb(248, 248, 242);">;</span><span class="token plain"></span><br/></span><span class="token-line" style="color: rgb(248, 248, 242);"><span class="token plain"></span><span class="token punctuation" style="color: rgb(248, 248, 242);">}</span><br/></span></code></pre><div class="buttonGroup__atx"><button aria-label="Copy code to clipboard" class="clean-btn" title="Copy" type="button"><span aria-hidden="true" class="copyButtonIcons_eSgA"><svg class="copyButtonIcon_y97N" viewbox="0 0 24 24"><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" fill="currentColor"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewbox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" fill="currentColor"></path></svg></span></button></div></div></div><p>Please mind that you'll be getting a snapshot of events aggregated from all the sibling and child processes, and it never will be complete until the very end of the test session.</p><p>See also: <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>DurationBeginEvent</code></a>, <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>DurationEndEvent</code></a>, <a href="/_404.html" rel="noopener noreferrer" target="_blank"><code>InstantEvent</code></a>.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="worker-object"><code>worker</code> <!-- -->[<!-- -->object]<a aria-label="Direct link to worker-object" class="hash-link" href="#worker-object" title="Direct link to worker-object"></a></h3><p>Not documented on purpose. Provides direct access to the object which holds the device driver, websocket client, matchers, expectations, etc.</p></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a class="theme-edit-this-page" href="/_404.html" rel="noreferrer noopener" target="_blank"><svg aria-hidden="true" class="iconEdit_Z9Sw" fill="currentColor" height="20" viewbox="0 0 40 40" width="20"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_vwxv"></div></div></footer></article><nav aria-label="Docs pages" class="pagination-nav docusaurus-mt-lg"><a class="pagination-nav__link pagination-nav__link--prev" href="/docs/api/pilot"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Wix Pilot</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/docs/articles/design-principles"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Design Principles</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a class="table-of-contents__link toc-highlight" href="#lifecycle">Lifecycle</a><ul><li><a class="table-of-contents__link toc-highlight" href="#jest-lifecycle">Jest lifecycle</a></li><li><a class="table-of-contents__link toc-highlight" href="#detox-lifecycle">Detox lifecycle</a></li></ul></li><li><a class="table-of-contents__link toc-highlight" href="#methods">Methods</a><ul><li><a class="table-of-contents__link toc-highlight" href="#resolveconfigoptions-promiseruntimeconfig"><code>resolveConfig([options])</code> [Promise<RuntimeConfig>]</a></li><li><a class="table-of-contents__link toc-highlight" href="#getstatus-enum"><code>getStatus()</code> [enum]</a></li><li><a class="table-of-contents__link toc-highlight" href="#initoptions-promise"><code>init([options])</code> [Promise]</a></li><li><a class="table-of-contents__link toc-highlight" href="#installworkeroptions-promise"><code>installWorker([options])</code> [Promise]</a></li><li><a class="table-of-contents__link toc-highlight" href="#uninstallworker-promise"><code>uninstallWorker()</code> [Promise]</a></li><li><a class="table-of-contents__link toc-highlight" href="#cleanup-promise"><code>cleanup()</code> [Promise]</a></li></ul></li><li><a class="table-of-contents__link toc-highlight" href="#optional-lifecycle">Optional lifecycle</a><ul><li><a class="table-of-contents__link toc-highlight" href="#reporttestresultsarray-promise"><code>reportTestResults(array)</code> [Promise]</a></li><li><a class="table-of-contents__link toc-highlight" href="#onrundescribestartevent-promise"><code>onRunDescribeStart(event)</code> [Promise]</a></li><li><a class="table-of-contents__link toc-highlight" href="#onteststartevent-promise"><code>onTestStart(event)</code> [Promise]</a></li><li><a class="table-of-contents__link toc-highlight" href="#onhookfailureevent-promise"><code>onHookFailure(event)</code> [Promise]</a></li><li><a class="table-of-contents__link toc-highlight" href="#ontestfnfailureevent-promise"><code>onTestFnFailure(event)</code> [Promise]</a></li><li><a class="table-of-contents__link toc-highlight" href="#ontestdoneevent-promise"><code>onTestDone(event)</code> [Promise]</a></li><li><a class="table-of-contents__link toc-highlight" href="#onrundescribefinishevent-promise"><code>onRunDescribeFinish(event)</code> [Promise]</a></li></ul></li><li><a class="table-of-contents__link toc-highlight" href="#properties">Properties</a><ul><li><a class="table-of-contents__link toc-highlight" href="#config-runtimeconfig"><code>config</code> [RuntimeConfig]</a></li><li><a class="table-of-contents__link toc-highlight" href="#session-sessionstate"><code>session</code> [SessionState]</a></li><li><a class="table-of-contents__link toc-highlight" href="#log-logger"><code>log</code> [Logger]</a></li><li><a class="table-of-contents__link toc-highlight" href="#tracing"><code>tracing</code></a></li><li><a class="table-of-contents__link toc-highlight" href="#worker-object"><code>worker</code> [object]</a></li></ul></li></ul></div></div></div></div></main></div></div><footer class="footer"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col footer__col_docs"><div class="footer__title">Docs</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/docs/introduction/getting-started">Getting Started</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/contributing">Contributing to Detox</a></li></ul></div><div class="col footer__col footer__col_support"><div class="footer__title">Support</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item footer__link-item_ask-a-question-on-stack-overflow" href="/_404.html" rel="noopener noreferrer" target="_blank">Ask a question on Stack Overflow</a></li><li class="footer__item"><a class="footer__link-item footer__link-item_create-new-issue-on-github" href="/_404.html" rel="noopener noreferrer" target="_blank">Create new issue on Github</a></li></ul></div><div class="col footer__col footer__col_more"><div class="footer__title">More</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item footer__link-item_git-hub" href="/_404.html" rel="noopener noreferrer" target="_blank">GitHub</a></li><li class="footer__item"><a class="footer__link-item footer__link-item_twitter" href="/_404.html" rel="noopener noreferrer" target="_blank">Twitter</a></li><li class="footer__item"><a class="footer__link-item footer__link-item_discord" href="/_404.html" rel="noopener noreferrer" target="_blank">Discord</a></li></ul></div></div></div></footer></div> | |
| <script src="/assets/js/runtime~main.12cb17c3.js"></script> | |
| <script src="/assets/js/main.899efd46.js"></script> | |
| <iframe allowtransparency="true" frameborder="0" scrolling="no" src="/_cdn/platform.twitter.com/widgets/widget_iframe.1227a5674072e080ffb1ba14ac0c1079.html?origin=https%3A%2F%2Fwix.github.io" style="display: none;" title="Twitter settings iframe"></iframe><div class="c--anim" id="cc--main" style="position: fixed;"><div class="cc_div" id="cc_div"><div aria-describedby="c-txt" aria-labelledby="c-ttl" aria-modal="true" class="box bottom center zoom" id="cm" role="dialog" style="visibility: hidden;" tabindex="-1"><div id="c-inr"><div id="c-inr-i"><h2 id="c-ttl">We use cookies!</h2><div id="c-txt">This website uses essential cookies to ensure its proper operation and tracking cookies to understand how you interact with it. The latter will be set only after consent.</div></div><div id="c-bns"><button class="c-bn" id="c-p-bn" type="button"><span tabindex="-1">I agree</span></button><button class="c-bn c_link" id="c-s-bn" type="button"><span tabindex="-1">Customize</span></button></div></div></div><div id="cm-ov" style="visibility: hidden; opacity: 0;"></div><div aria-hidden="true" aria-labelledby="s-ttl" aria-modal="true" class="zoom" id="s-cnt" role="dialog" style="visibility: hidden;" tabindex="-1"><div id="c-vln"><div id="cs"><div id="c-s-in"><div class="bns-t" id="s-inr"><div id="s-hdr"><h2 id="s-ttl">Cookie settings</h2><div id="s-c-bnc"><button aria-label="Close" class="c-bn" id="s-c-bn" type="button"><span tabindex="-1"></span></button></div></div><div id="s-bl"><div class="c-bl"><div class="title"><div aria-level="3" class="b-tl" role="heading">Cookie usage</div></div><div class="desc"><div class="p">We use cookies to ensure the basic functionalities of the website and to enhance your online experience. You can choose for each category to opt-in/out whenever you want.</div></div></div><div class="c-bl b-ex"><div class="title b-bn"><button aria-controls="c-ac-1" aria-expanded="false" class="b-tl exp" type="button">Functionality cookies</button><label class="b-tg"><input class="c-tgl" disabled="" type="checkbox" value="functionality_storage"/><span aria-hidden="true" class="c-tg c-ro"><span class="on-i"></span><span class="off-i"></span></span><span class="t-lb">Functionality cookies</span></label></div><div aria-hidden="true" class="desc b-acc" id="c-ac-1"><div class="p">These cookies are necessary for the proper functioning of our website. Without these cookies, the website might not be working properly.</div></div></div><div class="c-bl b-ex"><div class="title b-bn"><button aria-controls="c-ac-2" aria-expanded="false" class="b-tl exp" type="button">Security cookies</button><label class="b-tg"><input class="c-tgl" type="checkbox" value="security_storage"/><span aria-hidden="true" class="c-tg"><span class="on-i"></span><span class="off-i"></span></span><span class="t-lb">Security cookies</span></label></div><div aria-hidden="true" class="desc b-acc" id="c-ac-2"><div class="p">Security cookies allows storage of security-related information, such as authentication, fraud protection, and other means to protect the user.</div></div></div><div class="c-bl b-ex"><div class="title b-bn"><button aria-controls="c-ac-3" aria-expanded="false" class="b-tl exp" type="button">Personalization cookies</button><label class="b-tg"><input class="c-tgl" type="checkbox" value="personalization_storage"/><span aria-hidden="true" class="c-tg"><span class="on-i"></span><span class="off-i"></span></span><span class="t-lb">Personalization cookies</span></label></div><div aria-hidden="true" class="desc b-acc" id="c-ac-3"><div class="p">Personalisation cookies may use third party cookies to help them personalise content and track users across different websites and devices.</div></div></div><div class="c-bl b-ex"><div class="title b-bn"><button aria-controls="c-ac-4" aria-expanded="false" class="b-tl exp" type="button">Ad cookies</button><label class="b-tg"><input class="c-tgl" type="checkbox" value="ad_storage"/><span aria-hidden="true" class="c-tg"><span class="on-i"></span><span class="off-i"></span></span><span class="t-lb">Ad cookies</span></label></div><div aria-hidden="true" class="desc b-acc" id="c-ac-4"><div class="p">Advertising cookies are used by us or our partners to show you relevant content or advertisements both on our site and on third party sites. This enables us to create profiles based on your interests, so-called pseudonymised profiles. Based on this information, it is generally not possible to directly identify you as a person, as only pseudonymised data is used. Unless you express your consent, you will not receive content and advertisements tailored to your interests.</div></div></div><div class="c-bl b-ex"><div class="title b-bn"><div class="b-tl">Ad user data</div><label class="b-tg"><input class="c-tgl" type="checkbox" value="ad_user_data"/><span aria-hidden="true" class="c-tg"><span class="on-i"></span><span class="off-i"></span></span><span class="t-lb">Ad user data</span></label></div><div aria-hidden="true" class="desc b-acc" id="c-ac-5"></div></div><div class="c-bl b-ex"><div class="title b-bn"><div class="b-tl">Ad personalization</div><label class="b-tg"><input class="c-tgl" type="checkbox" value="ad_personalization"/><span aria-hidden="true" class="c-tg"><span class="on-i"></span><span class="off-i"></span></span><span class="t-lb">Ad personalization</span></label></div><div aria-hidden="true" class="desc b-acc" id="c-ac-6"></div></div><div class="c-bl b-ex"><div class="title b-bn"><button aria-controls="c-ac-7" aria-expanded="false" class="b-tl exp" type="button">Analytics cookies</button><label class="b-tg"><input class="c-tgl" type="checkbox" value="analytics_storage"/><span aria-hidden="true" class="c-tg"><span class="on-i"></span><span class="off-i"></span></span><span class="t-lb">Analytics cookies</span></label></div><div aria-hidden="true" class="desc b-acc" id="c-ac-7"><div class="p">Analytics cookies allow us to measure the performance of our website and our advertising campaigns. We use them to determine the number of visits and sources of visits to our website. We process the data obtained through these cookies in aggregate, without using identifiers that point to specific users of our website. If you disable the use of analytics cookies in relation to your visit, we lose the ability to analyse performance and optimise our measures.</div></div></div><div class="c-bl"><div class="title"><div aria-level="3" class="b-tl" role="heading">More information</div></div><div class="desc"><div class="p">For any queries in relation to our policy on cookies and your choices, please contact us.</div></div></div></div><div id="s-bns"><button class="c-bn" id="s-all-bn" type="button">Accept all</button><button class="c-bn" id="s-rall-bn" type="button">Accept necessary</button><button class="c-bn" id="s-sv-bn" type="button">Save settings</button></div></div></div></div></div></div><div id="cs-ov" style="visibility: hidden; opacity: 0;"></div></div></div><iframe allowfullscreen="true" allowtransparency="true" frameborder="0" id="rufous-sandbox" scrolling="no" style="position: absolute; visibility: hidden; display: none; width: 0px; height: 0px; padding: 0px; border-width: medium; border-style: none; border-color: currentcolor; border-image: initial;" title="Twitter analytics iframe"></iframe></body></html> |