@playwright/test 1.36.0-alpha-jun-8-2023 → 1.36.0-alpha-jun-10-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.
@@ -23,17 +23,19 @@ exports.serializeRegexPatterns = serializeRegexPatterns;
23
23
  */
24
24
 
25
25
  class TeleReporterReceiver {
26
- constructor(pathSeparator, reporter, reportConfig) {
26
+ constructor(pathSeparator, reporter, reuseTestCases, reportConfig) {
27
27
  this._rootSuite = void 0;
28
28
  this._pathSeparator = void 0;
29
29
  this._reporter = void 0;
30
30
  this._tests = new Map();
31
31
  this._rootDir = void 0;
32
32
  this._clearPreviousResultsWhenTestBegins = false;
33
+ this._reuseTestCases = void 0;
33
34
  this._reportConfig = void 0;
34
35
  this._rootSuite = new TeleSuite('', 'root');
35
36
  this._pathSeparator = pathSeparator;
36
37
  this._reporter = reporter;
38
+ this._reuseTestCases = reuseTestCases;
37
39
  this._reportConfig = reportConfig;
38
40
  }
39
41
  dispatch(message) {
@@ -130,7 +132,7 @@ class TeleReporterReceiver {
130
132
  result.status = payload.status;
131
133
  result.statusEx = payload.status;
132
134
  result.errors = payload.errors;
133
- result.attachments = payload.attachments;
135
+ result.attachments = this._parseAttachments(payload.attachments);
134
136
  (_this$_reporter$onTes2 = (_this$_reporter3 = this._reporter).onTestEnd) === null || _this$_reporter$onTes2 === void 0 ? void 0 : _this$_reporter$onTes2.call(_this$_reporter3, test, result);
135
137
  }
136
138
  _onStepBegin(testId, resultId, payload) {
@@ -145,7 +147,7 @@ class TeleReporterReceiver {
145
147
  location: this._absoluteLocation(payload.location),
146
148
  parent: parentStep,
147
149
  startTime: new Date(payload.startTime),
148
- duration: 0,
150
+ duration: -1,
149
151
  steps: []
150
152
  };
151
153
  if (parentStep) parentStep.steps.push(step);else result.steps.push(step);
@@ -166,11 +168,18 @@ class TeleReporterReceiver {
166
168
  (_this$_reporter$onErr = (_this$_reporter6 = this._reporter).onError) === null || _this$_reporter$onErr === void 0 ? void 0 : _this$_reporter$onErr.call(_this$_reporter6, error);
167
169
  }
168
170
  _onStdIO(type, testId, resultId, data, isBase64) {
169
- var _this$_reporter$onStd, _this$_reporter7, _this$_reporter$onStd2, _this$_reporter8;
170
171
  const chunk = isBase64 ? globalThis.Buffer ? Buffer.from(data, 'base64') : atob(data) : data;
171
172
  const test = testId ? this._tests.get(testId) : undefined;
172
173
  const result = test && resultId ? test.resultsMap.get(resultId) : undefined;
173
- if (type === 'stdout') (_this$_reporter$onStd = (_this$_reporter7 = this._reporter).onStdOut) === null || _this$_reporter$onStd === void 0 ? void 0 : _this$_reporter$onStd.call(_this$_reporter7, chunk, test, result);else (_this$_reporter$onStd2 = (_this$_reporter8 = this._reporter).onStdErr) === null || _this$_reporter$onStd2 === void 0 ? void 0 : _this$_reporter$onStd2.call(_this$_reporter8, chunk, test, result);
174
+ if (type === 'stdout') {
175
+ var _this$_reporter$onStd, _this$_reporter7;
176
+ result === null || result === void 0 ? void 0 : result.stdout.push(chunk);
177
+ (_this$_reporter$onStd = (_this$_reporter7 = this._reporter).onStdOut) === null || _this$_reporter$onStd === void 0 ? void 0 : _this$_reporter$onStd.call(_this$_reporter7, chunk, test, result);
178
+ } else {
179
+ var _this$_reporter$onStd2, _this$_reporter8;
180
+ result === null || result === void 0 ? void 0 : result.stderr.push(chunk);
181
+ (_this$_reporter$onStd2 = (_this$_reporter8 = this._reporter).onStdErr) === null || _this$_reporter$onStd2 === void 0 ? void 0 : _this$_reporter$onStd2.call(_this$_reporter8, chunk, test, result);
182
+ }
174
183
  }
175
184
  _onEnd(result) {
176
185
  var _this$_reporter$onEnd, _this$_reporter9;
@@ -213,6 +222,14 @@ class TeleReporterReceiver {
213
222
  use: {}
214
223
  };
215
224
  }
225
+ _parseAttachments(attachments) {
226
+ return attachments.map(a => {
227
+ return {
228
+ ...a,
229
+ body: a.base64 && globalThis.Buffer ? Buffer.from(a.base64, 'base64') : undefined
230
+ };
231
+ });
232
+ }
216
233
  _mergeSuitesInto(jsonSuites, parent) {
217
234
  for (const jsonSuite of jsonSuites) {
218
235
  let targetSuite = parent.suites.find(s => s.title === jsonSuite.title);
@@ -230,7 +247,7 @@ class TeleReporterReceiver {
230
247
  }
231
248
  _mergeTestsInto(jsonTests, parent) {
232
249
  for (const jsonTest of jsonTests) {
233
- let targetTest = parent.tests.find(s => s.title === jsonTest.title);
250
+ let targetTest = this._reuseTestCases ? parent.tests.find(s => s.title === jsonTest.title) : undefined;
234
251
  if (!targetTest) {
235
252
  targetTest = new TeleTestCase(jsonTest.testId, jsonTest.title, this._absoluteLocation(jsonTest.location));
236
253
  targetTest.parent = parent;
@@ -29,7 +29,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
29
29
 
30
30
  class BlobReporter extends _teleEmitter.TeleReporterEmitter {
31
31
  constructor(options) {
32
- super(message => this._messages.push(message));
32
+ super(message => this._messages.push(message), false);
33
33
  this._messages = [];
34
34
  this._options = void 0;
35
35
  this._salt = void 0;
@@ -65,7 +65,7 @@ class BlobReporter extends _teleEmitter.TeleReporterEmitter {
65
65
  _fs.default.promises.writeFile(this._reportFile, content).catch(e => console.error(`Failed to write report ${this._reportFile}: ${e}`))]);
66
66
  }
67
67
  _serializeAttachments(attachments) {
68
- return attachments.map(attachment => {
68
+ return super._serializeAttachments(attachments).map(attachment => {
69
69
  if (!attachment.path || !_fs.default.statSync(attachment.path).isFile()) return attachment;
70
70
  // Add run guid to avoid clashes between shards.
71
71
  const sha1 = (0, _utils.calculateSha1)(attachment.path + this._salt);
@@ -32,7 +32,7 @@ async function createMergedReport(config, dir, reporterDescriptions, resolvePath
32
32
  const events = await mergeEvents(dir, shardFiles);
33
33
  if (resolvePaths) patchAttachmentPaths(events, dir);
34
34
  const reporters = await (0, _reporters.createReporters)(config, 'merge', reporterDescriptions);
35
- const receiver = new _teleReceiver.TeleReporterReceiver(_path.default.sep, new _multiplexer.Multiplexer(reporters), config.config);
35
+ const receiver = new _teleReceiver.TeleReporterReceiver(_path.default.sep, new _multiplexer.Multiplexer(reporters), false, config.config);
36
36
  for (const event of events) await receiver.dispatch(event);
37
37
  }
38
38
  function patchAttachmentPaths(events, resourceDir) {
@@ -26,10 +26,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
26
26
  */
27
27
 
28
28
  class TeleReporterEmitter {
29
- constructor(messageSink) {
29
+ constructor(messageSink, skipBuffers) {
30
30
  this._messageSink = void 0;
31
31
  this._rootDir = void 0;
32
+ this._skipBuffers = void 0;
32
33
  this._messageSink = messageSink;
34
+ this._skipBuffers = skipBuffers;
33
35
  }
34
36
  onBegin(config, suite) {
35
37
  this._rootDir = config.rootDir;
@@ -97,7 +99,7 @@ class TeleReporterEmitter {
97
99
  });
98
100
  }
99
101
  onStdOut(chunk, test, result) {
100
- this._onStdIO('stdio', chunk, test, result);
102
+ this._onStdIO('stdout', chunk, test, result);
101
103
  }
102
104
  onStdErr(chunk, test, result) {
103
105
  this._onStdIO('stderr', chunk, test, result);
@@ -201,7 +203,13 @@ class TeleReporterEmitter {
201
203
  };
202
204
  }
203
205
  _serializeAttachments(attachments) {
204
- return attachments;
206
+ return attachments.map(a => {
207
+ return {
208
+ ...a,
209
+ // There is no Buffer in the browser, so there is no point in sending the data there.
210
+ base64: a.body && !this._skipBuffers ? a.body.toString('base64') : undefined
211
+ };
212
+ });
205
213
  }
206
214
  _serializeStepStart(step) {
207
215
  var _step$parent;
@@ -70,7 +70,7 @@ async function createReporters(config, mode, descriptions) {
70
70
  const prints = r.printsToStdio ? r.printsToStdio() : true;
71
71
  return prints;
72
72
  });
73
- if (reporters.length && !someReporterPrintsToStdio && mode !== 'merge') {
73
+ if (reporters.length && !someReporterPrintsToStdio) {
74
74
  // Add a line/dot/list-mode reporter for convenience.
75
75
  // Important to put it first, jsut in case some other reporter stalls onEnd.
76
76
  if (mode === 'list') reporters.unshift(new ListModeReporter());else reporters.unshift(!process.env.CI ? new _line.default({
@@ -155,7 +155,7 @@ class UIMode {
155
155
  (_this$_transport$send = (_this$_transport = this._transport).sendEvent) === null || _this$_transport$send === void 0 ? void 0 : _this$_transport$send.call(_this$_transport, method, params);
156
156
  }
157
157
  async _listTests() {
158
- const listReporter = new _teleEmitter.TeleReporterEmitter(e => this._dispatchEvent(e.method, e.params));
158
+ const listReporter = new _teleEmitter.TeleReporterEmitter(e => this._dispatchEvent(e.method, e.params), true);
159
159
  const reporter = new _internalReporter.InternalReporter([listReporter]);
160
160
  this._config.cliListOnly = true;
161
161
  this._config.testIdMatcher = undefined;
@@ -179,7 +179,7 @@ class UIMode {
179
179
  this._config.cliListOnly = false;
180
180
  this._config.testIdMatcher = id => !testIdSet || testIdSet.has(id);
181
181
  const reporters = await (0, _reporters.createReporters)(this._config, 'ui');
182
- reporters.push(new _teleEmitter.TeleReporterEmitter(e => this._dispatchEvent(e.method, e.params)));
182
+ reporters.push(new _teleEmitter.TeleReporterEmitter(e => this._dispatchEvent(e.method, e.params), true));
183
183
  const reporter = new _internalReporter.InternalReporter(reporters);
184
184
  const taskRunner = (0, _tasks.createTaskRunnerForWatch)(this._config, reporter);
185
185
  const testRun = new _tasks.TestRun(this._config, reporter);
@@ -71,7 +71,7 @@ class Fixture {
71
71
  }
72
72
  }
73
73
 
74
- // Break the regustration function into before/after steps. Create these before/after stacks
74
+ // Break the registration function into before/after steps. Create these before/after stacks
75
75
  // w/o scopes, and create single mutable step that will be converted into the after step.
76
76
  const shouldGenerateStep = !this.registration.hideStep && !this.registration.name.startsWith('_') && !this.registration.option;
77
77
  const isInternalFixture = this.registration.location && (0, _util.filterStackFile)(this.registration.location.file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playwright/test",
3
- "version": "1.36.0-alpha-jun-8-2023",
3
+ "version": "1.36.0-alpha-jun-10-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-jun-8-2023"
44
+ "playwright-core": "1.36.0-alpha-jun-10-2023"
45
45
  },
46
46
  "optionalDependencies": {
47
47
  "fsevents": "2.3.2"