如何避免 Playwright 读取配置文件并为每个工作线程创建单独的实例?

huangapple go评论110阅读模式
英文:

How to avoid Playwright reading the configuration file and creating separate instance for each workers?

问题

Playwright是否会为每个工作线程读取配置文件?
例如,如果我在Playwright配置文件中设置了工作线程数为3,是否意味着Playwright会创建三个单独的浏览器实例来并行执行测试?

我们如何避免为每个工作线程创建单独的实例?

英文:

Does Playwright reads the configuration file for each worker?
For example, If I have set the number of workers to 3 in my Playwright configuration file, does it means that Playwright will create three separate instances of the browser to execute the tests in parallel ?

How can we avoid creating separate instances for every worker?

答案1

得分: 1

是的,工作进程用于并行执行。

如果您想禁用并行执行,只需在配置文件或执行期间通过命令行将工作进程设置为1即可。

命令行:

npx playwright test --workers=1

配置文件:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  // 禁用并行执行 
  workers: 1
});

更多信息,请参阅:https://playwright.dev/docs/test-parallel#disable-parallelism

英文:

Yes, workers are for parallel execution.

If you want to disable parallel execution, you can simply set the workers as 1 either in config or through command line during execution.

Command line:

npx playwright test --workers=1

Config:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  // Disable parallel execution 
  workers: 1
});

https://playwright.dev/docs/test-parallel#disable-parallelism

huangapple
  • 本文由 发表于 2023年6月5日 12:47:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76403545.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定