lint
This commit is contained in:
parent
47fc364be7
commit
b567bc9be5
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { JSONReport, JSONReportSuite, JSONReportTestResult } from 'packages/playwright-test/reporter';
|
||||
import type { JSONReport, JSONReportSuite } from 'packages/playwright-test/reporter';
|
||||
import type { Suite, TestCase } from '../common/test';
|
||||
|
||||
export type TestGroup = {
|
||||
|
|
@ -29,7 +29,7 @@ type testDetails = {
|
|||
id: string,
|
||||
name: string,
|
||||
duration: number
|
||||
}
|
||||
};
|
||||
|
||||
export function createTestGroups(projectSuite: Suite, workers: number): TestGroup[] {
|
||||
// This function groups tests that can be run together.
|
||||
|
|
@ -180,7 +180,7 @@ export function filterForShardFromTimingFile(timingFile: JSONReport, shard: { to
|
|||
recordedTests.forEach(group => result.add(group));
|
||||
|
||||
// If not all test groups have recorded timing information, filter the remaining groups based on shard distribution
|
||||
if (testDetails.length != testGroups.length) {
|
||||
if (testDetails.length !== testGroups.length) {
|
||||
const allTestIds = testDetails.map(shardDetails => shardDetails.id);
|
||||
const UnrecordedTests = testGroups.filter(group => !allTestIds.includes(group.tests[0].id));
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ export function filterForShardFromTimingFile(timingFile: JSONReport, shard: { to
|
|||
|
||||
// Extracts test details from a JSON report and returns an array of test details objects.
|
||||
function getAllTestDetails(report: JSONReport) {
|
||||
const allTestDetails:testDetails[] = [];
|
||||
const allTestDetails: testDetails[] = [];
|
||||
report.suites.forEach((suite: JSONReportSuite) => {
|
||||
getTestDetails(suite, allTestDetails);
|
||||
});
|
||||
|
|
@ -222,9 +222,9 @@ function getAllTestDetails(report: JSONReport) {
|
|||
// Recursively traverses through test suites in a JSON report and extracts test details.
|
||||
function getTestDetails(suite: JSONReportSuite, allTestDetails: testDetails[]) {
|
||||
if (suite.specs) {
|
||||
suite.specs.forEach((spec) => {
|
||||
spec.tests.forEach((test) => {
|
||||
test.results.forEach((result) => {
|
||||
suite.specs.forEach(spec => {
|
||||
spec.tests.forEach(test => {
|
||||
test.results.forEach(result => {
|
||||
allTestDetails.push({
|
||||
id: spec.id,
|
||||
name: spec.title,
|
||||
|
|
@ -236,7 +236,7 @@ function getTestDetails(suite: JSONReportSuite, allTestDetails: testDetails[]) {
|
|||
}
|
||||
|
||||
if (suite.suites) {
|
||||
suite.suites.forEach((subSuite) => {
|
||||
suite.suites.forEach(subSuite => {
|
||||
getTestDetails(subSuite, allTestDetails);
|
||||
});
|
||||
}
|
||||
|
|
@ -245,13 +245,13 @@ function getTestDetails(suite: JSONReportSuite, allTestDetails: testDetails[]) {
|
|||
function mapTestDetailsToShards(testDetails: testDetails[], shard: {total: number, current: number}) {
|
||||
testDetails.sort((a, b) => b.duration - a.duration);
|
||||
|
||||
const result:testDetails[][] = Array.from({ length: shard.total }, () => []);
|
||||
const result: testDetails[][] = Array.from({ length: shard.total }, () => []);
|
||||
const sums = Array(shard.total).fill(0);
|
||||
|
||||
// Distribute tests to shards based on their durations
|
||||
for (let testDetailsObj of testDetails) {
|
||||
for (const testDetailsObj of testDetails) {
|
||||
// Find the shard with the smallest total duration and assign the test to that shard
|
||||
let minIndex = sums.indexOf(Math.min(...sums));
|
||||
const minIndex = sums.indexOf(Math.min(...sums));
|
||||
result[minIndex].push(testDetailsObj);
|
||||
sums[minIndex] += testDetailsObj.duration;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue