@playwright/test 1.32.0 → 1.32.1-beta-1679703607000

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.
@@ -70,7 +70,6 @@ class TeleReporterReceiver {
70
70
  }
71
71
  _onBegin(config, projects) {
72
72
  var _this$_reporter$onBeg, _this$_reporter;
73
- const removeMissing = config.listOnly;
74
73
  for (const project of projects) {
75
74
  let projectSuite = this._rootSuite.suites.find(suite => suite.project().id === project.id);
76
75
  if (!projectSuite) {
@@ -80,7 +79,23 @@ class TeleReporterReceiver {
80
79
  }
81
80
  const p = this._parseProject(project);
82
81
  projectSuite.project = () => p;
83
- this._mergeSuitesInto(project.suites, projectSuite, removeMissing);
82
+ this._mergeSuitesInto(project.suites, projectSuite);
83
+
84
+ // Remove deleted tests when listing. Empty suites will be auto-filtered
85
+ // in the UI layer.
86
+ if (config.listOnly) {
87
+ const testIds = new Set();
88
+ const collectIds = suite => {
89
+ suite.tests.map(t => t.testId).forEach(testId => testIds.add(testId));
90
+ suite.suites.forEach(collectIds);
91
+ };
92
+ project.suites.forEach(collectIds);
93
+ const filterTests = suite => {
94
+ suite.tests = suite.tests.filter(t => testIds.has(t.id));
95
+ suite.suites.forEach(filterTests);
96
+ };
97
+ filterTests(projectSuite);
98
+ }
84
99
  }
85
100
  (_this$_reporter$onBeg = (_this$_reporter = this._reporter).onBegin) === null || _this$_reporter$onBeg === void 0 ? void 0 : _this$_reporter$onBeg.call(_this$_reporter, this._parseConfig(config), this._rootSuite);
86
101
  }
@@ -92,6 +107,7 @@ class TeleReporterReceiver {
92
107
  testResult.workerIndex = payload.workerIndex;
93
108
  testResult.parallelIndex = payload.parallelIndex;
94
109
  testResult.startTime = new Date(payload.startTime);
110
+ testResult.statusEx = 'running';
95
111
  (_this$_reporter$onTes = (_this$_reporter2 = this._reporter).onTestBegin) === null || _this$_reporter$onTes === void 0 ? void 0 : _this$_reporter$onTes.call(_this$_reporter2, test, testResult);
96
112
  }
97
113
  _onTestEnd(testId, payload) {
@@ -100,6 +116,7 @@ class TeleReporterReceiver {
100
116
  const result = test.resultsMap.get(payload.id);
101
117
  result.duration = payload.duration;
102
118
  result.status = payload.status;
119
+ result.statusEx = payload.status;
103
120
  result.errors = payload.errors;
104
121
  result.attachments = payload.attachments;
105
122
  (_this$_reporter$onTes2 = (_this$_reporter3 = this._reporter).onTestEnd) === null || _this$_reporter$onTes2 === void 0 ? void 0 : _this$_reporter$onTes2.call(_this$_reporter3, test, result);
@@ -174,7 +191,7 @@ class TeleReporterReceiver {
174
191
  use: {}
175
192
  };
176
193
  }
177
- _mergeSuitesInto(jsonSuites, parent, removeMissing) {
194
+ _mergeSuitesInto(jsonSuites, parent) {
178
195
  for (const jsonSuite of jsonSuites) {
179
196
  let targetSuite = parent.suites.find(s => s.title === jsonSuite.title);
180
197
  if (!targetSuite) {
@@ -185,15 +202,11 @@ class TeleReporterReceiver {
185
202
  targetSuite.location = jsonSuite.location;
186
203
  targetSuite._fileId = jsonSuite.fileId;
187
204
  targetSuite._parallelMode = jsonSuite.parallelMode;
188
- this._mergeSuitesInto(jsonSuite.suites, targetSuite, removeMissing);
189
- this._mergeTestsInto(jsonSuite.tests, targetSuite, removeMissing);
190
- }
191
- if (removeMissing) {
192
- const suiteMap = new Map(parent.suites.map(p => [p.title, p]));
193
- parent.suites = jsonSuites.map(s => suiteMap.get(s.title)).filter(Boolean);
205
+ this._mergeSuitesInto(jsonSuite.suites, targetSuite);
206
+ this._mergeTestsInto(jsonSuite.tests, targetSuite);
194
207
  }
195
208
  }
196
- _mergeTestsInto(jsonTests, parent, removeMissing) {
209
+ _mergeTestsInto(jsonTests, parent) {
197
210
  for (const jsonTest of jsonTests) {
198
211
  let targetTest = parent.tests.find(s => s.title === jsonTest.title);
199
212
  if (!targetTest) {
@@ -204,10 +217,6 @@ class TeleReporterReceiver {
204
217
  }
205
218
  this._updateTest(jsonTest, targetTest);
206
219
  }
207
- if (removeMissing) {
208
- const testMap = new Map(parent.tests.map(p => [p.title, p]));
209
- parent.tests = jsonTests.map(s => testMap.get(s.title)).filter(Boolean);
210
- }
211
220
  }
212
221
  _updateTest(payload, test) {
213
222
  test.id = payload.testId;
@@ -307,6 +316,7 @@ class TeleTestCase {
307
316
  stderr: [],
308
317
  attachments: [],
309
318
  status: 'skipped',
319
+ statusEx: 'scheduled',
310
320
  steps: [],
311
321
  errors: [],
312
322
  stepMap: new Map(),
@@ -34,6 +34,7 @@ class UIMode {
34
34
  this._page = void 0;
35
35
  this._testRun = void 0;
36
36
  this.globalCleanup = void 0;
37
+ this._globalWatcher = void 0;
37
38
  this._testWatcher = void 0;
38
39
  this._originalStderr = void 0;
39
40
  this._config = config;
@@ -53,28 +54,22 @@ class UIMode {
53
54
  sources: false
54
55
  };
55
56
  this._originalStderr = process.stderr.write.bind(process.stderr);
56
- this._installGlobalWatcher();
57
- }
58
- _installGlobalWatcher() {
59
- const projectDirs = new Set();
60
- for (const p of this._config.projects) projectDirs.add(p.testDir);
61
- let coalescingTimer;
62
- const watcher = _utilsBundle.chokidar.watch([...projectDirs], {
63
- ignoreInitial: true,
64
- persistent: true
65
- }).on('all', async event => {
66
- if (event !== 'add' && event !== 'change' && event !== 'unlink') return;
67
- if (coalescingTimer) clearTimeout(coalescingTimer);
68
- coalescingTimer = setTimeout(() => {
69
- this._dispatchEvent({
70
- method: 'listChanged'
71
- });
72
- }, 200);
57
+ this._globalWatcher = new Watcher('deep', () => this._dispatchEvent({
58
+ method: 'listChanged'
59
+ }));
60
+ this._testWatcher = new Watcher('flat', events => {
61
+ const collector = new Set();
62
+ events.forEach(f => (0, _compilationCache.collectAffectedTestFiles)(f.file, collector));
63
+ this._dispatchEvent({
64
+ method: 'testFilesChanged',
65
+ params: {
66
+ testFileNames: [...collector]
67
+ }
68
+ });
73
69
  });
74
- return watcher;
75
70
  }
76
71
  async runGlobalSetup() {
77
- const reporter = await (0, _reporters.createReporter)(this._config, 'watch');
72
+ const reporter = await (0, _reporters.createReporter)(this._config, 'run');
78
73
  const taskRunner = (0, _tasks.createTaskRunnerForWatchSetup)(this._config, reporter);
79
74
  reporter.onConfigure(this._config);
80
75
  const context = {
@@ -86,6 +81,9 @@ class UIMode {
86
81
  status,
87
82
  cleanup: globalCleanup
88
83
  } = await taskRunner.runDeferCleanup(context, 0);
84
+ await reporter.onExit({
85
+ status
86
+ });
89
87
  if (status !== 'passed') {
90
88
  await globalCleanup();
91
89
  return status;
@@ -172,9 +170,12 @@ class UIMode {
172
170
  (0, _compilationCache.clearCompilationCache)();
173
171
  reporter.onConfigure(this._config);
174
172
  const status = await taskRunner.run(context, 0);
175
- reporter.onExit({
173
+ await reporter.onExit({
176
174
  status
177
175
  });
176
+ const projectDirs = new Set();
177
+ for (const p of this._config.projects) projectDirs.add(p.testDir);
178
+ this._globalWatcher.update([...projectDirs], false);
178
179
  }
179
180
  async _runTests(testIds) {
180
181
  await this._stopTests();
@@ -212,43 +213,7 @@ class UIMode {
212
213
  files.add(fileName);
213
214
  (0, _compilationCache.dependenciesForTestFile)(fileName).forEach(file => files.add(file));
214
215
  }
215
- const watchedFiles = [...files].sort();
216
- if (this._testWatcher && JSON.stringify(this._testWatcher.watchedFiles) === JSON.stringify(watchedFiles)) return;
217
- if (this._testWatcher) {
218
- if (this._testWatcher.collector.size) this._dispatchEvent({
219
- method: 'filesChanged',
220
- params: {
221
- fileNames: [...this._testWatcher.collector]
222
- }
223
- });
224
- clearTimeout(this._testWatcher.timer);
225
- this._testWatcher.watcher.close().then(() => {});
226
- this._testWatcher = undefined;
227
- }
228
- if (!watchedFiles.length) return;
229
- const collector = new Set();
230
- const watcher = _utilsBundle.chokidar.watch(watchedFiles, {
231
- ignoreInitial: true
232
- }).on('all', async (event, file) => {
233
- if (event !== 'add' && event !== 'change') return;
234
- (0, _compilationCache.collectAffectedTestFiles)(file, collector);
235
- if (this._testWatcher.timer) clearTimeout(this._testWatcher.timer);
236
- this._testWatcher.timer = setTimeout(() => {
237
- const fileNames = [...collector];
238
- collector.clear();
239
- this._dispatchEvent({
240
- method: 'filesChanged',
241
- params: {
242
- fileNames
243
- }
244
- });
245
- }, 250);
246
- });
247
- this._testWatcher = {
248
- watcher,
249
- watchedFiles,
250
- collector
251
- };
216
+ this._testWatcher.update([...files], true);
252
217
  }
253
218
  async _stopTests() {
254
219
  var _this$_testRun, _this$_testRun$stop, _this$_testRun2;
@@ -276,4 +241,44 @@ function chunkToPayload(type, chunk) {
276
241
  type,
277
242
  text: chunk
278
243
  };
244
+ }
245
+ class Watcher {
246
+ constructor(mode, onChange) {
247
+ this._onChange = void 0;
248
+ this._watchedFiles = [];
249
+ this._collector = [];
250
+ this._fsWatcher = void 0;
251
+ this._throttleTimer = void 0;
252
+ this._mode = void 0;
253
+ this._mode = mode;
254
+ this._onChange = onChange;
255
+ }
256
+ update(watchedFiles, reportPending) {
257
+ var _this$_fsWatcher;
258
+ if (JSON.stringify(this._watchedFiles) === JSON.stringify(watchedFiles)) return;
259
+ if (reportPending) this._reportEventsIfAny();
260
+ this._watchedFiles = watchedFiles;
261
+ (_this$_fsWatcher = this._fsWatcher) === null || _this$_fsWatcher === void 0 ? void 0 : _this$_fsWatcher.close().then(() => {});
262
+ this._fsWatcher = undefined;
263
+ this._collector.length = 0;
264
+ clearTimeout(this._throttleTimer);
265
+ this._throttleTimer = undefined;
266
+ if (!this._watchedFiles.length) return;
267
+ this._fsWatcher = _utilsBundle.chokidar.watch(watchedFiles, {
268
+ ignoreInitial: true
269
+ }).on('all', async (event, file) => {
270
+ if (this._throttleTimer) clearTimeout(this._throttleTimer);
271
+ if (this._mode === 'flat' && event !== 'add' && event !== 'change') return;
272
+ if (this._mode === 'deep' && event !== 'add' && event !== 'change' && event !== 'unlink' && event !== 'addDir' && event !== 'unlinkDir') return;
273
+ this._collector.push({
274
+ event,
275
+ file
276
+ });
277
+ this._throttleTimer = setTimeout(() => this._reportEventsIfAny(), 250);
278
+ });
279
+ }
280
+ _reportEventsIfAny() {
281
+ if (this._collector.length) this._onChange(this._collector.slice());
282
+ this._collector.length = 0;
283
+ }
279
284
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playwright/test",
3
- "version": "1.32.0",
3
+ "version": "1.32.1-beta-1679703607000",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": "github:Microsoft/playwright",
6
6
  "homepage": "https://playwright.dev",
@@ -34,7 +34,7 @@
34
34
  "license": "Apache-2.0",
35
35
  "dependencies": {
36
36
  "@types/node": "*",
37
- "playwright-core": "1.32.0"
37
+ "playwright-core": "1.32.1-beta-1679703607000"
38
38
  },
39
39
  "optionalDependencies": {
40
40
  "fsevents": "2.3.2"