Playwright: Not a bug, but a question. Can we run tests in parallel?

Created on 24 Jan 2020  路  5Comments  路  Source: microsoft/playwright

Thanks for the amazing tool (it's amazing so far!) I have a quick question though. Say I write a test and I want to run the same test against Chrome and Firefox, can we run same tests in parallel against different browsers?

Most helpful comment

Yes, although you will have to write a bit of scaffolding today.

const {chromium, firefox} = require('playwright');
(async function() {
  console.log('starting firefox and chromium tests.');
  await Promise.all([
      test(firefox),
      test(chromium)
    ]);
  console.log('done');
})();

async function test(launcher) {
    const browser = await launcher.launch();
    // run your test with the browser
    await browser.close();
}

All 5 comments

Yes, although you will have to write a bit of scaffolding today.

const {chromium, firefox} = require('playwright');
(async function() {
  console.log('starting firefox and chromium tests.');
  await Promise.all([
      test(firefox),
      test(chromium)
    ]);
  console.log('done');
})();

async function test(launcher) {
    const browser = await launcher.launch();
    // run your test with the browser
    await browser.close();
}

Yes, although you will have to write a bit of scaffolding today.

const {chromium, firefox} = require('playwright');
(async function() {
  console.log('starting firefox and chromium tests.');
  await Promise.all([
      test(firefox),
      test(chromium)
    ]);
  console.log('done');
})();

async function test(launcher) {
    const browser = await launcher.launch();
    // run your test with the browser
    await browser.close();
}

Thanks @JoelEinbinder , will give it a try. Is there a plan to have built in within playwright?

My thought is that this is a job for a test runner, like jest or mocha. We definitely want a good story around it to exist, but haven't started to look at it yet.

@rightqa JFYI we added remote parallel Playwright test execution support on the remote side in recent release of Moon. It was initially running Selenium tests in parallel in Kubernetes cluster, but is now able to do the same with Playwright. Documentation about it is here: https://aerokube.com/moon/latest/#_using_playwright It is a free solution up to 4 parallel browsers, but requires a license if you need more. We also have plans to deliver the same in our open-source solution called Selenoid.

Thanks @vania-pooh , will take a look.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JoelEinbinder picture JoelEinbinder  路  4Comments

kblok picture kblok  路  3Comments

saltyshiomix picture saltyshiomix  路  3Comments

KevinGrandon picture KevinGrandon  路  4Comments

jperl picture jperl  路  3Comments