playwright
playwright copied to clipboard
[Feature] Get report folder from playwright config file.
Need a way to get the folder specified in playwright config file. Eg:
// playwright config ts file
reporter: [['html', { open: 'never', outputFolder: 'reports/playwright' }]],
Folder name extracted would be reports/playwright
.
@quldude There is no special API for this, but you can always import your config and read values from it. Let me know if that helps.
const value = await import('./playwright.config').reporter[0][1].outputFolder;
I found another way:
onBegin(config: FullConfig, suite: Suite): void {
for (const [name, options] of config.reporter) {
if (name === 'html' && options) {
this.reportFolder = options.outputFolder;
break;
}
}
...
do you know if I use the environment variable PLAYWRIGHT_HTML_REPORT
, will that override the folder mentioned in config file?
do you know if I use the environment variable PLAYWRIGHT_HTML_REPORT, will that override the folder mentioned in config file?
PLAYWRIGHT_HTML_REPORT
will be used instead of the config, but value in the config itself will not be replaced.
Same question, if I want to get the name of the project for judgment, how do I get this configuration
@luqy In your custom reporter, call suite.project()
. Inside a test, use test.info().project
.