This commit is contained in:
Simon Knott 2024-11-08 10:37:00 +01:00
parent d703a9df60
commit 44364f3b64
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -357,20 +357,22 @@ class HtmlBuilder {
} }
} }
// Inline report data. await this._writeReportData(path.join(this._reportFolder, 'index.html'));
const indexFile = path.join(this._reportFolder, 'index.html');
fs.appendFileSync(indexFile, '<script>\nwindow.playwrightReportBase64 = "data:application/zip;base64,');
return { ok, singleTestId };
}
private async _writeReportData(path: string) {
fs.appendFileSync(path, '<script>\nwindow.playwrightReportBase64 = "data:application/zip;base64,');
await new Promise(f => { await new Promise(f => {
this._dataZipFile!.end(undefined, () => { this._dataZipFile!.end(undefined, () => {
this._dataZipFile!.outputStream this._dataZipFile!.outputStream
.pipe(new Base64Encoder()) .pipe(new Base64Encoder())
.pipe(fs.createWriteStream(indexFile, { flags: 'a' })).on('close', f); .pipe(fs.createWriteStream(path, { flags: 'a' })).on('close', f);
}); });
}); });
fs.appendFileSync(indexFile, '";</script>'); fs.appendFileSync(path, '";</script>');
return { ok, singleTestId };
} }
private _addDataFile(fileName: string, data: any) { private _addDataFile(fileName: string, data: any) {