<p dir="auto"><strong>Context:</strong></p>
<ul dir="auto">
<li>Playwright Version: 1.18.1</li>
</ul>
<p dir="auto">If you need to use extensions, there is no options to configure this behaviour for browser from launchOptions as in incognito mode browser removes all extensions.</p>
<p dir="auto">On one of our projects, we need to run tests with extensions. To launch extensions, we have to set <code class="notranslate">browserType.launchPersistentContext</code> in the <code class="notranslate">beforeAll</code> section of each test.</p>
<p dir="auto">It would be convenient to set <code class="notranslate">launchPersistentContext</code> in a <code class="notranslate">playwright.config</code> file, for instance:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    use: {
        launchPersistentContext: {
            userDataDir: '/tmp/test-user-data-dir',
            args: [
                `--disable-extensions-except=${path.join(__dirname, './my-extension')}`,
                `--load-extension=${path.join(__dirname, './my-extension')}`
            ]
        }
     }"><pre class="notranslate">    use: <span class="pl-kos">{</span>
        <span class="pl-c1">launchPersistentContext</span>: <span class="pl-kos">{</span>
            <span class="pl-c1">userDataDir</span>: <span class="pl-s">'/tmp/test-user-data-dir'</span><span class="pl-kos">,</span>
            <span class="pl-c1">args</span>: <span class="pl-kos">[</span>
                <span class="pl-s">`--disable-extensions-except=<span class="pl-s1"><span class="pl-kos">${</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">'./my-extension'</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">,</span>
                <span class="pl-s">`--load-extension=<span class="pl-s1"><span class="pl-kos">${</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">'./my-extension'</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></pre></div>