question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Best way to use playwright in parallel?

See original GitHub issue

Hi there!

I have an electron app that is doing a browser automation (navigation, form population, saving files, etc). The user can add a various of scripts in the “script store” and they will run in parallel.

Currently I am using mocha because it has parallel mode (since 8 version) and I am more familiar with it. I have a function like this:

function runMochaTest(pathToScript, reportFileName, callback) {
  const mocha = new Mocha({
    parallel: true,
    reporter: "xunit",
    reporterOptions: {
      output: `${exeDirectory}/../reports/${reportFileName}.xml`
    },
  });

  mocha.addFile(pathToScript);

  mocha.run(() => {
    callback();
  });
}

And a typical script is look like this:

const data = require('./somedata.json');

describe("parallel playwright execution via mocha 8.0", async function () {
  data.forEach(async function (product) {
    it(`parsing data for ${product}`, async function () {
      this.timeout(120000);
      const browser = await chromium.launch();
      const context = await browser.newContext({
        ignoreHTTPSErrors: true,
        viewport: null,
        httpCredentials: {
          username: credentials.username,
          password: credentials.password,
        },
      });

      const page = await context.newPage();
      await page.goto("http://website.com", { waitUntil: "load"});

     //... some data related stuff 

      await browser.close();
    });
  });
});

So far everything is working, but since I don’t need any mocha features beside the parallel execution and xml report, I want to explore other alternatives to what I am doing now.

So, my question is: What are the “best practices” to execute playwright in parallel? Are you using something like jest or other test runners?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nicoandmeecommented, Dec 18, 2020

Check out: https://github.com/agaricide/puppeteer-functional-patterns (although it is for puppeteer, still directly applicable)

0reactions
aslushnikovcommented, Dec 18, 2020

@MihailPertsev one other option to run Playwright in parallel would be our very own playwright-test which is in preview.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Answers to All The Top Questions For Playwright Testing
All the top answers to your favorite questions on the hottest new testing framework from Microsoft, Playwright.
Read more >
How to run playwright test parallel using TestNG - YouTube
In this video you will learn how to run Playwright tests parallel on multiple browsers by using TestNG suite xml file.
Read more >
Jest Sequential & Parallel Execution | Playwright - Part 20
Jest Sequential & Parallel ExecutionIn this video, we'll learn how to run a playwright test script in sequential and parallel.
Read more >
Parallel Execution of Scenarios and using different Browsers ...
NET app using Playwright ... from 2021-03-04 Topics of the stream: - parallel execution of Scenarios - use different Browsers for automation ...
Read more >
Playwright: Ensuring parallel tests run in their own rooms
Is there a better way to spread my tests across my chatrooms and still run them in parallel? typescript · jestjs · playwright...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found