<p dir="auto">Referring the documentation provided by playwright, seems like the hooks (example: afterAll / beforeAll) can be used only inside a spec/ test file as below:</p>
<p dir="auto">// example.spec.ts<br>
import { test, expect } from '@playwright/test';</p>
<p dir="auto">test.beforeAll(async () =&gt; {<br>
console.log('Before tests');<br>
});</p>
<p dir="auto">test.afterAll(async () =&gt; {<br>
console.log('After tests');<br>
});</p>
<p dir="auto">test('my test', async ({ page }) =&gt; {<br>
// ...<br>
});</p>
<p dir="auto">My question: is there any support where there can be only one AfterAll() or beforeAll() hook  in one single file which will be called for every test files ? the piece of code that i want to have inside the afterAll and beforeAll is common for all the test/ specs files and i dont want to have the same duplicated in all the spec files/ test file.<br>
Any suggestion or thoughts on this?</p>
<p dir="auto">TIA<br>
Allen</p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.32.3]</li>
<li>Operating System: [All, Windows] I only has Windows</li>
<li>Browser: [Chromium, Firefox]</li>
</ul>
<p dir="auto">Page Visibility API :  <a href="https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API</a></p>
<p dir="auto"><strong>Steps</strong></p>
<ul dir="auto">
<li>Start a test and wait for the browser opens (let the test wait log, we need do following steps manually )</li>
<li>open inspect/'dev tool' in a tab</li>
<li>In console panel run the following script</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="document.addEventListener(&quot;visibilitychange&quot;, () =&gt; {
 console.log('visibilitychange  work', document.visibilityState === 'visible')
}); "><pre class="notranslate"><code class="notranslate">document.addEventListener("visibilitychange", () =&gt; {
 console.log('visibilitychange  work', document.visibilityState === 'visible')
}); 
</code></pre></div>
<ul dir="auto">
<li>open another new tab --just open it manually</li>
<li>switch to the previous tab and watch the console log</li>
</ul>
<p dir="auto"><strong>Expected</strong><br>
We can see the console log:<br>
"visibilitychange  work false"<br>
"visibilitychange  work true"</p>
<p dir="auto"><strong>Actual</strong><br>
There is not such log. looks 'visibilitychange' event never triggered</p>
<p dir="auto">Note: open the browser(Chromium) manually , Page Visibility API works OK.<br>
But when running in test env, Page Visibility API does not work OK.</p>