英文:
how to pass parameter from npx command to playright.config.js file
问题
我有这个在playwright.config.js文件中的axios报告
reporter: [['junit', { outputFile: 'results.xml' }],['./aio-reporter.js']],
现在我想在从命令行运行测试时向报告传递参数
例如:
reporter: [['junit', { outputFile: 'results.xml' }],['./aio-reporter.js'], let testcycle],
npx playwright test --testcycle=TC-TY-2
英文:
i have this axios report in playwright.config.js file
reporter: [['junit', { outputFile: 'results.xml' }],['./aio-reporter.js']],
now I want to pass a parameter to the report when I'm running the test from the command line
ex:
reporter: [['junit', { outputFile: 'results.xml' }],['./aio-reporter.js'], let testcycle],
npx playwright test --testcycle=TC-TY-2
答案1
得分: 1
你可以选择一个简单的实现方式,即在这种情况下使用环境变量来传递该值。你可以这样运行命令:
TESTCYCLE="TC-TY-2" npx playwright test
然后在代码中可以通过process.env.TESTCYCLE
引用该值。
英文:
One option that is simple to implement would be to just use an environment variable in this case to pass in that value. You could run the command like so:
TESTCYCLE=“TC-TY-2” npx playwright test
And then you can reference that value in the code as process.env.TESTCYCLE
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论