mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: ensure the file operations are async in the json reporter. (#24356)
This commit is contained in:
parent
f453a17ede
commit
2070861807
@ -55,7 +55,7 @@ class JSONReporter extends EmptyReporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override async onEnd(result: FullResult) {
|
override async onEnd(result: FullResult) {
|
||||||
outputReport(this._serializeReport(), this.config, this._outputFile);
|
await outputReport(this._serializeReport(), this.config, this._outputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _serializeReport(): JSONReport {
|
private _serializeReport(): JSONReport {
|
||||||
@ -222,13 +222,13 @@ class JSONReporter extends EmptyReporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputReport(report: JSONReport, config: FullConfig, outputFile: string | undefined) {
|
async function outputReport(report: JSONReport, config: FullConfig, outputFile: string | undefined) {
|
||||||
const reportString = JSON.stringify(report, undefined, 2);
|
const reportString = JSON.stringify(report, undefined, 2);
|
||||||
if (outputFile) {
|
if (outputFile) {
|
||||||
assert(config.configFile || path.isAbsolute(outputFile), 'Expected fully resolved path if not using config file.');
|
assert(config.configFile || path.isAbsolute(outputFile), 'Expected fully resolved path if not using config file.');
|
||||||
outputFile = config.configFile ? path.resolve(path.dirname(config.configFile), outputFile) : outputFile;
|
outputFile = config.configFile ? path.resolve(path.dirname(config.configFile), outputFile) : outputFile;
|
||||||
fs.mkdirSync(path.dirname(outputFile), { recursive: true });
|
await fs.promises.mkdir(path.dirname(outputFile), { recursive: true });
|
||||||
fs.writeFileSync(outputFile, reportString);
|
await fs.promises.writeFile(outputFile, reportString);
|
||||||
} else {
|
} else {
|
||||||
console.log(reportString);
|
console.log(reportString);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user