@playwright/test 1.35.0-alpha-jun-5-2023 → 1.35.0-alpha-jun-6-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/.eslintrc.js CHANGED
@@ -1,3 +1,15 @@
1
+ const path = require('path');
2
+
1
3
  module.exports = {
2
- extends: "../.eslintrc-with-ts-config.js",
4
+ extends: '../.eslintrc.js',
5
+ parser: "@typescript-eslint/parser",
6
+ plugins: ["@typescript-eslint", "notice"],
7
+ parserOptions: {
8
+ ecmaVersion: 9,
9
+ sourceType: "module",
10
+ project: path.join(__dirname, '..', '..', 'tsconfig.json'),
11
+ },
12
+ rules: {
13
+ '@typescript-eslint/no-floating-promises': 'error',
14
+ },
3
15
  };
@@ -99,7 +99,6 @@ This project incorporates components from the projects listed below. The origina
99
99
  - color-name@1.1.4 (https://github.com/colorjs/color-name)
100
100
  - convert-source-map@1.8.0 (https://github.com/thlorenz/convert-source-map)
101
101
  - debug@4.3.4 (https://github.com/debug-js/debug)
102
- - define-lazy-prop@2.0.0 (https://github.com/sindresorhus/define-lazy-prop)
103
102
  - diff-sequences@27.5.1 (https://github.com/facebook/jest)
104
103
  - electron-to-chromium@1.4.337 (https://github.com/kilian/electron-to-chromium)
105
104
  - enquirer@2.3.6 (https://github.com/enquirer/enquirer)
@@ -115,11 +114,9 @@ This project incorporates components from the projects listed below. The origina
115
114
  - has-flag@3.0.0 (https://github.com/sindresorhus/has-flag)
116
115
  - has-flag@4.0.0 (https://github.com/sindresorhus/has-flag)
117
116
  - is-binary-path@2.1.0 (https://github.com/sindresorhus/is-binary-path)
118
- - is-docker@2.2.1 (https://github.com/sindresorhus/is-docker)
119
117
  - is-extglob@2.1.1 (https://github.com/jonschlinkert/is-extglob)
120
118
  - is-glob@4.0.3 (https://github.com/micromatch/is-glob)
121
119
  - is-number@7.0.0 (https://github.com/jonschlinkert/is-number)
122
- - is-wsl@2.2.0 (https://github.com/sindresorhus/is-wsl)
123
120
  - jest-diff@27.5.1 (https://github.com/facebook/jest)
124
121
  - jest-get-type@27.5.1 (https://github.com/facebook/jest)
125
122
  - jest-matcher-utils@27.2.5 (https://github.com/facebook/jest)
@@ -133,7 +130,6 @@ This project incorporates components from the projects listed below. The origina
133
130
  - ms@2.1.2 (https://github.com/zeit/ms)
134
131
  - node-releases@2.0.10 (https://github.com/chicoxyzzy/node-releases)
135
132
  - normalize-path@3.0.0 (https://github.com/jonschlinkert/normalize-path)
136
- - open@8.4.0 (https://github.com/sindresorhus/open)
137
133
  - picocolors@1.0.0 (https://github.com/alexeyraspopov/picocolors)
138
134
  - picomatch@2.3.1 (https://github.com/micromatch/picomatch)
139
135
  - pirates@4.0.4 (https://github.com/danez/pirates)
@@ -3105,20 +3101,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3105
3101
  =========================================
3106
3102
  END OF debug@4.3.4 AND INFORMATION
3107
3103
 
3108
- %% define-lazy-prop@2.0.0 NOTICES AND INFORMATION BEGIN HERE
3109
- =========================================
3110
- MIT License
3111
-
3112
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3113
-
3114
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3115
-
3116
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
3117
-
3118
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3119
- =========================================
3120
- END OF define-lazy-prop@2.0.0 AND INFORMATION
3121
-
3122
3104
  %% diff-sequences@27.5.1 NOTICES AND INFORMATION BEGIN HERE
3123
3105
  =========================================
3124
3106
  MIT License
@@ -3395,20 +3377,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
3395
3377
  =========================================
3396
3378
  END OF is-binary-path@2.1.0 AND INFORMATION
3397
3379
 
3398
- %% is-docker@2.2.1 NOTICES AND INFORMATION BEGIN HERE
3399
- =========================================
3400
- MIT License
3401
-
3402
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
3403
-
3404
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3405
-
3406
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
3407
-
3408
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3409
- =========================================
3410
- END OF is-docker@2.2.1 AND INFORMATION
3411
-
3412
3380
  %% is-extglob@2.1.1 NOTICES AND INFORMATION BEGIN HERE
3413
3381
  =========================================
3414
3382
  The MIT License (MIT)
@@ -3487,20 +3455,6 @@ THE SOFTWARE.
3487
3455
  =========================================
3488
3456
  END OF is-number@7.0.0 AND INFORMATION
3489
3457
 
3490
- %% is-wsl@2.2.0 NOTICES AND INFORMATION BEGIN HERE
3491
- =========================================
3492
- MIT License
3493
-
3494
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3495
-
3496
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3497
-
3498
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
3499
-
3500
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3501
- =========================================
3502
- END OF is-wsl@2.2.0 AND INFORMATION
3503
-
3504
3458
  %% jest-diff@27.5.1 NOTICES AND INFORMATION BEGIN HERE
3505
3459
  =========================================
3506
3460
  MIT License
@@ -3834,20 +3788,6 @@ THE SOFTWARE.
3834
3788
  =========================================
3835
3789
  END OF normalize-path@3.0.0 AND INFORMATION
3836
3790
 
3837
- %% open@8.4.0 NOTICES AND INFORMATION BEGIN HERE
3838
- =========================================
3839
- MIT License
3840
-
3841
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
3842
-
3843
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3844
-
3845
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
3846
-
3847
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3848
- =========================================
3849
- END OF open@8.4.0 AND INFORMATION
3850
-
3851
3791
  %% picocolors@1.0.0 NOTICES AND INFORMATION BEGIN HERE
3852
3792
  =========================================
3853
3793
  ISC License
@@ -4284,6 +4224,6 @@ END OF yallist@3.1.1 AND INFORMATION
4284
4224
 
4285
4225
  SUMMARY BEGIN HERE
4286
4226
  =========================================
4287
- Total Packages: 149
4227
+ Total Packages: 145
4288
4228
  =========================================
4289
4229
  END OF SUMMARY
@@ -57,7 +57,7 @@ process.on('message', async message => {
57
57
  } = message.params;
58
58
  setTtyParams(process.stdout, processParams.stdoutParams);
59
59
  setTtyParams(process.stderr, processParams.stderrParams);
60
- (0, _utils.startProfiling)();
60
+ void (0, _utils.startProfiling)();
61
61
  const {
62
62
  create
63
63
  } = require(runnerScript);
package/lib/index.js CHANGED
@@ -95,12 +95,12 @@ const playwrightFixtures = {
95
95
  scope: 'worker',
96
96
  option: true
97
97
  }],
98
- connectOptions: [({}, use) => {
98
+ connectOptions: [async ({}, use) => {
99
99
  // Usually, when connect options are specified (e.g, in the config or in the environment),
100
100
  // all launch() calls are turned into connect() calls.
101
101
  // However, when running in "reuse browser" mode and connecting to the reusable server,
102
102
  // only the default "browser" fixture should turn into reused browser.
103
- use(process.env.PW_TEST_REUSE_CONTEXT ? undefined : connectOptionsFromEnv());
103
+ await use(process.env.PW_TEST_REUSE_CONTEXT ? undefined : connectOptionsFromEnv());
104
104
  }, {
105
105
  scope: 'worker',
106
106
  option: true
@@ -149,6 +149,11 @@ class SnapshotHelper {
149
149
  if (isWriteMissingMode) {
150
150
  writeFileSync(this.snapshotPath, actual);
151
151
  writeFileSync(this.actualPath, actual);
152
+ this.testInfo.attachments.push({
153
+ name: (0, _util.addSuffixToFilePath)(this.snapshotName, '-actual'),
154
+ contentType: this.mimeType,
155
+ path: this.actualPath
156
+ });
152
157
  }
153
158
  const message = `A snapshot doesn't exist at ${this.snapshotPath}${isWriteMissingMode ? ', writing actual.' : '.'}`;
154
159
  if (this.updateSnapshots === 'all') {
@@ -52,7 +52,7 @@ class GitHubReporter extends _base.BaseReporter {
52
52
  return false;
53
53
  }
54
54
  async onEnd(result) {
55
- super.onEnd(result);
55
+ await super.onEnd(result);
56
56
  this._printAnnotations();
57
57
  }
58
58
  onError(error) {
@@ -8,7 +8,6 @@ exports.showHTMLReport = showHTMLReport;
8
8
  exports.startHtmlReportServer = startHtmlReportServer;
9
9
  var _utilsBundle = require("playwright-core/lib/utilsBundle");
10
10
  var _fs = _interopRequireDefault(require("fs"));
11
- var _utilsBundle2 = require("../utilsBundle");
12
11
  var _path = _interopRequireDefault(require("path"));
13
12
  var _stream = require("stream");
14
13
  var _utils = require("playwright-core/lib/utils");
@@ -153,7 +152,7 @@ async function showHTMLReport(reportFolder, host = 'localhost', port, testId) {
153
152
  console.log('');
154
153
  console.log(_utilsBundle.colors.cyan(` Serving HTML report at ${url}. Press Ctrl+C to quit.`));
155
154
  if (testId) url += `#?testId=${testId}`;
156
- await (0, _utilsBundle2.open)(url, {
155
+ await (0, _utilsBundle.open)(url, {
157
156
  wait: true
158
157
  }).catch(() => console.log(`Failed to open browser on ${url}`));
159
158
  await new Promise(() => {});
@@ -28,6 +28,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
28
28
 
29
29
  async function createMergedReport(config, dir, reporterDescriptions, resolvePaths) {
30
30
  const shardFiles = await sortedShardFiles(dir);
31
+ if (shardFiles.length === 0) throw new Error(`No report files found in ${dir}`);
31
32
  const events = await mergeEvents(dir, shardFiles);
32
33
  if (resolvePaths) patchAttachmentPaths(events, dir);
33
34
  const reporters = await (0, _reporters.createReporters)(config, 'merge', reporterDescriptions);
@@ -88,7 +88,7 @@ class Dispatcher {
88
88
  this._checkFinished();
89
89
 
90
90
  // 5. We got a free worker - perhaps we can immediately start another job?
91
- this._scheduleJob();
91
+ void this._scheduleJob();
92
92
  }
93
93
  async _startJobInWorker(index, job) {
94
94
  let worker = this._workerSlots[index].worker;
@@ -156,7 +156,7 @@ class Dispatcher {
156
156
  busy: false
157
157
  });
158
158
  // 2. Schedule enough jobs.
159
- for (let i = 0; i < this._workerSlots.length; i++) this._scheduleJob();
159
+ for (let i = 0; i < this._workerSlots.length; i++) void this._scheduleJob();
160
160
  this._checkFinished();
161
161
  // 3. More jobs are scheduled when the worker becomes free, or a new job is added.
162
162
  // 4. Wait for all jobs to finish.
@@ -306,13 +306,13 @@ class Dispatcher {
306
306
  // - we are here not because something failed
307
307
  // - no unrecoverable worker error
308
308
  if (!remaining.length && !failedTestIds.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.unexpectedExitError) {
309
- if (this._isWorkerRedundant(worker)) worker.stop();
309
+ if (this._isWorkerRedundant(worker)) void worker.stop();
310
310
  doneWithJob();
311
311
  return;
312
312
  }
313
313
 
314
314
  // When worker encounters error, we will stop it and create a new one.
315
- worker.stop(true /* didFail */);
315
+ void worker.stop(true /* didFail */);
316
316
 
317
317
  const massSkipTestsFromRemaining = (testIds, errors, onlyStartedTests) => {
318
318
  remaining = remaining.filter(test => {
@@ -409,7 +409,7 @@ class Dispatcher {
409
409
  });
410
410
  this._queuedOrRunningHashCount.set(testGroup.workerHash, this._queuedOrRunningHashCount.get(testGroup.workerHash) + 1);
411
411
  // Perhaps we can immediately start the new job if there is a worker available?
412
- this._scheduleJob();
412
+ void this._scheduleJob();
413
413
  }
414
414
 
415
415
  // This job is over, we just scheduled another one.
@@ -12,6 +12,7 @@ var _teleEmitter = require("../reporters/teleEmitter");
12
12
  var _reporters = require("./reporters");
13
13
  var _tasks = require("./tasks");
14
14
  var _utilsBundle = require("../utilsBundle");
15
+ var _utilsBundle2 = require("playwright-core/lib/utilsBundle");
15
16
  var _list = _interopRequireDefault(require("../reporters/list"));
16
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18
  /**
@@ -93,7 +94,7 @@ class UIMode {
93
94
  return status;
94
95
  }
95
96
  async showUI() {
96
- this._page = await (0, _server.showTraceViewer)([], 'chromium', {
97
+ this._page = await (0, _server.openTraceViewerApp)([], 'chromium', {
97
98
  app: 'uiMode.html',
98
99
  headless: (0, _utils.isUnderTest)() && process.env.PWTEST_HEADED_FOR_TEST !== '1'
99
100
  });
@@ -116,7 +117,7 @@ class UIMode {
116
117
  const exitPromise = new _utils.ManualPromise();
117
118
  this._page.on('close', () => exitPromise.resolve());
118
119
  let queue = Promise.resolve();
119
- this._page.exposeBinding('sendMessage', false, async (source, data) => {
120
+ await this._page.exposeBinding('sendMessage', false, async (source, data) => {
120
121
  const {
121
122
  method,
122
123
  params
@@ -130,7 +131,7 @@ class UIMode {
130
131
  return;
131
132
  }
132
133
  if (method === 'open' && params.location) {
133
- (0, _utilsBundle.open)('vscode://file/' + params.location).catch(e => this._originalStderrWrite.call(process.stderr, String(e)));
134
+ (0, _utilsBundle2.open)('vscode://file/' + params.location).catch(e => this._originalStderrWrite.call(process.stderr, String(e)));
134
135
  return;
135
136
  }
136
137
  if (method === 'resizeTerminal') {
@@ -141,7 +142,7 @@ class UIMode {
141
142
  return;
142
143
  }
143
144
  if (method === 'stop') {
144
- this._stopTests();
145
+ void this._stopTests();
145
146
  return;
146
147
  }
147
148
  queue = queue.then(() => this._queueListOrRun(method, params));
@@ -209,7 +210,7 @@ class UIMode {
209
210
  };
210
211
  await run;
211
212
  }
212
- async _watchFiles(fileNames) {
213
+ _watchFiles(fileNames) {
213
214
  const files = new Set();
214
215
  for (const fileName of fileNames) {
215
216
  files.add(fileName);
@@ -260,7 +261,7 @@ class Watcher {
260
261
  if (JSON.stringify(this._watchedFiles) === JSON.stringify(watchedFiles)) return;
261
262
  if (reportPending) this._reportEventsIfAny();
262
263
  this._watchedFiles = watchedFiles;
263
- (_this$_fsWatcher = this._fsWatcher) === null || _this$_fsWatcher === void 0 ? void 0 : _this$_fsWatcher.close().then(() => {});
264
+ void ((_this$_fsWatcher = this._fsWatcher) === null || _this$_fsWatcher === void 0 ? void 0 : _this$_fsWatcher.close());
264
265
  this._fsWatcher = undefined;
265
266
  this._collector.length = 0;
266
267
  clearTimeout(this._throttleTimer);
package/lib/util.js CHANGED
@@ -296,13 +296,30 @@ function envWithoutExperimentalLoaderOptions() {
296
296
  // https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-beta/#moduleresolution-bundler
297
297
  const kExtLookups = new Map([['.js', ['.jsx', '.ts', '.tsx']], ['.jsx', ['.tsx']], ['.cjs', ['.cts']], ['.mjs', ['.mts']], ['', ['.js', '.ts', '.jsx', '.tsx', '.cjs', '.mjs', '.cts', '.mts']]]);
298
298
  function resolveImportSpecifierExtension(resolved) {
299
- if (_fs.default.existsSync(resolved)) return resolved;
299
+ if (fileExists(resolved)) return resolved;
300
300
  for (const [ext, others] of kExtLookups) {
301
301
  if (!resolved.endsWith(ext)) continue;
302
302
  for (const other of others) {
303
303
  const modified = resolved.substring(0, resolved.length - ext.length) + other;
304
- if (_fs.default.existsSync(modified)) return modified;
304
+ if (fileExists(modified)) return modified;
305
305
  }
306
306
  break; // Do not try '' when a more specific extesion like '.jsx' matched.
307
307
  }
308
+ // try directory imports last
309
+ if (dirExists(resolved)) {
310
+ const dirImport = _path.default.join(resolved, 'index');
311
+ return resolveImportSpecifierExtension(dirImport);
312
+ }
313
+ }
314
+ function fileExists(resolved) {
315
+ var _fs$statSync;
316
+ return (_fs$statSync = _fs.default.statSync(resolved, {
317
+ throwIfNoEntry: false
318
+ })) === null || _fs$statSync === void 0 ? void 0 : _fs$statSync.isFile();
319
+ }
320
+ function dirExists(resolved) {
321
+ var _fs$statSync2;
322
+ return (_fs$statSync2 = _fs.default.statSync(resolved, {
323
+ throwIfNoEntry: false
324
+ })) === null || _fs$statSync2 === void 0 ? void 0 : _fs$statSync2.isDirectory();
308
325
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.stoppable = exports.sourceMapSupport = exports.pirates = exports.open = exports.json5 = exports.enquirer = exports.chokidar = void 0;
6
+ exports.stoppable = exports.sourceMapSupport = exports.pirates = exports.json5 = exports.enquirer = exports.chokidar = void 0;
7
7
  /**
8
8
  * Copyright (c) Microsoft Corporation.
9
9
  *
@@ -22,8 +22,6 @@ exports.stoppable = exports.sourceMapSupport = exports.pirates = exports.open =
22
22
 
23
23
  const json5 = require('./utilsBundleImpl').json5;
24
24
  exports.json5 = json5;
25
- const open = require('./utilsBundleImpl').open;
26
- exports.open = open;
27
25
  const pirates = require('./utilsBundleImpl').pirates;
28
26
  exports.pirates = pirates;
29
27
  const sourceMapSupport = require('./utilsBundleImpl').sourceMapSupport;