Skip to content

Commit 7c1f45c

Browse files
authored
chore(playwrighttesting): show effective parallelism instead of requested worker (Azure#32618)
### Packages impacted by this PR @azure/microsoft-playwright-testing ### Issues associated with this PR ### Describe the problem that is addressed by this PR Show effective parallelism instead of requested worker count. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ Yes ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
1 parent 307a1a9 commit 7c1f45c

File tree

4 files changed

+80
-2
lines changed

4 files changed

+80
-2
lines changed

sdk/playwrighttesting/microsoft-playwright-testing/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Release History
22

3+
## 1.0.0-beta.8 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
### Bugs Fixed
10+
11+
### Other Changes
12+
313
## 1.0.0-beta.7 (2025-01-17)
414

515
### Features Added

sdk/playwrighttesting/microsoft-playwright-testing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@azure/microsoft-playwright-testing",
3-
"version": "1.0.0-beta.7",
3+
"version": "1.0.0-beta.8",
44
"description": "Package to integrate your Playwright test suite with Microsoft Playwright Testing service",
55
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/playwrighttesting/microsoft-playwright-testing/README.md",
66
"sdk-type": "client",

sdk/playwrighttesting/microsoft-playwright-testing/src/utils/reporterUtils.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ class ReporterUtils {
404404

405405
private getTestRunConfig(): TestRunConfig {
406406
const testRunConfig: TestRunConfig = {
407-
workers: this.config.workers,
407+
workers: this.getWorkers(),
408408
pwVersion: this.config.version,
409409
timeout: this.config.globalTimeout,
410410
repeatEach: this.config.projects[0].repeatEach,
@@ -643,6 +643,17 @@ class ReporterUtils {
643643
private getReadableLineLocation(location: Location): string {
644644
return `at ${location.file}:${location.line}:${location.column}`;
645645
}
646+
647+
private getWorkers(): number {
648+
if (
649+
this.config.metadata &&
650+
"actualWorkers" in this.config.metadata &&
651+
typeof this.config.metadata.actualWorkers === "number"
652+
) {
653+
return this.config.metadata.actualWorkers;
654+
}
655+
return this.config.workers;
656+
}
646657
}
647658

648659
export default ReporterUtils;

sdk/playwrighttesting/microsoft-playwright-testing/test/utils/reporterUtils.spec.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,60 @@ describe("ReporterUtils.getReadableLineLocation", () => {
139139
expect(result).to.equal("at test-file.ts:100:10");
140140
});
141141
});
142+
143+
describe("ReporterUtils.getWorkers", () => {
144+
it("should returns config.workers if worker info not available in metadata object", () => {
145+
const reporterUtils = new ReporterUtils(
146+
{} as any,
147+
{
148+
workers: 5,
149+
metadata: {},
150+
} as any,
151+
{} as any,
152+
);
153+
const result = reporterUtils["getWorkers"]();
154+
expect(result).to.equal(5);
155+
});
156+
157+
it("should returns config.workers if metadata object is not available", () => {
158+
const reporterUtils = new ReporterUtils(
159+
{} as any,
160+
{
161+
workers: 5,
162+
} as any,
163+
{} as any,
164+
);
165+
const result = reporterUtils["getWorkers"]();
166+
expect(result).to.equal(5);
167+
});
168+
169+
it("should returns config.workers if actualWorkers in metadata object is not int", () => {
170+
const reporterUtils = new ReporterUtils(
171+
{} as any,
172+
{
173+
workers: 5,
174+
metadata: {
175+
actualWorkers: "dummy",
176+
},
177+
} as any,
178+
{} as any,
179+
);
180+
const result = reporterUtils["getWorkers"]();
181+
expect(result).to.equal(5);
182+
});
183+
184+
it("should returns metadata.actualWorkers if actualWorkers is int and available in metadata object", () => {
185+
const reporterUtils = new ReporterUtils(
186+
{} as any,
187+
{
188+
workers: 5,
189+
metadata: {
190+
actualWorkers: 3,
191+
},
192+
} as any,
193+
{} as any,
194+
);
195+
const result = reporterUtils["getWorkers"]();
196+
expect(result).to.equal(3);
197+
});
198+
});

0 commit comments

Comments
 (0)