[Question] Best way to use playwright in parallel?
See original GitHub issueHi 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:
- Created 3 years ago
- Comments:12 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Check out: https://github.com/agaricide/puppeteer-functional-patterns (although it is for puppeteer, still directly applicable)
@MihailPertsev one other option to run Playwright in parallel would be our very own playwright-test which is in preview.