I am trying to run Parametrized Playwright tests created with Node.js in Parallel.
SRC: https://playwright.dev/docs/test-parameterize
SRC: https://playwright.dev/docs/test-parallel
However, when I combine the two, the test cases run sequentially. Can the parametrised tests be executed in parallel in Playwright (Node.js)?
import fs from 'fs';
import path from 'path';
import { test } from '@playwright/test';
import { parse } from 'csv-parse/sync';
const records = parse(fs.readFileSync(path.join(__dirname,
'input.csv')), {
columns: true,
skip_empty_lines: true
});
for (const record of records) {
test(`foo: ${record.test_case}`, async ({ page }) => {
console.log(record.test_case, record.some_value,
record.some_other_value);
// Test Case Goes Here.
});
}
As default, tests in a single file are run sequentially (source). Add this line to your playwright.config to achieve parallell run of same file tests:
Demonstrated by doing the following:
When
fullyParallellis true, all 3 tests are ran in parallell (identical timestamp). Remember to set number ofworkers> 1 in config file. My current config file: