-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateTests.mjs
27 lines (21 loc) · 930 Bytes
/
generateTests.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {writeFileSync} from "node:fs";
const files = {
numberOfTests: 130, numberOfFiles: 5, distribution: [0.05, 0.1, 0.2, 0.3, 0.35]
};
const generateTests = () => {
let currentCase = 1;
for (let currentFile = 0; currentFile < files.numberOfFiles; currentFile++) {
const testsForShard = Math.floor(files.numberOfTests * files.distribution[currentFile]);
const tests = ["import {test, expect} from '@playwright/test';"]
tests.push(`test.describe('shard ${currentFile + 1}', () => {`);
for (let currentTest = 0; currentTest < testsForShard; currentTest++) {
tests.push(`test('test ${currentCase}', () => {`);
tests.push('expect(true).toBe(true);');
tests.push('});');
currentCase += 1;
}
tests.push('});');
writeFileSync(`./tests/shard${currentFile + 1}.spec.ts`, tests.join('\n'));
}
};
generateTests();