@playwright/test 1.34.0-alpha-may-3-2023 → 1.34.0-alpha-may-5-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/jsx-runtime.js ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ function jsx(type, props) {
18
+ return {
19
+ type,
20
+ props,
21
+ };
22
+ }
23
+
24
+ function jsxs(type, props) {
25
+ return {
26
+ type,
27
+ props,
28
+ };
29
+ }
30
+
31
+ module.exports = {
32
+ jsx,
33
+ jsxs,
34
+ };
package/lib/cli.js CHANGED
@@ -10,6 +10,7 @@ var _merge = require("./reporters/merge");
10
10
  var _configLoader = require("./common/configLoader");
11
11
  var _config = require("./common/config");
12
12
  var _program = _interopRequireDefault(require("playwright-core/lib/cli/program"));
13
+ var _base = require("./reporters/base");
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  /**
15
16
  * Copyright (c) Microsoft Corporation.
@@ -130,18 +131,29 @@ async function runTests(args, opts) {
130
131
  }
131
132
  async function listTestFiles(opts) {
132
133
  // Redefine process.stdout.write in case config decides to pollute stdio.
133
- const write = process.stdout.write.bind(process.stdout);
134
+ const stdoutWrite = process.stdout.write.bind(process.stdout);
134
135
  process.stdout.write = () => {};
136
+ process.stderr.write = () => {};
135
137
  const configFileOrDirectory = opts.config ? _path.default.resolve(process.cwd(), opts.config) : process.cwd();
136
138
  const resolvedConfigFile = (0, _configLoader.resolveConfigFile)(configFileOrDirectory);
137
139
  if (restartWithExperimentalTsEsm(resolvedConfigFile)) return;
138
- const configLoader = new _configLoader.ConfigLoader();
139
- const config = await configLoader.loadConfigFile(resolvedConfigFile);
140
- const runner = new _runner.Runner(config);
141
- const report = await runner.listTestFiles(opts.project);
142
- write(JSON.stringify(report), () => {
143
- process.exit(0);
144
- });
140
+ try {
141
+ const configLoader = new _configLoader.ConfigLoader();
142
+ const config = await configLoader.loadConfigFile(resolvedConfigFile);
143
+ const runner = new _runner.Runner(config);
144
+ const report = await runner.listTestFiles(opts.project);
145
+ stdoutWrite(JSON.stringify(report), () => {
146
+ process.exit(0);
147
+ });
148
+ } catch (e) {
149
+ const error = (0, _util.serializeError)(e);
150
+ error.location = (0, _base.prepareErrorStack)(e.stack).location;
151
+ stdoutWrite(JSON.stringify({
152
+ error
153
+ }), () => {
154
+ process.exit(0);
155
+ });
156
+ }
145
157
  }
146
158
  async function mergeReports(reportDir, opts) {
147
159
  let configFile = opts.config;
@@ -2113,4 +2113,4 @@ If you are using Webpack or Rollup and thus don't want
2113
2113
  Babel to transpile your imports and exports, you can use
2114
2114
  the @babel/plugin-syntax-dynamic-import plugin and let your
2115
2115
  bundler handle dynamic imports.
2116
- `,tDe=(0,Jwe.declare)(e=>(e.assertVersion(7),{name:"proposal-dynamic-import",inherits:Qwe.default,pre(){this.file.set("@babel/plugin-proposal-dynamic-import","7.18.6")},visitor:{Program(){let t=this.file.get("@babel/plugin-transform-modules-*");if(!Zwe.includes(t))throw new Error(eDe)}}}));pd.default=tDe});var qF=T(dd=>{"use strict";Object.defineProperty(dd,"__esModule",{value:!0});dd.default=void 0;var rDe=nt(),nDe=(0,rDe.declare)(e=>(e.assertVersion(7),{name:"syntax-import-assertions",manipulateOptions(t,r){r.plugins.push("importAssertions")}}));dd.default=nDe});var oDe={};eB(oDe,{babelTransform:()=>aDe,codeFrameColumns:()=>KF.codeFrameColumns,declare:()=>WF.declare,parse:()=>zF.parse,setBabelPlugins:()=>sDe,traverse:()=>iDe,types:()=>GF.types});module.exports=tB(oDe);var UF=ls(Pt()),KF=ls(Is()),WF=ls(nt()),GF=ls(Pt()),zF=ls($s()),$F=ls(gr()),iDe=$F.default,VF=[];function sDe(e){VF=e}function aDe(e,t,r,n){let i=[];return t&&i.push([iF(),{version:"2022-03"}],[aF()],[uF()],[pF()],[hF()],[yF()],[TF()],[SF()],[xF()],[PF()],[AF()],[CF()],[DF()],[({template:s})=>({name:"replace-ts-export-assignment",visitor:{TSExportAssignment(a){a.replaceWith(s("module.exports = ASSIGNMENT;")({ASSIGNMENT:a.node.expression}))}}})]),i.push([kF()]),r?i.push([qF()]):(i.push([jF()]),i.push([RF()])),i.unshift(...VF.map(([s,a])=>[require(s),a])),n&&i.push([n]),UF.transformFileSync(e,{babelrc:!1,configFile:!1,assumptions:{setPublicClassFields:!0},presets:[[tT(),{onlyRemoveTypeImports:!1}]],plugins:i,sourceMaps:"both"})}0&&(module.exports={babelTransform,codeFrameColumns,declare,parse,setBabelPlugins,traverse,types});
2116
+ `,tDe=(0,Jwe.declare)(e=>(e.assertVersion(7),{name:"proposal-dynamic-import",inherits:Qwe.default,pre(){this.file.set("@babel/plugin-proposal-dynamic-import","7.18.6")},visitor:{Program(){let t=this.file.get("@babel/plugin-transform-modules-*");if(!Zwe.includes(t))throw new Error(eDe)}}}));pd.default=tDe});var qF=T(dd=>{"use strict";Object.defineProperty(dd,"__esModule",{value:!0});dd.default=void 0;var rDe=nt(),nDe=(0,rDe.declare)(e=>(e.assertVersion(7),{name:"syntax-import-assertions",manipulateOptions(t,r){r.plugins.push("importAssertions")}}));dd.default=nDe});var oDe={};eB(oDe,{babelTransform:()=>aDe,codeFrameColumns:()=>KF.codeFrameColumns,declare:()=>WF.declare,parse:()=>zF.parse,setBabelPlugins:()=>sDe,traverse:()=>iDe,types:()=>GF.types});module.exports=tB(oDe);var UF=ls(Pt()),KF=ls(Is()),WF=ls(nt()),GF=ls(Pt()),zF=ls($s()),$F=ls(gr()),iDe=$F.default,VF=[];function sDe(e){VF=e}function aDe(e,t,r,n){let i=[];return t&&i.push([iF(),{version:"2022-03"}],[aF()],[uF()],[pF()],[hF()],[yF()],[TF()],[SF()],[xF()],[PF()],[AF()],[CF()],[DF()],[({template:s})=>({name:"replace-ts-export-assignment",visitor:{TSExportAssignment(a){a.replaceWith(s("module.exports = ASSIGNMENT;")({ASSIGNMENT:a.node.expression}))}}})]),i.push([kF(),{runtime:"automatic",importSource:"@playwright/test"}]),r?i.push([qF()]):(i.push([jF()]),i.push([RF()])),i.unshift(...VF.map(([s,a])=>[require(s),a])),n&&i.push([n]),UF.transformFileSync(e,{babelrc:!1,configFile:!1,assumptions:{setPublicClassFields:!0},presets:[[tT(),{onlyRemoveTypeImports:!1}]],plugins:i,sourceMaps:"both"})}0&&(module.exports={babelTransform,codeFrameColumns,declare,parse,setBabelPlugins,traverse,types});
@@ -37,16 +37,17 @@ function validateTsConfig(tsconfig) {
37
37
  if (!tsconfig.tsConfigPath || !tsconfig.baseUrl) return;
38
38
  // Make 'baseUrl' absolute, because it is relative to the tsconfig.json, not to cwd.
39
39
  const absoluteBaseUrl = _path.default.resolve(_path.default.dirname(tsconfig.tsConfigPath), tsconfig.baseUrl);
40
- const paths = tsconfig.paths || {
41
- '*': ['*']
42
- };
40
+ const pathsFallback = [{
41
+ key: '*',
42
+ values: ['*']
43
+ }];
43
44
  return {
44
45
  allowJs: tsconfig.allowJs,
45
46
  absoluteBaseUrl,
46
- paths: Object.entries(paths).map(([key, values]) => ({
47
+ paths: Object.entries(tsconfig.paths || {}).map(([key, values]) => ({
47
48
  key,
48
49
  values
49
- }))
50
+ })).concat(pathsFallback)
50
51
  };
51
52
  }
52
53
  function loadAndValidateTsconfigForFile(file) {
package/lib/index.js CHANGED
@@ -440,7 +440,8 @@ const playwrightFixtures = {
440
440
  location: stackTrace === null || stackTrace === void 0 ? void 0 : stackTrace.frames[0],
441
441
  category: 'pw:api',
442
442
  title: apiCall,
443
- wallTime
443
+ wallTime,
444
+ laxParent: true
444
445
  });
445
446
  userData.userObject = step;
446
447
  },
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.BaseReporter = void 0;
7
- exports.addSnippetToError = addSnippetToError;
8
7
  exports.formatError = formatError;
9
8
  exports.formatFailure = formatFailure;
10
9
  exports.formatResultFailure = formatResultFailure;
@@ -17,9 +16,7 @@ exports.stepSuffix = stepSuffix;
17
16
  exports.stripAnsiEscapes = stripAnsiEscapes;
18
17
  exports.uniqueProjectIds = uniqueProjectIds;
19
18
  var _utilsBundle = require("playwright-core/lib/utilsBundle");
20
- var _fs = _interopRequireDefault(require("fs"));
21
19
  var _path = _interopRequireDefault(require("path"));
22
- var _babelBundle = require("../common/babelBundle");
23
20
  var _utils = require("playwright-core/lib/utils");
24
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
22
  /**
@@ -400,29 +397,6 @@ function formatError(config, error, highlightCode) {
400
397
  message: tokens.join('\n')
401
398
  };
402
399
  }
403
- function addSnippetToError(config, error, file) {
404
- let location = error.location;
405
- if (error.stack && !location) location = prepareErrorStack(error.stack).location;
406
- if (!location) return;
407
- try {
408
- const tokens = [];
409
- const source = _fs.default.readFileSync(location.file, 'utf8');
410
- const codeFrame = (0, _babelBundle.codeFrameColumns)(source, {
411
- start: location
412
- }, {
413
- highlightCode: true
414
- });
415
- // Convert /var/folders to /private/var/folders on Mac.
416
- if (!file || _fs.default.realpathSync(file) !== location.file) {
417
- tokens.push(_utilsBundle.colors.gray(` at `) + `${relativeFilePath(config, location.file)}:${location.line}`);
418
- tokens.push('');
419
- }
420
- tokens.push(codeFrame);
421
- error.snippet = tokens.join('\n');
422
- } catch (e) {
423
- // Failed to read the source file - that's ok.
424
- }
425
- }
426
400
  function separator(text = '') {
427
401
  var _process$stdout;
428
402
  if (text) text += ' ';
@@ -4,9 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.InternalReporter = void 0;
7
+ var _fs = _interopRequireDefault(require("fs"));
8
+ var _utilsBundle = require("playwright-core/lib/utilsBundle");
9
+ var _babelBundle = require("../common/babelBundle");
7
10
  var _test = require("../common/test");
8
- var _base = require("./base");
9
11
  var _multiplexer = require("./multiplexer");
12
+ var _base = require("./base");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
14
  /**
11
15
  * Copyright (c) Microsoft Corporation.
12
16
  *
@@ -92,7 +96,7 @@ class InternalReporter {
92
96
  });
93
97
  return;
94
98
  }
95
- (0, _base.addSnippetToError)(this._config.config, error);
99
+ addLocationAndSnippetToError(this._config.config, error);
96
100
  this._multiplexer.onError(error);
97
101
  }
98
102
  onStepBegin(test, result, step) {
@@ -103,10 +107,33 @@ class InternalReporter {
103
107
  this._multiplexer.onStepEnd(test, result, step);
104
108
  }
105
109
  _addSnippetToTestErrors(test, result) {
106
- for (const error of result.errors) (0, _base.addSnippetToError)(this._config.config, error, test.location.file);
110
+ for (const error of result.errors) addLocationAndSnippetToError(this._config.config, error, test.location.file);
107
111
  }
108
112
  _addSnippetToStepError(test, step) {
109
- if (step.error) (0, _base.addSnippetToError)(this._config.config, step.error, test.location.file);
113
+ if (step.error) addLocationAndSnippetToError(this._config.config, step.error, test.location.file);
110
114
  }
111
115
  }
112
- exports.InternalReporter = InternalReporter;
116
+ exports.InternalReporter = InternalReporter;
117
+ function addLocationAndSnippetToError(config, error, file) {
118
+ if (error.stack && !error.location) error.location = (0, _base.prepareErrorStack)(error.stack).location;
119
+ const location = error.location;
120
+ if (!location) return;
121
+ try {
122
+ const tokens = [];
123
+ const source = _fs.default.readFileSync(location.file, 'utf8');
124
+ const codeFrame = (0, _babelBundle.codeFrameColumns)(source, {
125
+ start: location
126
+ }, {
127
+ highlightCode: true
128
+ });
129
+ // Convert /var/folders to /private/var/folders on Mac.
130
+ if (!file || _fs.default.realpathSync(file) !== location.file) {
131
+ tokens.push(_utilsBundle.colors.gray(` at `) + `${(0, _base.relativeFilePath)(config, location.file)}:${location.line}`);
132
+ tokens.push('');
133
+ }
134
+ tokens.push(codeFrame);
135
+ error.snippet = tokens.join('\n');
136
+ } catch (e) {
137
+ // Failed to read the source file - that's ok.
138
+ }
139
+ }
@@ -84,8 +84,6 @@ function mergeEvents(shardReports) {
84
84
  for (const reportJsonl of shardReports) {
85
85
  const parsedEvents = parseEvents(reportJsonl);
86
86
  for (const event of parsedEvents) {
87
- // TODO: show remaining events?
88
- if (event.method === 'onError') throw new Error('Error in shard');
89
87
  if (event.method === 'onBegin') beginEvents.push(event);else if (event.method === 'onEnd') endEvents.push(event);else events.push(event);
90
88
  }
91
89
  }
@@ -56,6 +56,7 @@ class TestInfoImpl {
56
56
  this._lastStepId = 0;
57
57
  this._projectInternal = void 0;
58
58
  this._configInternal = void 0;
59
+ this._steps = [];
59
60
  this.testId = void 0;
60
61
  this.repeatEachIndex = void 0;
61
62
  this.retry = void 0;
@@ -163,15 +164,28 @@ class TestInfoImpl {
163
164
  }
164
165
  _addStep(data) {
165
166
  const stepId = `${data.category}@${data.title}@${++this._lastStepId}`;
166
- const parentStep = _utils.zones.zoneData('stepZone', (0, _utils.captureRawStack)());
167
- let callbackHandled = false;
168
- const firstErrorIndex = this.errors.length;
167
+ let parentStep = _utils.zones.zoneData('stepZone', (0, _utils.captureRawStack)());
168
+
169
+ // For out-of-stack calls, locate the enclosing step.
170
+ let isLaxParent = false;
171
+ if (!parentStep && data.laxParent) {
172
+ const visit = step => {
173
+ // Never nest into under another lax element, it could be a series
174
+ // of no-reply actions, ala page.continue().
175
+ if (!step.endWallTime && step.category === data.category && !step.laxParent) parentStep = step;
176
+ step.steps.forEach(visit);
177
+ };
178
+ this._steps.forEach(visit);
179
+ isLaxParent = !!parentStep;
180
+ }
169
181
  const step = {
170
182
  stepId,
171
183
  ...data,
184
+ laxParent: isLaxParent,
185
+ steps: [],
172
186
  complete: result => {
173
- if (callbackHandled) return;
174
- callbackHandled = true;
187
+ if (step.endWallTime) return;
188
+ step.endWallTime = Date.now();
175
189
  let error;
176
190
  if (result.error instanceof Error) {
177
191
  // Step function threw an error.
@@ -180,19 +194,22 @@ class TestInfoImpl {
180
194
  // Internal API step reported an error.
181
195
  error = result.error;
182
196
  } else {
183
- // There was some other error (porbably soft expect) during step execution.
184
- // Report step as failed to make it easier to spot.
185
- error = this.errors[firstErrorIndex];
197
+ // One of the child steps failed (probably soft expect).
198
+ // Report this step as failed to make it easier to spot.
199
+ error = step.steps.map(s => s.error).find(e => !!e);
186
200
  }
201
+ step.error = error;
187
202
  const payload = {
188
203
  testId: this._test.id,
189
204
  stepId,
190
- wallTime: Date.now(),
205
+ wallTime: step.endWallTime,
191
206
  error
192
207
  };
193
208
  this._onStepEnd(payload);
194
209
  }
195
210
  };
211
+ const parentStepList = parentStep ? parentStep.steps : this._steps;
212
+ parentStepList.push(step);
196
213
  const hasLocation = data.location && !data.location.file.includes('@playwright');
197
214
  // Sanitize location that comes from user land, it might have extra properties.
198
215
  const location = data.location && hasLocation ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playwright/test",
3
- "version": "1.34.0-alpha-may-3-2023",
3
+ "version": "1.34.0-alpha-may-5-2023",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": "github:Microsoft/playwright",
6
6
  "homepage": "https://playwright.dev",
@@ -23,6 +23,7 @@
23
23
  "./lib/internalsForTest": "./lib/internalsForTest.js",
24
24
  "./lib/experimentalLoader": "./lib/experimentalLoader.js",
25
25
  "./lib/plugins": "./lib/plugins/index.js",
26
+ "./jsx-runtime": "./jsx-runtime.js",
26
27
  "./lib/util": "./lib/util.js",
27
28
  "./lib/utilsBundle": "./lib/utilsBundle.js",
28
29
  "./reporter": "./reporter.js"
@@ -36,7 +37,7 @@
36
37
  "license": "Apache-2.0",
37
38
  "dependencies": {
38
39
  "@types/node": "*",
39
- "playwright-core": "1.34.0-alpha-may-3-2023"
40
+ "playwright-core": "1.34.0-alpha-may-5-2023"
40
41
  },
41
42
  "optionalDependencies": {
42
43
  "fsevents": "2.3.2"