Search code examples
playwright

Keep browser open for all tests in a test suite


The typical structure of my tests is as follows:

import {test} from '@playwright/test';

test.describe('suite', () => {
   test('test1', async ({page}) => {
      await page.goto('test1');
   }); 
   test('test2', async ({page}) => {
      await page.goto('test2');
   }); 
}); 

This works perfectly but I noticed that Playwright opens and closes the browser window for each test and was wondering, why the browser window cannot stay open for all tests and if this could/should be optimised?


Solution

  • Based on my feedback from a playwright contributor:

    • If you use the VSCode extension, the browser stays open: https://playwright.dev/docs/getting-started-vscode
    • You want to ensure full test isolation on your CI, what Playwright does is guarantee that so no tests will interfere with each other. (less reasons to flake)