Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: ensure the file operations are async in the json reporter. (#24356)
Marcin Strzyz207086180781
diff --git a/packages/playwright-test/src/reporters/json.ts b/packages/playwright-test/src/reporters/json.tsindex f85427bb4f..6ba7d48801 100644--- a/packages/playwright-test/src/reporters/json.ts+++ b/packages/playwright-test/src/reporters/json.ts@@ -55,7 +55,7 @@ class JSONReporter extends EmptyReporter {}override async onEnd(result: FullResult) {- outputReport(this._serializeReport(), this.config, this._outputFile);+ await outputReport(this._serializeReport(), this.config, this._outputFile);}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);if (outputFile) {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;- fs.mkdirSync(path.dirname(outputFile), { recursive: true });- fs.writeFileSync(outputFile, reportString);+ await fs.promises.mkdir(path.dirname(outputFile), { recursive: true });+ await fs.promises.writeFile(outputFile, reportString);} else {console.log(reportString);}