我们可以基于Env配置并选择剧作家启动选项吗?
上下文:作为CI/CD进程的一部分,我正在为企业Web应用程序运行一堆剧作E2E测试,该测试是在GitHub Action上运行的。
要使用剧作家启动铬,我们有以下启动选项 -
const options = {
headless: true,
slowMo: 100,
..
// all args added to help run Chromium in headless mode
args: [
'--start-maximized',
'--disable-dev-shm-usage',
'--no-sandbox'
],
video: "true"
};
当在添加新测试用例的过程中,在本地系统上运行相同的测试时,我们必须手动将 true 更改为
> false
具有头部执行。
我想知道我们是否可以根据运行进行配置以更改 - 当执行是本地时,它在CI上运行时将无头模式更改为false和true。假设对于在本地运行测试,
npm运行测试-env = local
将无头作为false,而npm运行test -env = ci
在此处无头为true。 选项
。
我已经浏览了剧作家的文档,但找不到任何具体的文档。剧作家/Puppeteer上的大多数答案都是关于如何基于Env更改URL等的。
Context : I am running a bunch of Playwright e2e tests for a enterprise web application, which are run on Github actions, as a part of the CI/CD process.
To launch Chromium using Playwright we have these launch options -
const options = {
headless: true,
slowMo: 100,
..
// all args added to help run Chromium in headless mode
args: [
'--start-maximized',
'--disable-dev-shm-usage',
'--no-sandbox'
],
video: "true"
};
When the same tests are run on the local system during the time we add new test cases, we have to manually change the headless: true
to false
to have a head-ful execution.
I'm wondering if we can configure this to have change based on the run - when the execution is local, it changes the headless mode to false and true when it runs on ci. Let's say for running tests on local,
npm run test --env=local
gets the headless as false, and npm run test --env=ci
gets headless true in the options
.
I've gone through Playwright's documentation but couldn't find anything concrete. Most of the answers on Playwright/Puppeteer are about how to change the URL's etc, based on the env.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试以下选项之一:
You could try one of the below options: