@playwright/test 1.37.0-alpha-aug-1-2023 → 1.37.0-alpha-aug-2-2023
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/reporters/blob.js +34 -33
- package/lib/reporters/merge.js +21 -16
- package/package.json +2 -2
package/lib/reporters/blob.js
CHANGED
|
@@ -29,28 +29,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
29
29
|
* limitations under the License.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
+
const currentVersion = 1;
|
|
32
33
|
class BlobReporter extends _teleEmitter.TeleReporterEmitter {
|
|
33
34
|
constructor(options) {
|
|
34
35
|
super(message => this._messages.push(message), false);
|
|
35
36
|
this._messages = [];
|
|
37
|
+
this._attachments = [];
|
|
36
38
|
this._options = void 0;
|
|
37
39
|
this._salt = void 0;
|
|
38
|
-
this._copyFilePromises = new Set();
|
|
39
|
-
this._outputDir = void 0;
|
|
40
|
-
this._reportName = void 0;
|
|
41
40
|
this._options = options;
|
|
42
41
|
this._salt = (0, _utils.createGuid)();
|
|
43
42
|
}
|
|
44
43
|
onConfigure(config) {
|
|
45
|
-
|
|
46
|
-
const removePromise = process.env.PWTEST_BLOB_DO_NOT_REMOVE ? Promise.resolve() : (0, _utils.removeFolders)([outputDir]);
|
|
47
|
-
this._outputDir = removePromise.then(() => _fs.default.promises.mkdir(_path.default.join(outputDir, 'resources'), {
|
|
48
|
-
recursive: true
|
|
49
|
-
})).then(() => outputDir);
|
|
50
|
-
this._reportName = `report-${(0, _utils.createGuid)()}`;
|
|
44
|
+
var _config$shard;
|
|
51
45
|
const metadata = {
|
|
46
|
+
version: currentVersion,
|
|
52
47
|
projectSuffix: process.env.PWTEST_BLOB_SUFFIX,
|
|
53
|
-
shard: config.shard ?
|
|
48
|
+
shard: (_config$shard = config.shard) !== null && _config$shard !== void 0 ? _config$shard : undefined
|
|
54
49
|
};
|
|
55
50
|
this._messages.push({
|
|
56
51
|
method: 'onBlobReportMetadata',
|
|
@@ -60,48 +55,54 @@ class BlobReporter extends _teleEmitter.TeleReporterEmitter {
|
|
|
60
55
|
}
|
|
61
56
|
async onEnd(result) {
|
|
62
57
|
await super.onEnd(result);
|
|
63
|
-
const outputDir =
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
const outputDir = (0, _util.resolveReporterOutputPath)('blob-report', this._options.configDir, this._options.outputDir);
|
|
59
|
+
if (!process.env.PWTEST_BLOB_DO_NOT_REMOVE) await (0, _utils.removeFolders)([outputDir]);
|
|
60
|
+
await _fs.default.promises.mkdir(outputDir, {
|
|
61
|
+
recursive: true
|
|
62
|
+
});
|
|
63
|
+
const reportName = `report-${(0, _utils.createGuid)()}`;
|
|
66
64
|
const zipFile = new _zipBundle.yazl.ZipFile();
|
|
67
65
|
const zipFinishPromise = new _utils.ManualPromise();
|
|
66
|
+
const finishPromise = zipFinishPromise.catch(e => {
|
|
67
|
+
throw new Error(`Failed to write report ${reportName + '.zip'}: ` + e.message);
|
|
68
|
+
});
|
|
68
69
|
zipFile.on('error', error => zipFinishPromise.reject(error));
|
|
69
|
-
const zipFileName = _path.default.join(outputDir,
|
|
70
|
+
const zipFileName = _path.default.join(outputDir, reportName + '.zip');
|
|
70
71
|
zipFile.outputStream.pipe(_fs.default.createWriteStream(zipFileName)).on('close', () => {
|
|
71
72
|
zipFinishPromise.resolve(undefined);
|
|
72
73
|
}).on('error', error => zipFinishPromise.reject(error));
|
|
73
|
-
|
|
74
|
+
for (const {
|
|
75
|
+
originalPath,
|
|
76
|
+
zipEntryPath
|
|
77
|
+
} of this._attachments) {
|
|
78
|
+
var _fs$statSync;
|
|
79
|
+
if (!((_fs$statSync = _fs.default.statSync(originalPath, {
|
|
80
|
+
throwIfNoEntry: false
|
|
81
|
+
})) !== null && _fs$statSync !== void 0 && _fs$statSync.isFile())) continue;
|
|
82
|
+
zipFile.addFile(originalPath, zipEntryPath);
|
|
83
|
+
}
|
|
84
|
+
const lines = this._messages.map(m => JSON.stringify(m) + '\n');
|
|
85
|
+
const content = _stream.Readable.from(lines);
|
|
86
|
+
zipFile.addReadStream(content, reportName + '.jsonl');
|
|
74
87
|
zipFile.end();
|
|
75
|
-
await
|
|
76
|
-
// Requires Node v14.18.0+
|
|
77
|
-
zipFinishPromise.catch(e => {
|
|
78
|
-
throw new Error(`Failed to write report ${zipFileName}: ` + e.message);
|
|
79
|
-
})]);
|
|
88
|
+
await finishPromise;
|
|
80
89
|
}
|
|
81
90
|
_serializeAttachments(attachments) {
|
|
82
91
|
return super._serializeAttachments(attachments).map(attachment => {
|
|
83
|
-
|
|
84
|
-
if (!attachment.path || !((_fs$statSync = _fs.default.statSync(attachment.path, {
|
|
85
|
-
throwIfNoEntry: false
|
|
86
|
-
})) !== null && _fs$statSync !== void 0 && _fs$statSync.isFile())) return attachment;
|
|
92
|
+
if (!attachment.path) return attachment;
|
|
87
93
|
// Add run guid to avoid clashes between shards.
|
|
88
94
|
const sha1 = (0, _utils.calculateSha1)(attachment.path + this._salt);
|
|
89
95
|
const extension = _utilsBundle.mime.getExtension(attachment.contentType) || 'dat';
|
|
90
96
|
const newPath = `resources/${sha1}.${extension}`;
|
|
91
|
-
this.
|
|
97
|
+
this._attachments.push({
|
|
98
|
+
originalPath: attachment.path,
|
|
99
|
+
zipEntryPath: newPath
|
|
100
|
+
});
|
|
92
101
|
return {
|
|
93
102
|
...attachment,
|
|
94
103
|
path: newPath
|
|
95
104
|
};
|
|
96
105
|
});
|
|
97
106
|
}
|
|
98
|
-
_startCopyingFile(from, to) {
|
|
99
|
-
const copyPromise = this._outputDir.then(dir => _fs.default.promises.copyFile(from, _path.default.join(dir, to))).catch(e => {
|
|
100
|
-
console.error(`Failed to copy file from "${from}" to "${to}": ${e}`);
|
|
101
|
-
}).then(() => {
|
|
102
|
-
this._copyFilePromises.delete(copyPromise);
|
|
103
|
-
});
|
|
104
|
-
this._copyFilePromises.add(copyPromise);
|
|
105
|
-
}
|
|
106
107
|
}
|
|
107
108
|
exports.BlobReporter = BlobReporter;
|
package/lib/reporters/merge.js
CHANGED
|
@@ -48,17 +48,30 @@ function patchAttachmentPaths(events, resourceDir) {
|
|
|
48
48
|
function parseEvents(reportJsonl) {
|
|
49
49
|
return reportJsonl.toString().split('\n').filter(line => line.length).map(line => JSON.parse(line));
|
|
50
50
|
}
|
|
51
|
-
async function
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
async function extractAndParseReports(dir, shardFiles) {
|
|
52
|
+
const shardEvents = [];
|
|
53
|
+
await _fs.default.promises.mkdir(_path.default.join(dir, 'resources'), {
|
|
54
|
+
recursive: true
|
|
55
|
+
});
|
|
56
|
+
for (const file of shardFiles) {
|
|
57
|
+
const zipFile = new _utils.ZipFile(_path.default.join(dir, file));
|
|
58
|
+
const entryNames = await zipFile.entries();
|
|
55
59
|
for (const entryName of entryNames) {
|
|
56
|
-
|
|
60
|
+
const content = await zipFile.read(entryName);
|
|
61
|
+
if (entryName.endsWith('.jsonl')) {
|
|
62
|
+
const parsedEvents = parseEvents(content);
|
|
63
|
+
shardEvents.push({
|
|
64
|
+
metadata: findMetadata(parsedEvents, file),
|
|
65
|
+
parsedEvents
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
const fileName = _path.default.join(dir, entryName);
|
|
69
|
+
await _fs.default.promises.writeFile(fileName, content);
|
|
70
|
+
}
|
|
57
71
|
}
|
|
58
|
-
} finally {
|
|
59
72
|
zipFile.close();
|
|
60
73
|
}
|
|
61
|
-
|
|
74
|
+
return shardEvents;
|
|
62
75
|
}
|
|
63
76
|
function findMetadata(events, file) {
|
|
64
77
|
var _events$;
|
|
@@ -70,15 +83,7 @@ async function mergeEvents(dir, shardReportFiles) {
|
|
|
70
83
|
const configureEvents = [];
|
|
71
84
|
const beginEvents = [];
|
|
72
85
|
const endEvents = [];
|
|
73
|
-
const shardEvents =
|
|
74
|
-
for (const reportFile of shardReportFiles) {
|
|
75
|
-
const reportJsonl = await extractReportFromZip(_path.default.join(dir, reportFile));
|
|
76
|
-
const parsedEvents = parseEvents(reportJsonl);
|
|
77
|
-
shardEvents.push({
|
|
78
|
-
metadata: findMetadata(parsedEvents, reportFile),
|
|
79
|
-
parsedEvents
|
|
80
|
-
});
|
|
81
|
-
}
|
|
86
|
+
const shardEvents = await extractAndParseReports(dir, shardReportFiles);
|
|
82
87
|
shardEvents.sort((a, b) => {
|
|
83
88
|
var _a$metadata$shard$cur, _a$metadata$shard, _b$metadata$shard$cur, _b$metadata$shard;
|
|
84
89
|
const shardA = (_a$metadata$shard$cur = (_a$metadata$shard = a.metadata.shard) === null || _a$metadata$shard === void 0 ? void 0 : _a$metadata$shard.current) !== null && _a$metadata$shard$cur !== void 0 ? _a$metadata$shard$cur : 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playwright/test",
|
|
3
|
-
"version": "1.37.0-alpha-aug-
|
|
3
|
+
"version": "1.37.0-alpha-aug-2-2023",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": "github:Microsoft/playwright",
|
|
6
6
|
"homepage": "https://playwright.dev",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"license": "Apache-2.0",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@types/node": "*",
|
|
44
|
-
"playwright-core": "1.37.0-alpha-aug-
|
|
44
|
+
"playwright-core": "1.37.0-alpha-aug-2-2023"
|
|
45
45
|
},
|
|
46
46
|
"optionalDependencies": {
|
|
47
47
|
"fsevents": "2.3.2"
|