<p dir="auto">In UI<br>
<a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/72373858/238871572-c3b3b6ff-56c5-43d3-9161-5ab927761554.png"><img src="https://user-images.githubusercontent.com/72373858/238871572-c3b3b6ff-56c5-43d3-9161-5ab927761554.png" alt="obraz" style="max-width: 100%;"></a><br>
In runner it is OK:<br>
<a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/72373858/238868691-8f0fdd0b-1877-4be6-ba80-7a953e178540.png"><img src="https://user-images.githubusercontent.com/72373858/238868691-8f0fdd0b-1877-4be6-ba80-7a953e178540.png" alt="obraz" style="max-width: 100%;"></a></p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.33.0]</li>
<li>Operating System: [Windows 11]</li>
<li>Browser: [Chromium]</li>
<li>Other info:
<ul dir="auto">
<li>Base on default code after running 'npx init playwright@latest'</li>
<li>VSC extension: Playwright Test for VSCode v1.0.11</li>
<li>VSC: 1.78.2</li>
</ul>
</li>
</ul>
<h3 dir="auto">Source code</h3>
<ul dir="auto">
<li>[ x ] I provided exact source code that allows reproducing the issue locally.</li>
</ul>




<p dir="auto">File structure (base on defaults provided by running: <code class="notranslate">npm init playwright@latest</code>)<br>
<a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/72373858/238869591-cfd08feb-fd6b-44b2-85b9-556d52de9e88.png"><img src="https://user-images.githubusercontent.com/72373858/238869591-cfd08feb-fd6b-44b2-85b9-556d52de9e88.png" alt="obraz" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Config file</strong><br>
Added to default config: <code class="notranslate">baseUrl</code>, and <code class="notranslate">projects</code> with session</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';
import path from &quot;path&quot;;

export const STORAGE_STATE = path.join(__dirname, &quot;session.json&quot;);
export default defineConfig({
  testDir: &quot;./tests&quot;,
  globalSetup: &quot;global-setup.ts&quot;,
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  reporter: &quot;html&quot;,
  use: {
    trace: &quot;on-first-retry&quot;,
    baseURL: &quot;https://demo-bank.vercel.app&quot;,
  },
  projects: [
    {
      name: &quot;setup-project&quot;,
      testMatch: &quot;**/*.setup.ts&quot;,
    },
    {
      name: &quot;authenticated tests&quot;,
      testMatch: &quot;**/*example.spec.ts&quot;,
      dependencies: [&quot;setup-project&quot;],
      use: {
        storageState: STORAGE_STATE,
      },
    },
  ],
});
"><pre class="notranslate"><span class="pl-c">// playwright.config.ts</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">defineConfig</span><span class="pl-kos">,</span> <span class="pl-s1">devices</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'@playwright/test'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">path</span> <span class="pl-k">from</span> <span class="pl-s">"path"</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-c1">STORAGE_STATE</span> <span class="pl-c1">=</span> <span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">join</span><span class="pl-kos">(</span><span class="pl-s1">__dirname</span><span class="pl-kos">,</span> <span class="pl-s">"session.json"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-en">defineConfig</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">testDir</span>: <span class="pl-s">"./tests"</span><span class="pl-kos">,</span>
  <span class="pl-c1">globalSetup</span>: <span class="pl-s">"global-setup.ts"</span><span class="pl-kos">,</span>
  <span class="pl-c1">fullyParallel</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
  <span class="pl-c1">forbidOnly</span>: <span class="pl-c1">!</span><span class="pl-c1">!</span><span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">env</span><span class="pl-kos">.</span><span class="pl-c1">CI</span><span class="pl-kos">,</span>
  <span class="pl-c1">retries</span>: <span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">env</span><span class="pl-kos">.</span><span class="pl-c1">CI</span> ? <span class="pl-c1">2</span> : <span class="pl-c1">0</span><span class="pl-kos">,</span>
  <span class="pl-c1">workers</span>: <span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">env</span><span class="pl-kos">.</span><span class="pl-c1">CI</span> ? <span class="pl-c1">1</span> : <span class="pl-c1">undefined</span><span class="pl-kos">,</span>
  <span class="pl-c1">reporter</span>: <span class="pl-s">"html"</span><span class="pl-kos">,</span>
  <span class="pl-c1">use</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">trace</span>: <span class="pl-s">"on-first-retry"</span><span class="pl-kos">,</span>
    <span class="pl-c1">baseURL</span>: <span class="pl-s">"https://demo-bank.vercel.app"</span><span class="pl-kos">,</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-c1">projects</span>: <span class="pl-kos">[</span>
    <span class="pl-kos">{</span>
      <span class="pl-c1">name</span>: <span class="pl-s">"setup-project"</span><span class="pl-kos">,</span>
      <span class="pl-c1">testMatch</span>: <span class="pl-s">"**/*.setup.ts"</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">{</span>
      <span class="pl-c1">name</span>: <span class="pl-s">"authenticated tests"</span><span class="pl-kos">,</span>
      <span class="pl-c1">testMatch</span>: <span class="pl-s">"**/*example.spec.ts"</span><span class="pl-kos">,</span>
      <span class="pl-c1">dependencies</span>: <span class="pl-kos">[</span><span class="pl-s">"setup-project"</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
      <span class="pl-c1">use</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">storageState</span>: <span class="pl-c1">STORAGE_STATE</span><span class="pl-kos">,</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-kos">]</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">IMPORTANT: Global setup for clearing session to avoid false positives</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//global-setup.ts
import fs from &quot;fs&quot;;
import { STORAGE_STATE } from &quot;./playwright.config&quot;;

async function globalSetup() {
  // Remove session
  if (fs.existsSync(STORAGE_STATE)) {
    fs.unlinkSync(STORAGE_STATE);
  }
}

export default globalSetup;
"><pre class="notranslate"><span class="pl-c">//global-setup.ts</span>
<span class="pl-k">import</span> <span class="pl-s1">fs</span> <span class="pl-k">from</span> <span class="pl-s">"fs"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-c1">STORAGE_STATE</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"./playwright.config"</span><span class="pl-kos">;</span>

<span class="pl-k">async</span> <span class="pl-k">function</span> <span class="pl-en">globalSetup</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-c">// Remove session</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">fs</span><span class="pl-kos">.</span><span class="pl-en">existsSync</span><span class="pl-kos">(</span><span class="pl-c1">STORAGE_STATE</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">fs</span><span class="pl-kos">.</span><span class="pl-en">unlinkSync</span><span class="pl-kos">(</span><span class="pl-c1">STORAGE_STATE</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-s1">globalSetup</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Test file (self-contained)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//login.setup.ts
import { test as setup, expect } from &quot;@playwright/test&quot;;
import { STORAGE_STATE } from &quot;../playwright.config&quot;;

setup(&quot;successful login with correct credentials&quot;, async ({ page }) =&gt; {
    await page.goto(&quot;/&quot;);
    console.log(&quot;Running setup: successful login with correct credentials...&quot;);
    await page.getByTestId(&quot;login-input&quot;).fill('testerxx');
    await page.getByTestId(&quot;password-input&quot;).fill('12345678');
    await page.getByTestId(&quot;login-button&quot;).click();

    await expect(page.getByTestId(&quot;user-name&quot;)).toHaveText(&quot;Jan Demobankowy&quot;);

    await page.context().storageState({ path: STORAGE_STATE });
});
"><pre class="notranslate"><span class="pl-c">//login.setup.ts</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">test</span> <span class="pl-k">as</span> <span class="pl-s1">setup</span><span class="pl-kos">,</span> <span class="pl-s1">expect</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"@playwright/test"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-c1">STORAGE_STATE</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"../playwright.config"</span><span class="pl-kos">;</span>

<span class="pl-en">setup</span><span class="pl-kos">(</span><span class="pl-s">"successful login with correct credentials"</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> page <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">goto</span><span class="pl-kos">(</span><span class="pl-s">"/"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"Running setup: successful login with correct credentials..."</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">getByTestId</span><span class="pl-kos">(</span><span class="pl-s">"login-input"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">fill</span><span class="pl-kos">(</span><span class="pl-s">'testerxx'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">getByTestId</span><span class="pl-kos">(</span><span class="pl-s">"password-input"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">fill</span><span class="pl-kos">(</span><span class="pl-s">'12345678'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">getByTestId</span><span class="pl-kos">(</span><span class="pl-s">"login-button"</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">click</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">await</span> <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">getByTestId</span><span class="pl-kos">(</span><span class="pl-s">"user-name"</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toHaveText</span><span class="pl-kos">(</span><span class="pl-s">"Jan Demobankowy"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">context</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">storageState</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">path</span>: <span class="pl-c1">STORAGE_STATE</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//example.spec.ts
import { test, expect } from &quot;@playwright/test&quot;;

test.describe(&quot;Logged test&quot;, () =&gt; {

  test(&quot;mock bank panel @logged&quot;, async ({ page }) =&gt; {
    await page.goto(&quot;/pulpit.html&quot;);
    await expect(page.getByTestId(&quot;user-name&quot;)).toHaveText(&quot;Jan Demobankowy&quot;);
  });
});"><pre class="notranslate"><span class="pl-c">//example.spec.ts</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">test</span><span class="pl-kos">,</span> <span class="pl-s1">expect</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"@playwright/test"</span><span class="pl-kos">;</span>

<span class="pl-s1">test</span><span class="pl-kos">.</span><span class="pl-en">describe</span><span class="pl-kos">(</span><span class="pl-s">"Logged test"</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>

  <span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">"mock bank panel @logged"</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> page <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">goto</span><span class="pl-kos">(</span><span class="pl-s">"/pulpit.html"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">getByTestId</span><span class="pl-kos">(</span><span class="pl-s">"user-name"</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toHaveText</span><span class="pl-kos">(</span><span class="pl-s">"Jan Demobankowy"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Steps</strong></p>
<ul dir="auto">
<li>npx playwright test --ui</li>
<li>try run test what contain dependencies</li>
</ul>
<p dir="auto"><strong>Expected</strong><br>
Test and it's dependencies run successfully</p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">Test fail, dependencies not run before test</p>
<p dir="auto">Running playwright test with a test that have a dependency. For example the below snippet will run the <code class="notranslate">setup</code> dependency when running <code class="notranslate">npx playwright test</code>. In UI mode I would reasonably expect the same - in that when running a test that has a dependency it would run the dependency first and then run the test. This is currently not the case.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="      name: 'loggedIn',
      use: {
        ...devices['Desktop Chrome'],
        storageState: STORAGE_STATE,
      },
      testIgnore: ['**/*login.spec.ts', '**/*.setup.ts'],
      dependencies: ['setup'],
    },```"><pre lang="{" class="notranslate"><code class="notranslate">      name: 'loggedIn',
      use: {
        ...devices['Desktop Chrome'],
        storageState: STORAGE_STATE,
      },
      testIgnore: ['**/*login.spec.ts', '**/*.setup.ts'],
      dependencies: ['setup'],
    },```
</code></pre></div>