<p dir="auto">We are currently using Jest for running playwright test cases. So this code is working perfectly fine for us:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { runCLI } from &quot;jest&quot;;
 const { results } = await runCLI(
      {
        $0: &quot;&quot;,
        config: jestConfigPath,
        ...options,
        _: testNamePatterns,
      },
      [integrationTestsPackagePath]
    );
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">runCLI</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"jest"</span><span class="pl-kos">;</span>
 <span class="pl-k">const</span> <span class="pl-kos">{</span> results <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-en">runCLI</span><span class="pl-kos">(</span>
      <span class="pl-kos">{</span>
        <span class="pl-c1">$0</span>: <span class="pl-s">""</span><span class="pl-kos">,</span>
        <span class="pl-c1">config</span>: <span class="pl-s1">jestConfigPath</span><span class="pl-kos">,</span>
        ...<span class="pl-s1">options</span><span class="pl-kos">,</span>
        <span class="pl-c1">_</span>: <span class="pl-s1">testNamePatterns</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">integrationTestsPackagePath</span><span class="pl-kos">]</span>
    <span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">We are getting test results and we can decide the next steps for test run.<br>
We would like to switch to playwright-test-runner.<br>
We would like to create playwright.config.ts on runtime and then run playwright tests cases using similar command above for playwright test runner.</p>
<p dir="auto">What we want is to somehow expose this line of code (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="533619789" data-permission-text="Title is private" data-url="https://github.com/microsoft/playwright/issues/154" data-hovercard-type="pull_request" data-hovercard-url="/microsoft/playwright/pull/154/hovercard" href="https://github.com/microsoft/playwright/pull/154">#154</a>):</p>
<p dir="auto">const result = await runner.run(!!opts.list, filePatternFilters, opts.project || undefined);</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/microsoft/playwright/blob/eafba43e15bcca8d10da30bc7c53d4092bb2374a/src/test/cli.ts#L154">playwright/src/test/cli.ts</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 154
      in
      <a data-pjax="true" class="commit-tease-sha" href="/microsoft/playwright/commit/eafba43e15bcca8d10da30bc7c53d4092bb2374a">eafba43</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L154" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="154"></td>
          <td id="LC154" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">async</span> <span class="pl-k">function</span> <span class="pl-en">runTests</span><span class="pl-kos">(</span><span class="pl-s1">args</span>: <span class="pl-smi">string</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-s1">opts</span>: <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">key</span>: <span class="pl-smi">string</span><span class="pl-kos">]</span>: <span class="pl-smi">any</span> <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/12835833/133660151-7372ed16-cb8f-4f12-9e78-4be0720fadac.png"><img src="https://user-images.githubusercontent.com/12835833/133660151-7372ed16-cb8f-4f12-9e78-4be0720fadac.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">This function should be exposed so that we can consume it in our Typescript code to run playwright test cases using playwright test runner.</p>
<p dir="auto">We're currently using jest as a test runner for testing angular applications using playwright. In the angular ecosystem tools usually integrate with the <code class="notranslate">@angular/cli</code> by providing a builder, so our <code class="notranslate">@ngx-playwright/jest</code> package is actually what powers the <code class="notranslate">ng e2e</code> command in our repositories.</p>
<p dir="auto">It would be great if we could write such an integration for the <code class="notranslate">@playwright/test</code> runner as well, but that'd require access to the runner APIs.<br>
While it would be possible to execute the playwright CLI in a new process, this would make certain integrations harder or hacky. For instance passing configuration from the angular.json into the test runner would require turning those into CLI arguments and passing the base URL the angular app is hosted at into the runner would require a workaround using the child process's environment to pass this along.</p>