英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论