<p dir="auto"><strong>Context:</strong></p>
<ul dir="auto">
<li>Playwright Version: 1.18.1</li>
<li>Operating System: Windows 10</li>
<li>Node.js Version: 16.13.2</li>
<li>Browser: Chromium</li>
</ul>
<p dir="auto"><strong>Issue</strong><br>
When running a test which imports a module from a different file which also contains a test, the test on the imported file is run <em>instead of</em> the test from the expected test file.</p>
<p dir="auto"><strong>Code</strong><br>
<em>package.json</em></p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;name&quot;: &quot;playwright-test-issue&quot;,
  &quot;version&quot;: &quot;1.0.0&quot;,
  &quot;description&quot;: &quot;&quot;,
  &quot;main&quot;: &quot;index.js&quot;,
  &quot;scripts&quot;: {
    &quot;test&quot;: &quot;npx playwright test&quot;
  },
  &quot;type&quot;: &quot;module&quot;,
  &quot;author&quot;: &quot;&quot;,
  &quot;license&quot;: &quot;ISC&quot;,
  &quot;devDependencies&quot;: {
    &quot;@playwright/test&quot;: &quot;^1.18.1&quot;
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"name"</span>: <span class="pl-s"><span class="pl-pds">"</span>playwright-test-issue<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>1.0.0<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"description"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
  <span class="pl-ent">"main"</span>: <span class="pl-s"><span class="pl-pds">"</span>index.js<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"scripts"</span>: {
    <span class="pl-ent">"test"</span>: <span class="pl-s"><span class="pl-pds">"</span>npx playwright test<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>module<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"author"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
  <span class="pl-ent">"license"</span>: <span class="pl-s"><span class="pl-pds">"</span>ISC<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"devDependencies"</span>: {
    <span class="pl-ent">"@playwright/test"</span>: <span class="pl-s"><span class="pl-pds">"</span>^1.18.1<span class="pl-pds">"</span></span>
  }
}</pre></div>
<p dir="auto"><em>test1.spec.js</em></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { test } from &quot;@playwright/test&quot;;

test(&quot;test 1&quot;, async ({page}) =&gt; {
	console.log(&quot;running test 1&quot;);
})

export function utilityFunction() {
	console.log(&quot;running utility function&quot;);
}"><pre class="notranslate"><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-k">from</span> <span class="pl-s">"@playwright/test"</span><span class="pl-kos">;</span>

<span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">"test 1"</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-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"running test 1"</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">function</span> <span class="pl-en">utilityFunction</span><span class="pl-kos">(</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 utility function"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><em>test2.spec.js</em></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { test } from &quot;@playwright/test&quot;;
import { utilityFunction } from &quot;./test1.spec.js&quot;;

test(&quot;test 2&quot;, async ({page}) =&gt; {
	utilityFunction();
	console.log(&quot;running test 2&quot;);
})"><pre class="notranslate"><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-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-s1">utilityFunction</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"./test1.spec.js"</span><span class="pl-kos">;</span>

<span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">"test 2"</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-en">utilityFunction</span><span class="pl-kos">(</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 test 2"</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>Output</strong><br>
Upon running the command <code class="notranslate">npm run test</code> we get the following output</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; playwright-test-issue@1.0.0 test
&gt; npx playwright test


Running 2 tests using 2 workers

  ok test1.spec.js:3:1 › test 1 (2s)
  ok test2.spec.js:4:1 › test 2 (2s) 
running test 1
running test 1

  2 passed (3s)"><pre class="notranslate"><code class="notranslate">&gt; playwright-test-issue@1.0.0 test
&gt; npx playwright test


Running 2 tests using 2 workers

  ok test1.spec.js:3:1 › test 1 (2s)
  ok test2.spec.js:4:1 › test 2 (2s) 
running test 1
running test 1

  2 passed (3s)
</code></pre></div>
<p dir="auto">It is clear that the output above is reporting that test2 has been run. If this was actually the case, we wouldn't see <code class="notranslate">running test 1</code> repeated twice in the output.</p>
<p dir="auto"><strong>Expected Output</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; playwright-test-issue@1.0.0 test
&gt; npx playwright test


Running 2 tests using 2 workers

  ok test1.spec.js:3:1 › test 1 (2s)
  ok test2.spec.js:4:1 › test 2 (2s) 
running test 1
running test 2
running utility function

  2 passed (3s)"><pre class="notranslate"><code class="notranslate">&gt; playwright-test-issue@1.0.0 test
&gt; npx playwright test


Running 2 tests using 2 workers

  ok test1.spec.js:3:1 › test 1 (2s)
  ok test2.spec.js:4:1 › test 2 (2s) 
running test 1
running test 2
running utility function

  2 passed (3s)
</code></pre></div>
<p dir="auto"><strong>Notes</strong><br>
I'm aware that this isn't exactly a good way to structure a project, and I was able to side-step this by refactoring utility functions into their own files which don't contain tests. My main issue here was that the incorrect reporting of which tests had been run made this difficult to diagnose.</p>
<p dir="auto">Apologies if this is a duplicate, I had a look and couldn't find anything like this.</p>
<p dir="auto">Also I appreciate all of the hard work you all do for this project, playwright is an absolute joy to work with and this is the only <em>issue</em> I've encountered in my whole time working with it.</p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.33, v1.34, v1.35]</li>
<li>Operating System: [Linux]</li>
<li>Browser: [Chromium]</li>
<li>Other info: Teamcity CI, Docker Wrapper via Node.js-Task</li>
</ul>
<p dir="auto"><strong>Description</strong><br>
Nearly all tests fail with in CI most of the time (running docker image playwright:v1.35.0-jammy, tried as well with 1.34 and 1.33).<br>
The Traces show a blank screen after 'page.goto' and the subsequent locator fails to find anything and times out.<br>
Sometimes (rarely) tests succeed on initial run or on the second or third retry.</p>
<p dir="auto">Testsuite is running perfectly fine locally in Windows via VSCode or in Docker (using the same image and parameters as the CI does).</p>
<p dir="auto">Unfortunately I was not able to reproduce the issue locally. Do you have on suggestions on how I could proceed to pinpoint the issue a little bit better?.</p>
<p dir="auto"><strong>Expected</strong><br>
Runs in Docker using the same docker-image and -parameters should work the same no matter whether they are run on a laptop or a build agent.</p>
<p dir="auto"><strong>Actual</strong><br>
Nearly all tests fail with in CI most of the time and Traces show a blank screen after 'page.goto' with subsequent locator fails to find anything.</p>
<h2 dir="auto">Possible relevant runtime information</h2>
<p dir="auto">docker.server.osType	linux<br>
docker.server.version	20.10.23<br>
docker.version	20.10.23<br>
teamcity.agent.hardware.cpuCount	4<br>
teamcity.agent.hardware.memorySizeMb	6949<br>
teamcity.agent.jvm.os.arch	amd64<br>
teamcity.agent.jvm.os.name	Linux<br>
teamcity.agent.jvm.os.version	5.4.0-147-generic<br>
system.teamcity.version	2022.10.3 (build 117072)</p>
<p dir="auto"><strong>script</strong><br>
npm install<br>
npx playwright test --update-snapshots</p>
<p dir="auto"><strong>docker-images used</strong><br>
playwright:v1.33.0-jammy<br>
playwright:v1.34.0-jammy<br>
playwright:v1.35.0-jammy</p>
<p dir="auto"><strong>additional docker parameter</strong><br>
--env DEBUG=pw:browser*,pw:api --network host -v %teamcity.build.checkoutDir%/zimdbvwgui:/work/ -w /work/</p>
<p dir="auto"><a href="https://github.com/microsoft/playwright/files/11768862/build-output.log">build-output.log</a></p>