Skip to content

Commit 9ea1688

Browse files
authored
feat: Playwright improvements (#3495)
2 parents 4d5b174 + ad390b4 commit 9ea1688

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

examples/browser-load-testing-playwright/browser-load-test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ export const config = {
1313
}
1414
};
1515

16+
export const before = {
17+
engine: 'playwright',
18+
testFunction: async function beforeFunctionHook(_page, userContext, _events) {
19+
// Any scenario variables we add via userContext.vars in this before hook will be available in every VU
20+
userContext.vars.testStartTime = new Date();
21+
}
22+
};
23+
1624
export const scenarios = [
1725
{
1826
engine: 'playwright',

packages/artillery/lib/platform/local/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ class PlatformLocal {
3030
await this.init();
3131

3232
if (this.platformOpts.mode === 'distribute') {
33-
const count = Math.max(1, os.cpus().length - 1);
33+
// Disable worker threads for Playwright-based load tests
34+
const count = this.script.config.engines?.playwright
35+
? 1
36+
: Math.max(1, os.cpus().length - 1);
3437
this.workerScripts = divideWork(this.script, count);
3538
this.count = this.workerScripts.length;
3639
} else {

0 commit comments

Comments
 (0)