<p dir="auto">Let's say I ran</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npx playwright test --grep=@test"><pre class="notranslate"><code class="notranslate">npx playwright test --grep=@test
</code></pre></div>
<p dir="auto">Is there a way that I can programatically get names of all test files that are about to run, in e.g. <code class="notranslate">globalSetup</code>? Right now there's a way to do this with CLI</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npx playwright test --grep=@test --list"><pre class="notranslate"><code class="notranslate">npx playwright test --grep=@test --list
</code></pre></div>
<p dir="auto">But can I get this list in code, like from env variable or something?</p>
<p dir="auto">Since Playwright 1.19, the list of cases is now generated before the Global Setup (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1131426052" data-permission-text="Title is private" data-url="https://github.com/microsoft/playwright/issues/12018" data-hovercard-type="issue" data-hovercard-url="/microsoft/playwright/issues/12018/hovercard" href="https://github.com/microsoft/playwright/issues/12018">#12018</a> for more details).</p>
<p dir="auto">It would be great if we could expose root <code class="notranslate">Suite</code> to the global setup - containing exactly the tests to be run.</p>
<p dir="auto">This could be beneficial for use cases where we would like to run certain pre-conditions during global setup depending on the list of cases to be executed. For example: authentication setup being carried out only when cases that require it are slotted to be executed, otherwise do not authenticate.</p>