<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.35.1]</li>
<li>Operating System: [All]</li>
<li>Browser: [All]</li>
</ul>
<h3 dir="auto">Source code</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I provided exact source code that allows reproducing the issue locally.</li>
</ul>




<p dir="auto"><a href="https://github.com/edumserrano/playwright-bug-reuse-existing-server">Link to the GitHub repository with the repro</a></p>
<p dir="auto"><strong>Steps</strong></p>
<ol dir="auto">
<li>Clone this repo and using your shell of choice navigate to the root of the repo.</li>
<li>Execute <code class="notranslate">npm start</code>. This will build and run an angular app.</li>
<li>Once the angular app is running, execute <code class="notranslate">npm test</code></li>
</ol>
<p dir="auto">When running with node <code class="notranslate">16.19.1</code> the output after <code class="notranslate">step 3</code> is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; demo-app@0.0.0 test
&gt; npx playwright test


Running 1 test using 1 worker

  ✓  1 [chromium] › example.spec.ts:3:5 › dummy test (1.8s)

  1 passed (2.6s)"><pre class="notranslate"><code class="notranslate">&gt; demo-app@0.0.0 test
&gt; npx playwright test


Running 1 test using 1 worker

  ✓  1 [chromium] › example.spec.ts:3:5 › dummy test (1.8s)

  1 passed (2.6s)
</code></pre></div>
<p dir="auto">When running with node <code class="notranslate">18.16.0</code> the output after <code class="notranslate">step 3</code> is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; demo-app@0.0.0 test
&gt; npx playwright test

[WebServer] ? Port 4200 is already in use.
Would you like to use a different port? (Y/n) [WebServer]
Error: Timed out waiting 30000ms from config.webServer."><pre class="notranslate"><code class="notranslate">&gt; demo-app@0.0.0 test
&gt; npx playwright test

[WebServer] ? Port 4200 is already in use.
Would you like to use a different port? (Y/n) [WebServer]
Error: Timed out waiting 30000ms from config.webServer.
</code></pre></div>
<p dir="auto">As you can see, it tries to execute the <code class="notranslate">webServer.command</code> and then eventually times out because the port is already taken.</p>
<p dir="auto"><strong>Expected</strong></p>
<p dir="auto">When running on node <code class="notranslate">18.16.0</code> it should NOT try to execute the <code class="notranslate">webServer.command</code> when <code class="notranslate">webServer.reuseExistingServer</code> is set to true.</p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">When running on node <code class="notranslate">18.16.0</code> it executes the <code class="notranslate">webServer.command</code> when <code class="notranslate">webServer.reuseExistingServer</code> is set to true.</p>
<h3 dir="auto">Other</h3>
<p dir="auto">I used <a href="https://github.com/nvm-sh/nvm">nvm</a> to swap between node versions whilst testing this.</p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v8.17.0]</li>
<li>Operating System: Windows 10 Pro</li>
<li>Browser:  Chromium</li>
<li>Other info:</li>
</ul>
<h3 dir="auto">Source code</h3>
<p dir="auto">Due to security aspects i cannot share the company code. I would appreciate any help you can provide with out reproducing the problem on your computer. when i run the test either by debug either by run test i see that every step passes succefuly. In the terminal i see it writes test passes. but then it reruns the test again as if it failed. and also in the final report it writes failed.<br>
I am attaching the test code - u will not be able to run it locally but maybe it could help.</p>
<p dir="auto">also I have 30 tests it HAPPENS ONLY in this test. al the rest are fine. this is not the only test that run with for<br>
(const hotelSupplier of hotelSupplierList)</p>
<p dir="auto">TEST CODE</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const test = require('../testFixtures/fixture')
const fs = require('fs')
const testDataLogic = JSON.parse(fs.readFileSync('./data/homePageLogicData.json', 'utf-8'))
const { parse } = require('csv-parse/sync')
const hotelSupplierList = parse(fs.readFileSync('./data/hotelSupplierForHotelQouteTest.csv'), {
  columns: true,
  skip_empty_lines: true
})

test.beforeEach(async ({ homePageLogic }, testInfo) =&gt; {
  console.log(`Running ${testInfo.title}`)
  await homePageLogic.openApp()
})

test.afterEach(async ({ page }, testInfo) =&gt; {
  console.log(`Finished ${testInfo.title} with status ${testInfo.status}`)

  if (testInfo.status !== testInfo.expectedStatus) { console.log(`Did not run as expected, ended up at ${page.url()}`) }
})


for (const hotelSupplier of hotelSupplierList) {
  test.setTimeout(320000)
  test(`Produce Hotel Quetaion and validate quotaion Arrives To Mail ${hotelSupplier.HotelSupplierName}`, async ({ homePageLogic, emailHelperPage }) =&gt; {
    await test.step('Create Trip and add PaxTo Trip', async () =&gt; {
      await homePageLogic.createNewTrip()
      await homePageLogic.addPaxToTripByID(testDataLogic.paxidKarimAbdul)
      await homePageLogic.validatePaxIDVisibleInTrip(testDataLogic.paxidKarimAbdul)
    })

    await test.step('search Hotel + choose Hotel + add qoute to cart + send mail ', async () =&gt; {
      await homePageLogic.pressOnHotelSearchButton()
      await homePageLogic.searchHotel(testDataLogic.destinationCity, '', hotelSupplier.HotelSupplierName)
      await homePageLogic.selectHotelFirstResult()
      await homePageLogic.addToQouteAndSendByMail()
    })

    await test.step('go to gmail verify email was recived with the subject hotel quote', async () =&gt; {
      const emailReturned = await emailHelperPage.returnMail('helpers/credentialsAmsalemMail.json', 'helpers/tokenAmsalemMail.json', testDataLogic.AgentRobotestEmailBox, 'Quote for: ' + testDataLogic.KarimAbdulFullName)
      await emailHelperPage.validateMailWasFound(emailReturned)
    })
  })
}"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">test</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'../testFixtures/fixture'</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-s1">fs</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'fs'</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-s1">testDataLogic</span> <span class="pl-c1">=</span> <span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">parse</span><span class="pl-kos">(</span><span class="pl-s1">fs</span><span class="pl-kos">.</span><span class="pl-en">readFileSync</span><span class="pl-kos">(</span><span class="pl-s">'./data/homePageLogicData.json'</span><span class="pl-kos">,</span> <span class="pl-s">'utf-8'</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-kos">{</span> parse <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'csv-parse/sync'</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-s1">hotelSupplierList</span> <span class="pl-c1">=</span> <span class="pl-en">parse</span><span class="pl-kos">(</span><span class="pl-s1">fs</span><span class="pl-kos">.</span><span class="pl-en">readFileSync</span><span class="pl-kos">(</span><span class="pl-s">'./data/hotelSupplierForHotelQouteTest.csv'</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-c1">columns</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
  <span class="pl-c1">skip_empty_lines</span>: <span class="pl-c1">true</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span>

<span class="pl-s1">test</span><span class="pl-kos">.</span><span class="pl-en">beforeEach</span><span class="pl-kos">(</span><span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> homePageLogic <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-s1">testInfo</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 <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">testInfo</span><span class="pl-kos">.</span><span class="pl-c1">title</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">)</span>
  <span class="pl-k">await</span> <span class="pl-s1">homePageLogic</span><span class="pl-kos">.</span><span class="pl-en">openApp</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span>

<span class="pl-s1">test</span><span class="pl-kos">.</span><span class="pl-en">afterEach</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-s1">testInfo</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">`Finished <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">testInfo</span><span class="pl-kos">.</span><span class="pl-c1">title</span><span class="pl-kos">}</span></span> with status <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">testInfo</span><span class="pl-kos">.</span><span class="pl-c1">status</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">)</span>

  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">testInfo</span><span class="pl-kos">.</span><span class="pl-c1">status</span> <span class="pl-c1">!==</span> <span class="pl-s1">testInfo</span><span class="pl-kos">.</span><span class="pl-c1">expectedStatus</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">`Did not run as expected, ended up at <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">url</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>`</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">for</span> <span class="pl-kos">(</span><span class="pl-k">const</span> <span class="pl-s1">hotelSupplier</span> <span class="pl-k">of</span> <span class="pl-s1">hotelSupplierList</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-s1">test</span><span class="pl-kos">.</span><span class="pl-en">setTimeout</span><span class="pl-kos">(</span><span class="pl-c1">320000</span><span class="pl-kos">)</span>
  <span class="pl-s1">test</span><span class="pl-kos">(</span><span class="pl-s">`Produce Hotel Quetaion and validate quotaion Arrives To Mail <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">hotelSupplier</span><span class="pl-kos">.</span><span class="pl-c1">HotelSupplierName</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> homePageLogic<span class="pl-kos">,</span> emailHelperPage <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">test</span><span class="pl-kos">.</span><span class="pl-en">step</span><span class="pl-kos">(</span><span class="pl-s">'Create Trip and add PaxTo Trip'</span><span class="pl-kos">,</span> <span class="pl-k">async</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-k">await</span> <span class="pl-s1">homePageLogic</span><span class="pl-kos">.</span><span class="pl-en">createNewTrip</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
      <span class="pl-k">await</span> <span class="pl-s1">homePageLogic</span><span class="pl-kos">.</span><span class="pl-en">addPaxToTripByID</span><span class="pl-kos">(</span><span class="pl-s1">testDataLogic</span><span class="pl-kos">.</span><span class="pl-c1">paxidKarimAbdul</span><span class="pl-kos">)</span>
      <span class="pl-k">await</span> <span class="pl-s1">homePageLogic</span><span class="pl-kos">.</span><span class="pl-en">validatePaxIDVisibleInTrip</span><span class="pl-kos">(</span><span class="pl-s1">testDataLogic</span><span class="pl-kos">.</span><span class="pl-c1">paxidKarimAbdul</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-s1">test</span><span class="pl-kos">.</span><span class="pl-en">step</span><span class="pl-kos">(</span><span class="pl-s">'search Hotel + choose Hotel + add qoute to cart + send mail '</span><span class="pl-kos">,</span> <span class="pl-k">async</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-k">await</span> <span class="pl-s1">homePageLogic</span><span class="pl-kos">.</span><span class="pl-en">pressOnHotelSearchButton</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
      <span class="pl-k">await</span> <span class="pl-s1">homePageLogic</span><span class="pl-kos">.</span><span class="pl-en">searchHotel</span><span class="pl-kos">(</span><span class="pl-s1">testDataLogic</span><span class="pl-kos">.</span><span class="pl-c1">destinationCity</span><span class="pl-kos">,</span> <span class="pl-s">''</span><span class="pl-kos">,</span> <span class="pl-s1">hotelSupplier</span><span class="pl-kos">.</span><span class="pl-c1">HotelSupplierName</span><span class="pl-kos">)</span>
      <span class="pl-k">await</span> <span class="pl-s1">homePageLogic</span><span class="pl-kos">.</span><span class="pl-en">selectHotelFirstResult</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
      <span class="pl-k">await</span> <span class="pl-s1">homePageLogic</span><span class="pl-kos">.</span><span class="pl-en">addToQouteAndSendByMail</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">await</span> <span class="pl-s1">test</span><span class="pl-kos">.</span><span class="pl-en">step</span><span class="pl-kos">(</span><span class="pl-s">'go to gmail verify email was recived with the subject hotel quote'</span><span class="pl-kos">,</span> <span class="pl-k">async</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-k">const</span> <span class="pl-s1">emailReturned</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">emailHelperPage</span><span class="pl-kos">.</span><span class="pl-en">returnMail</span><span class="pl-kos">(</span><span class="pl-s">'helpers/credentialsAmsalemMail.json'</span><span class="pl-kos">,</span> <span class="pl-s">'helpers/tokenAmsalemMail.json'</span><span class="pl-kos">,</span> <span class="pl-s1">testDataLogic</span><span class="pl-kos">.</span><span class="pl-c1">AgentRobotestEmailBox</span><span class="pl-kos">,</span> <span class="pl-s">'Quote for: '</span> <span class="pl-c1">+</span> <span class="pl-s1">testDataLogic</span><span class="pl-kos">.</span><span class="pl-c1">KarimAbdulFullName</span><span class="pl-kos">)</span>
      <span class="pl-k">await</span> <span class="pl-s1">emailHelperPage</span><span class="pl-kos">.</span><span class="pl-en">validateMailWasFound</span><span class="pl-kos">(</span><span class="pl-s1">emailReturned</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">playwright.config.js file</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const config = {
  reporter: 'list',
  retries: 1,
  workers: 3,
  timeout: 150000,
  fullyParallel: true,
  use: {
    video: 'retain-on-failure',
    screenshot: 'only-on-failure',
    browserName: 'chromium',
    headless: false,
    viewport: { width: 1100, height: 850 }
  },
  expect: {
    timeout: 4000
  }
}

module.exports = config"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">config</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">reporter</span>: <span class="pl-s">'list'</span><span class="pl-kos">,</span>
  <span class="pl-c1">retries</span>: <span class="pl-c1">1</span><span class="pl-kos">,</span>
  <span class="pl-c1">workers</span>: <span class="pl-c1">3</span><span class="pl-kos">,</span>
  <span class="pl-c1">timeout</span>: <span class="pl-c1">150000</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">use</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">video</span>: <span class="pl-s">'retain-on-failure'</span><span class="pl-kos">,</span>
    <span class="pl-c1">screenshot</span>: <span class="pl-s">'only-on-failure'</span><span class="pl-kos">,</span>
    <span class="pl-c1">browserName</span>: <span class="pl-s">'chromium'</span><span class="pl-kos">,</span>
    <span class="pl-c1">headless</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
    <span class="pl-c1">viewport</span>: <span class="pl-kos">{</span> <span class="pl-c1">width</span>: <span class="pl-c1">1100</span><span class="pl-kos">,</span> <span class="pl-c1">height</span>: <span class="pl-c1">850</span> <span class="pl-kos">}</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-c1">expect</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">timeout</span>: <span class="pl-c1">4000</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-s1">config</span></pre></div>
<p dir="auto"><strong>Steps</strong><br>
run the test</p>
<p dir="auto"><strong>Expected</strong></p>
<p dir="auto">in the terminal it will be written test passed and test wont rerun again as if failed.</p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">in the terminal --&gt; "test passed"  but it  reruns again and in the end it marked as failed<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/114003622/236122152-00b66638-75e2-4770-8111-6c4db2de25b7.png"><img src="https://user-images.githubusercontent.com/114003622/236122152-00b66638-75e2-4770-8111-6c4db2de25b7.png" alt="image" style="max-width: 100%;"></a></p>