@playwright/test 1.36.0-alpha-1686749586000 → 1.36.0-alpha-jun-15-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.
@@ -10,6 +10,7 @@ var _utils = require("playwright-core/lib/utils");
10
10
  var _utilsBundle = require("playwright-core/lib/utilsBundle");
11
11
  var _stream = require("stream");
12
12
  var _teleEmitter = require("./teleEmitter");
13
+ var _zipBundle = require("playwright-core/lib/zipBundle");
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  /**
15
16
  * Copyright (c) Microsoft Corporation.
@@ -35,7 +36,7 @@ class BlobReporter extends _teleEmitter.TeleReporterEmitter {
35
36
  this._salt = void 0;
36
37
  this._copyFilePromises = new Set();
37
38
  this._outputDir = void 0;
38
- this._reportFile = void 0;
39
+ this._reportName = void 0;
39
40
  this._options = options;
40
41
  this._salt = (0, _utils.createGuid)();
41
42
  this._messages.push({
@@ -53,16 +54,25 @@ class BlobReporter extends _teleEmitter.TeleReporterEmitter {
53
54
  _fs.default.mkdirSync(_path.default.join(this._outputDir, 'resources'), {
54
55
  recursive: true
55
56
  });
56
- this._reportFile = this._computeOutputFileName(config);
57
+ this._reportName = this._computeReportName(config);
57
58
  super.onBegin(config, suite);
58
59
  }
59
60
  async onEnd(result) {
60
61
  await super.onEnd(result);
61
62
  const lines = this._messages.map(m => JSON.stringify(m) + '\n');
62
63
  const content = _stream.Readable.from(lines);
64
+ const zipFile = new _zipBundle.yazl.ZipFile();
65
+ const zipFinishPromise = new _utils.ManualPromise();
66
+ zipFile.on('error', error => zipFinishPromise.reject(error));
67
+ const zipFileName = _path.default.join(this._outputDir, this._reportName + '.zip');
68
+ zipFile.outputStream.pipe(_fs.default.createWriteStream(zipFileName)).on('close', () => {
69
+ zipFinishPromise.resolve(undefined);
70
+ });
71
+ zipFile.addReadStream(content, this._reportName + '.jsonl');
72
+ zipFile.end();
63
73
  await Promise.all([...this._copyFilePromises,
64
74
  // Requires Node v14.18.0+
65
- _fs.default.promises.writeFile(this._reportFile, content).catch(e => console.error(`Failed to write report ${this._reportFile}: ${e}`))]);
75
+ zipFinishPromise.catch(e => console.error(`Failed to write report ${zipFileName}: ${e}`))]);
66
76
  }
67
77
  _serializeAttachments(attachments) {
68
78
  return super._serializeAttachments(attachments).map(attachment => {
@@ -78,13 +88,13 @@ class BlobReporter extends _teleEmitter.TeleReporterEmitter {
78
88
  };
79
89
  });
80
90
  }
81
- _computeOutputFileName(config) {
91
+ _computeReportName(config) {
82
92
  let shardSuffix = '';
83
93
  if (config.shard) {
84
94
  const paddedNumber = `${config.shard.current}`.padStart(`${config.shard.total}`.length, '0');
85
95
  shardSuffix = `${paddedNumber}-of-${config.shard.total}-`;
86
96
  }
87
- return _path.default.join(this._outputDir, `report-${shardSuffix}${(0, _utils.createGuid)()}.jsonl`);
97
+ return `report-${shardSuffix}${(0, _utils.createGuid)()}`;
88
98
  }
89
99
  _startCopyingFile(from, to) {
90
100
  const copyPromise = _fs.default.promises.copyFile(from, to).catch(e => {
@@ -9,6 +9,7 @@ var _path = _interopRequireDefault(require("path"));
9
9
  var _teleReceiver = require("../isomorphic/teleReceiver");
10
10
  var _reporters = require("../runner/reporters");
11
11
  var _multiplexer = require("./multiplexer");
12
+ var _utils = require("playwright-core/lib/utils");
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  /**
14
15
  * Copyright (c) Microsoft Corporation.
@@ -47,12 +48,24 @@ function patchAttachmentPaths(events, resourceDir) {
47
48
  function parseEvents(reportJsonl) {
48
49
  return reportJsonl.toString().split('\n').filter(line => line.length).map(line => JSON.parse(line));
49
50
  }
51
+ async function extractReportFromZip(file) {
52
+ const zipFile = new _utils.ZipFile(file);
53
+ const entryNames = await zipFile.entries();
54
+ try {
55
+ for (const entryName of entryNames) {
56
+ if (entryName.endsWith('.jsonl')) return await zipFile.read(entryName);
57
+ }
58
+ } finally {
59
+ zipFile.close();
60
+ }
61
+ throw new Error(`Cannot find *.jsonl file in ${file}`);
62
+ }
50
63
  async function mergeEvents(dir, shardReportFiles) {
51
64
  const events = [];
52
65
  const beginEvents = [];
53
66
  const endEvents = [];
54
67
  for (const reportFile of shardReportFiles) {
55
- const reportJsonl = await _fs.default.promises.readFile(_path.default.join(dir, reportFile), 'utf8');
68
+ const reportJsonl = await extractReportFromZip(_path.default.join(dir, reportFile));
56
69
  const parsedEvents = parseEvents(reportJsonl);
57
70
  for (const event of parsedEvents) {
58
71
  if (event.method === 'onBegin') beginEvents.push(event);else if (event.method === 'onEnd') endEvents.push(event);else if (event.method === 'onBlobReportMetadata') new ProjectNamePatcher(event.params.projectSuffix).patchEvents(parsedEvents);else events.push(event);
@@ -134,7 +147,7 @@ function mergeEndEvents(endEvents) {
134
147
  }
135
148
  async function sortedShardFiles(dir) {
136
149
  const files = await _fs.default.promises.readdir(dir);
137
- return files.filter(file => file.endsWith('.jsonl')).sort();
150
+ return files.filter(file => file.startsWith('report-') && file.endsWith('.zip')).sort();
138
151
  }
139
152
  class ProjectNamePatcher {
140
153
  constructor(_projectNameSuffix) {
@@ -184,7 +184,8 @@ class TestInfoImpl {
184
184
  const visit = step => {
185
185
  // Never nest into under another lax element, it could be a series
186
186
  // of no-reply actions, ala page.continue().
187
- if (!step.endWallTime && step.category === data.category && !step.laxParent) parentStep = step;
187
+ const canNest = step.category === data.category || step.category === 'expect' && data.category === 'attach';
188
+ if (!step.endWallTime && canNest && !step.laxParent) parentStep = step;
188
189
  step.steps.forEach(visit);
189
190
  };
190
191
  this._steps.forEach(visit);
@@ -297,7 +298,8 @@ class TestInfoImpl {
297
298
  const step = this._addStep({
298
299
  title: `attach "${name}"`,
299
300
  category: 'attach',
300
- wallTime: Date.now()
301
+ wallTime: Date.now(),
302
+ laxParent: true
301
303
  });
302
304
  this._attachWithoutStep(attachment);
303
305
  step.complete({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playwright/test",
3
- "version": "1.36.0-alpha-1686749586000",
3
+ "version": "1.36.0-alpha-jun-15-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.36.0-alpha-1686749586000"
44
+ "playwright-core": "1.36.0-alpha-jun-15-2023"
45
45
  },
46
46
  "optionalDependencies": {
47
47
  "fsevents": "2.3.2"