@smoothdeploy/playwright 1.62.1 → 1.63.0

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.
@@ -128,6 +128,7 @@ function overridesFromOptions(options) {
128
128
  repeatEach: options.repeatEach ? parseInt(options.repeatEach, 10) : void 0,
129
129
  retries: options.retries ? parseInt(options.retries, 10) : void 0,
130
130
  reporter: resolveReporterOption(options.reporter),
131
+ additionalReporters: resolveReporterOption(options.addReporter),
131
132
  shard: resolveShardOption(options.shard),
132
133
  timeout: options.timeout ? parseInt(options.timeout, 10) : void 0,
133
134
  tsconfig: options.tsconfig ? import_path.default.resolve(process.cwd(), options.tsconfig) : void 0,
@@ -63,11 +63,9 @@ __export(compilationCache_exports, {
63
63
  dependenciesForTestFile: () => dependenciesForTestFile,
64
64
  fileDependenciesForTest: () => fileDependenciesForTest,
65
65
  getFromCompilationCache: () => getFromCompilationCache,
66
- getUserData: () => getUserData,
67
66
  installSourceMapSupport: () => installSourceMapSupport,
68
67
  internalDependenciesForTestFile: () => internalDependenciesForTestFile,
69
68
  serializeCompilationCache: () => serializeCompilationCache,
70
- setExternalDependencies: () => setExternalDependencies,
71
69
  startCollectingFileDeps: () => startCollectingFileDeps,
72
70
  stopCollectingFileDeps: () => stopCollectingFileDeps
73
71
  });
@@ -86,7 +84,6 @@ var cacheDir = process.env.PWTEST_CACHE_DIR || (() => {
86
84
  var sourceMaps = /* @__PURE__ */ new Map();
87
85
  var memoryCache = /* @__PURE__ */ new Map();
88
86
  var fileDependencies = /* @__PURE__ */ new Map();
89
- var externalDependencies = /* @__PURE__ */ new Map();
90
87
  function installSourceMapSupport() {
91
88
  Error.stackTraceLimit = 200;
92
89
  sourceMapSupport.install({
@@ -149,25 +146,22 @@ function getFromCompilationCache(filename, contentHash, moduleUrl) {
149
146
  const cachePath = calculateCachePath(filename, cacheFolderName, hashPrefix);
150
147
  const codePath = cachePath + ".js";
151
148
  const sourceMapPath = cachePath + ".map";
152
- const dataPath = cachePath + ".data";
153
149
  try {
154
150
  const cachedCode = readCodeCache(codePath);
155
- const serializedCache = _innerAddToCompilationCacheAndSerialize(filename, { codePath, sourceMapPath, dataPath, moduleUrl });
151
+ const serializedCache = _innerAddToCompilationCacheAndSerialize(filename, { codePath, sourceMapPath, moduleUrl });
156
152
  return { cachedCode, serializedCache };
157
153
  } catch {
158
154
  }
159
155
  return {
160
- addToCache: (code, map, data) => {
156
+ addToCache: (code, map) => {
161
157
  if ((0, import_globals.isWorkerProcess)())
162
158
  return {};
163
159
  clearOldCacheEntries(cacheFolderName, filePathHash);
164
160
  import_fs.default.mkdirSync(import_path.default.dirname(cachePath), { recursive: true });
165
161
  if (map)
166
162
  import_fs.default.writeFileSync(sourceMapPath, JSON.stringify(map), "utf8");
167
- if (data.size)
168
- import_fs.default.writeFileSync(dataPath, JSON.stringify(Object.fromEntries(data.entries()), void 0, 2), "utf8");
169
163
  writeCodeCache(codePath, code);
170
- const serializedCache = _innerAddToCompilationCacheAndSerialize(filename, { codePath, sourceMapPath, dataPath, moduleUrl });
164
+ const serializedCache = _innerAddToCompilationCacheAndSerialize(filename, { codePath, sourceMapPath, moduleUrl });
171
165
  return { serializedCache };
172
166
  }
173
167
  };
@@ -176,8 +170,7 @@ function serializeCompilationCache() {
176
170
  return {
177
171
  sourceMaps: [...sourceMaps.entries()],
178
172
  memoryCache: [...memoryCache.entries()],
179
- fileDependencies: [...fileDependencies.entries()].map(([filename, deps]) => [filename, [...deps]]),
180
- externalDependencies: [...externalDependencies.entries()].map(([filename, deps]) => [filename, [...deps]])
173
+ fileDependencies: [...fileDependencies.entries()].map(([filename, deps]) => [filename, [...deps]])
181
174
  };
182
175
  }
183
176
  function addToCompilationCache(payload) {
@@ -189,10 +182,6 @@ function addToCompilationCache(payload) {
189
182
  const existing = fileDependencies.get(entry[0]) || [];
190
183
  fileDependencies.set(entry[0], /* @__PURE__ */ new Set([...entry[1], ...existing]));
191
184
  }
192
- for (const entry of payload.externalDependencies) {
193
- const existing = externalDependencies.get(entry[0]) || [];
194
- externalDependencies.set(entry[0], /* @__PURE__ */ new Set([...entry[1], ...existing]));
195
- }
196
185
  }
197
186
  function calculateFilePathHash(filePath) {
198
187
  return calculateSha1(filePath).substring(0, 10);
@@ -228,10 +217,6 @@ function stopCollectingFileDeps(filename) {
228
217
  function currentFileDepsCollector() {
229
218
  return depsCollector2;
230
219
  }
231
- function setExternalDependencies(filename, deps) {
232
- const depsSet = new Set(deps.filter((dep) => !belongsToNodeModules(dep) && dep !== filename));
233
- externalDependencies.set(filename, depsSet);
234
- }
235
220
  function fileDependenciesForTest() {
236
221
  return Object.fromEntries([...fileDependencies.entries()].map((entry) => [import_path.default.basename(entry[0]), [...entry[1]].map((f) => import_path.default.basename(f)).sort()]));
237
222
  }
@@ -243,16 +228,6 @@ function collectAffectedTestFiles(changedFile, testFileCollector) {
243
228
  if (deps.has(changedFile))
244
229
  testFileCollector.add(testFile);
245
230
  }
246
- for (const [importingFile, depsOfImportingFile] of externalDependencies) {
247
- if (depsOfImportingFile.has(changedFile)) {
248
- if (isTestFile(importingFile))
249
- testFileCollector.add(importingFile);
250
- for (const [testFile, depsOfTestFile] of fileDependencies) {
251
- if (depsOfTestFile.has(importingFile))
252
- testFileCollector.add(testFile);
253
- }
254
- }
255
- }
256
231
  }
257
232
  function affectedTestFiles(changes) {
258
233
  const result2 = /* @__PURE__ */ new Set();
@@ -264,15 +239,7 @@ function internalDependenciesForTestFile(filename) {
264
239
  return fileDependencies.get(filename);
265
240
  }
266
241
  function dependenciesForTestFile(filename) {
267
- const result2 = /* @__PURE__ */ new Set();
268
- for (const testDependency of fileDependencies.get(filename) || []) {
269
- result2.add(testDependency);
270
- for (const externalDependency of externalDependencies.get(testDependency) || [])
271
- result2.add(externalDependency);
272
- }
273
- for (const dep of externalDependencies.get(filename) || [])
274
- result2.add(dep);
275
- return result2;
242
+ return fileDependencies.get(filename) || /* @__PURE__ */ new Set();
276
243
  }
277
244
  var kPlaywrightInternalPrefix = import_package.packageRoot;
278
245
  function belongsToNodeModules(file2) {
@@ -282,19 +249,6 @@ function belongsToNodeModules(file2) {
282
249
  return true;
283
250
  return false;
284
251
  }
285
- async function getUserData(pluginName) {
286
- const result2 = /* @__PURE__ */ new Map();
287
- for (const [fileName2, cache] of memoryCache) {
288
- if (!cache.dataPath)
289
- continue;
290
- if (!import_fs.default.existsSync(cache.dataPath))
291
- continue;
292
- const data = JSON.parse(await import_fs.default.promises.readFile(cache.dataPath, "utf8"));
293
- if (data[pluginName])
294
- result2.set(fileName2, data[pluginName]);
295
- }
296
- return result2;
297
- }
298
252
 
299
253
  // packages/playwright/src/common/config.ts
300
254
  var config_exports = {};
@@ -565,7 +519,7 @@ var FullConfigInternal = class {
565
519
  preserveOutput: takeFirst(userConfig.preserveOutput, "always"),
566
520
  projects: [],
567
521
  quiet: takeFirst(configCLIOverrides.quiet, userConfig.quiet, false),
568
- reporter: takeFirst(configCLIOverrides.reporter, resolveReporters(userConfig.reporter, configDir), [[defaultReporter]]),
522
+ reporter: [...takeFirst(configCLIOverrides.reporter, resolveReporters(userConfig.reporter, configDir), [[defaultReporter]]), ...configCLIOverrides.additionalReporters ?? []],
569
523
  reportSlowTests: takeFirst(userConfig.reportSlowTests, {
570
524
  max: 5,
571
525
  threshold: 3e5
@@ -623,6 +577,10 @@ var FullProjectInternal = class {
623
577
  this.fullConfig = fullConfig;
624
578
  const testDir = takeFirst(pathResolve(configDir, projectConfig.testDir), pathResolve(configDir, config.testDir), fullConfig.configDir);
625
579
  this.snapshotPathTemplate = takeFirst(projectConfig.snapshotPathTemplate, config.snapshotPathTemplate);
580
+ const use = mergeObjects(config.use, projectConfig.use, configCLIOverrides.use);
581
+ const configTrace = takeFirst(projectConfig.use?.trace, config.use?.trace);
582
+ if (typeof configCLIOverrides.use?.trace === "string" && typeof configTrace === "object" && configTrace)
583
+ use.trace = { ...configTrace, mode: configCLIOverrides.use.trace };
626
584
  this.project = {
627
585
  grep: takeFirst(projectConfig.grep, config.grep, defaultGrep),
628
586
  grepInvert: takeFirst(projectConfig.grepInvert, config.grepInvert, null),
@@ -638,7 +596,7 @@ var FullProjectInternal = class {
638
596
  testIgnore: takeFirst(projectConfig.testIgnore, config.testIgnore, []),
639
597
  testMatch: takeFirst(projectConfig.testMatch, config.testMatch, "**/*.@(spec|test).?(c|m)[jt]s?(x)"),
640
598
  timeout: takeFirst(configCLIOverrides.debug === "inspector" ? 0 : void 0, configCLIOverrides.timeout, projectConfig.timeout, config.timeout, defaultTimeout),
641
- use: mergeObjects(config.use, projectConfig.use, configCLIOverrides.use),
599
+ use,
642
600
  dependencies: projectConfig.dependencies || [],
643
601
  teardown: projectConfig.teardown,
644
602
  ignoreSnapshots: takeFirst(configCLIOverrides.ignoreSnapshots, projectConfig.ignoreSnapshots, config.ignoreSnapshots, false)
@@ -729,7 +687,7 @@ function toReporters(reporters) {
729
687
  return [[reporters]];
730
688
  return reporters;
731
689
  }
732
- var builtInReporters = ["list", "line", "dot", "json", "junit", "null", "github", "html", "blob", "smoothdeploy"];
690
+ var builtInReporters = ["list", "line", "dot", "json", "junit", "null", "github", "html", "blob", "perfetto", "smoothdeploy"];
733
691
  function resolveScript(id, rootDir) {
734
692
  if (!id)
735
693
  return void 0;
@@ -766,7 +724,6 @@ __export(transform_exports, {
766
724
  resolveHook: () => resolveHook,
767
725
  setSingleTSConfig: () => setSingleTSConfig,
768
726
  setTransformConfig: () => setTransformConfig,
769
- setTransformData: () => setTransformData,
770
727
  shouldTransform: () => shouldTransform,
771
728
  startCollectingFileDeps: () => startCollectingFileDeps2,
772
729
  stopCollectingFileDeps: () => stopCollectingFileDeps2,
@@ -968,7 +925,6 @@ var sourceMapSupport2 = require("playwright-core/lib/utilsBundle").sourceMapSupp
968
925
  var version = import_package3.packageJSON.version;
969
926
  var cachedTSConfigs = /* @__PURE__ */ new Map();
970
927
  var _transformConfig = {
971
- babelPlugins: [],
972
928
  external: []
973
929
  };
974
930
  var _externalMatcher = () => false;
@@ -1093,35 +1049,24 @@ function shouldTransform(filename) {
1093
1049
  return false;
1094
1050
  return !belongsToNodeModules(filename);
1095
1051
  }
1096
- var transformData;
1097
- function setTransformData(pluginName, value) {
1098
- transformData.set(pluginName, value);
1099
- }
1100
1052
  function transformHook(originalCode, filename, moduleUrl) {
1101
1053
  const hasPreprocessor = process.env.PW_TEST_SOURCE_TRANSFORM && process.env.PW_TEST_SOURCE_TRANSFORM_SCOPE && process.env.PW_TEST_SOURCE_TRANSFORM_SCOPE.split(pathSeparator).some((f) => filename.startsWith(f));
1102
- const pluginsPrologue = _transformConfig.babelPlugins;
1103
1054
  const pluginsEpilogue = hasPreprocessor ? [[process.env.PW_TEST_SOURCE_TRANSFORM]] : [];
1104
- const hash = calculateHash(originalCode, filename, !!moduleUrl, pluginsPrologue, pluginsEpilogue);
1055
+ const hash = calculateHash(originalCode, filename, !!moduleUrl, pluginsEpilogue);
1105
1056
  const { cachedCode, addToCache, serializedCache } = getFromCompilationCache(filename, hash, moduleUrl);
1106
1057
  if (cachedCode !== void 0)
1107
1058
  return { code: cachedCode, serializedCache };
1108
1059
  process.env.BROWSERSLIST_IGNORE_OLD_DATA = "true";
1109
1060
  const { babelTransform } = require((0, import_package3.libPath)("transform", "babelBundle"));
1110
- transformData = /* @__PURE__ */ new Map();
1111
- const setTransformDataForPlugin = (key, value) => transformData.set(key, value);
1112
- const wrappedPrologue = pluginsPrologue.map(([name, opts]) => [
1113
- name,
1114
- { ...opts || {}, setTransformData: setTransformDataForPlugin }
1115
- ]);
1116
- const babelResult = babelTransform(originalCode, filename, !!moduleUrl, wrappedPrologue, pluginsEpilogue, _transformConfig.jsxImportSource);
1061
+ const babelResult = babelTransform(originalCode, filename, !!moduleUrl, pluginsEpilogue, _transformConfig.jsxImportSource);
1117
1062
  if (!babelResult?.code)
1118
1063
  return { code: originalCode, serializedCache };
1119
1064
  const { code, map } = babelResult;
1120
- const added = addToCache(code, map, transformData);
1065
+ const added = addToCache(code, map);
1121
1066
  return { code, serializedCache: added.serializedCache };
1122
1067
  }
1123
- function calculateHash(content, filePath, isModule2, pluginsPrologue, pluginsEpilogue) {
1124
- const hash = import_crypto.default.createHash("sha1").update(isModule2 ? "esm" : "no_esm").update(content).update(filePath).update(version).update(pluginsPrologue.map((p) => p[0]).join(",")).update(pluginsEpilogue.map((p) => p[0]).join(",")).digest("hex");
1068
+ function calculateHash(content, filePath, isModule2, pluginsEpilogue) {
1069
+ const hash = import_crypto.default.createHash("sha1").update(isModule2 ? "esm" : "no_esm").update(content).update(filePath).update(version).update(pluginsEpilogue.map((p) => p[0]).join(",")).digest("hex");
1125
1070
  return hash;
1126
1071
  }
1127
1072
  async function requireOrImport(file) {
@@ -1337,10 +1282,9 @@ async function loadConfig(location, overrides, ignoreProjectDependencies = false
1337
1282
  project.teardown = void 0;
1338
1283
  }
1339
1284
  }
1340
- const babelPlugins = userConfig["@playwright/test"]?.babelPlugins || [];
1341
1285
  const external = userConfig.build?.external || [];
1342
1286
  const jsxImportSource = import_path7.default.dirname(require.resolve("playwright"));
1343
- await setTransformConfig({ babelPlugins, external, jsxImportSource });
1287
+ await setTransformConfig({ external, jsxImportSource });
1344
1288
  if (!overrides?.tsconfig)
1345
1289
  await setSingleTSConfig(fullConfig?.singleTSConfigPath);
1346
1290
  return fullConfig;
@@ -2007,6 +1951,7 @@ function startProcessRunner(create) {
2007
1951
  });
2008
1952
  }
2009
1953
  var kForceExitTimeout = +(process.env.PWTEST_FORCE_EXIT_TIMEOUT || 3e4);
1954
+ var kHeartbeatInterval = 1e3;
2010
1955
  async function gracefullyCloseAndExit(forceExit) {
2011
1956
  if (forceExit && !forceExitInitiated) {
2012
1957
  forceExitInitiated = true;
@@ -2014,8 +1959,11 @@ async function gracefullyCloseAndExit(forceExit) {
2014
1959
  }
2015
1960
  if (!gracefullyCloseCalled) {
2016
1961
  gracefullyCloseCalled = true;
1962
+ const heartbeat = setInterval(() => sendMessageToParent({ method: "__heartbeat__" }), kHeartbeatInterval);
1963
+ heartbeat.unref();
2017
1964
  await processRunner?.gracefullyClose().catch(() => {
2018
1965
  });
1966
+ clearInterval(heartbeat);
2019
1967
  if (processName)
2020
1968
  await stopProfiling(processName).catch(() => {
2021
1969
  });
@@ -2089,6 +2037,10 @@ function bindFileSuiteToProject(project, suite) {
2089
2037
  for (let parentSuite = suite2; parentSuite; parentSuite = parentSuite.parent) {
2090
2038
  if (parentSuite._staticAnnotations.length)
2091
2039
  test.annotations.unshift(...parentSuite._staticAnnotations);
2040
+ if (parentSuite._parallelMode === "serial")
2041
+ test.annotations.unshift({ type: "serial", location: parentSuite.location });
2042
+ if (parentSuite._locks.length)
2043
+ test._locks.push(...parentSuite._locks);
2092
2044
  if (inheritedRetries === void 0 && parentSuite._retries !== void 0)
2093
2045
  inheritedRetries = parentSuite._retries;
2094
2046
  if (inheritedTimeout === void 0 && parentSuite._timeout !== void 0)
@@ -2193,6 +2145,12 @@ var testDetailsSchema = {
2193
2145
  testAnnotationSchema,
2194
2146
  { type: "array", items: testAnnotationSchema }
2195
2147
  ]
2148
+ },
2149
+ lock: {
2150
+ oneOf: [
2151
+ { type: "string" },
2152
+ { type: "array", items: { type: "string" } }
2153
+ ]
2196
2154
  }
2197
2155
  }
2198
2156
  };
@@ -2205,9 +2163,12 @@ function validateTestDetails(details, location) {
2205
2163
  const tags = tag === void 0 ? [] : typeof tag === "string" ? [tag] : tag;
2206
2164
  const annotation = obj.annotation;
2207
2165
  const annotations = annotation === void 0 ? [] : Array.isArray(annotation) ? annotation : [annotation];
2166
+ const lock = obj.lock;
2167
+ const locks = lock === void 0 ? [] : typeof lock === "string" ? [lock] : lock;
2208
2168
  return {
2209
2169
  annotations: annotations.map((a) => ({ ...a, location })),
2210
2170
  tags,
2171
+ locks,
2211
2172
  location
2212
2173
  };
2213
2174
  }
@@ -2291,6 +2252,7 @@ var TestTypeImpl = class _TestTypeImpl {
2291
2252
  test._requireFile = suite._requireFile;
2292
2253
  test.annotations.push(...validatedDetails.annotations);
2293
2254
  test._tags.push(...validatedDetails.tags);
2255
+ test._locks.push(...validatedDetails.locks);
2294
2256
  suite._addTest(test);
2295
2257
  if (type === "only" || type === "fail.only")
2296
2258
  test._only = true;
@@ -2326,6 +2288,7 @@ var TestTypeImpl = class _TestTypeImpl {
2326
2288
  child.location = location;
2327
2289
  child._staticAnnotations.push(...validatedDetails.annotations);
2328
2290
  child._tags.push(...validatedDetails.tags);
2291
+ child._locks.push(...validatedDetails.locks);
2329
2292
  suite._addSuite(child);
2330
2293
  if (type === "only" || type === "serial.only" || type === "parallel.only")
2331
2294
  child._only = true;
@@ -2432,7 +2395,7 @@ var TestTypeImpl = class _TestTypeImpl {
2432
2395
  if (!testInfo)
2433
2396
  throw new Error(`test.step() can only be called from a test`);
2434
2397
  await testInfo._onUserStepBegin?.(title);
2435
- const step = testInfo._addStep({ category: "test.step", title, location: options.location, box: options.box });
2398
+ const step = testInfo._addStep({ category: "test.step", title, subtitle: options.subtitle, location: options.location, box: options.box, params: options.params });
2436
2399
  return await currentZone().with("stepZone", step).run(async () => {
2437
2400
  try {
2438
2401
  let result2 = void 0;
@@ -2573,6 +2536,7 @@ var Suite = class _Suite extends Base {
2573
2536
  this._staticAnnotations = [];
2574
2537
  // Explicitly declared tags that are not a part of the title.
2575
2538
  this._tags = [];
2539
+ this._locks = [];
2576
2540
  this._modifiers = [];
2577
2541
  this._parallelMode = "none";
2578
2542
  this._type = type;
@@ -2715,6 +2679,7 @@ var Suite = class _Suite extends Base {
2715
2679
  retries: this._retries,
2716
2680
  staticAnnotations: this._staticAnnotations.slice(),
2717
2681
  tags: this._tags.slice(),
2682
+ locks: this._locks.slice(),
2718
2683
  modifiers: this._modifiers.slice(),
2719
2684
  parallelMode: this._parallelMode,
2720
2685
  hooks: this._hooks.map((h) => ({ type: h.type, location: h.location, title: h.title })),
@@ -2730,6 +2695,7 @@ var Suite = class _Suite extends Base {
2730
2695
  suite._retries = data.retries;
2731
2696
  suite._staticAnnotations = data.staticAnnotations;
2732
2697
  suite._tags = data.tags;
2698
+ suite._locks = data.locks;
2733
2699
  suite._modifiers = data.modifiers;
2734
2700
  suite._parallelMode = data.parallelMode;
2735
2701
  suite._hooks = data.hooks.map((h) => ({ type: h.type, location: h.location, title: h.title, fn: () => {
@@ -2765,6 +2731,7 @@ var TestCase = class _TestCase extends Base {
2765
2731
  this._projectId = "";
2766
2732
  // Explicitly declared tags that are not a part of the title.
2767
2733
  this._tags = [];
2734
+ this._locks = [];
2768
2735
  this._planAnnotations = [];
2769
2736
  this.fn = fn;
2770
2737
  this._testType = testType;
@@ -2815,6 +2782,7 @@ var TestCase = class _TestCase extends Base {
2815
2782
  workerHash: this._workerHash,
2816
2783
  annotations: this.annotations.slice(),
2817
2784
  tags: this._tags.slice(),
2785
+ locks: this._locks.slice(),
2818
2786
  projectId: this._projectId
2819
2787
  };
2820
2788
  }
@@ -2831,6 +2799,7 @@ var TestCase = class _TestCase extends Base {
2831
2799
  test._workerHash = data.workerHash;
2832
2800
  test.annotations = data.annotations;
2833
2801
  test._tags = data.tags;
2802
+ test._locks = data.locks;
2834
2803
  test._projectId = data.projectId;
2835
2804
  return test;
2836
2805
  }
@@ -1,25 +1,25 @@
1
1
  # packages/playwright/lib/common/index.js
2
- # total: 114.2 KB
2
+ # total: 112.8 KB
3
3
 
4
4
  ## Inlined (20)
5
- 12.0 KB packages/playwright/src/common/config.ts
6
- 13.7 KB packages/playwright/src/common/configLoader.ts
5
+ 12.3 KB packages/playwright/src/common/config.ts
6
+ 13.6 KB packages/playwright/src/common/configLoader.ts
7
7
  11.5 KB packages/playwright/src/common/fixtures.ts
8
8
  0.8 KB packages/playwright/src/common/index.ts
9
9
  1.3 KB packages/playwright/src/common/ipc.ts
10
10
  2.1 KB packages/playwright/src/common/poolBuilder.ts
11
- 3.9 KB packages/playwright/src/common/process.ts
12
- 4.7 KB packages/playwright/src/common/suiteUtils.ts
13
- 8.5 KB packages/playwright/src/common/test.ts
11
+ 4.1 KB packages/playwright/src/common/process.ts
12
+ 4.9 KB packages/playwright/src/common/suiteUtils.ts
13
+ 8.7 KB packages/playwright/src/common/test.ts
14
14
  2.0 KB packages/playwright/src/common/testLoader.ts
15
- 12.6 KB packages/playwright/src/common/testType.ts
16
- 1.2 KB packages/playwright/src/common/validators.ts
15
+ 12.7 KB packages/playwright/src/common/testType.ts
16
+ 1.4 KB packages/playwright/src/common/validators.ts
17
17
  1.3 KB packages/playwright/src/isomorphic/teleReceiver.ts
18
- 9.7 KB packages/playwright/src/transform/compilationCache.ts
18
+ 7.8 KB packages/playwright/src/transform/compilationCache.ts
19
19
  1.7 KB packages/playwright/src/transform/esmLoaderSync.ts
20
20
  1.1 KB packages/playwright/src/transform/pirates.ts
21
21
  1.1 KB packages/playwright/src/transform/portTransport.ts
22
- 12.3 KB packages/playwright/src/transform/transform.ts
22
+ 11.6 KB packages/playwright/src/transform/transform.ts
23
23
  2.9 KB packages/playwright/src/transform/tsconfig-loader.ts
24
24
  7.0 KB packages/playwright/src/util.ts
25
25
 
package/lib/index.js CHANGED
@@ -49,8 +49,7 @@ var import_browserBackend = require("./mcp/test/browserBackend");
49
49
  var import_expect = require("./matchers/expect");
50
50
  var import_common2 = require("./common");
51
51
  var import_expect2 = require("./matchers/expect");
52
- const { asLocatorDescription } = require("playwright-core/lib/coreBundle").iso;
53
- const { getActionGroup, renderTitleForCall } = require("playwright-core/lib/coreBundle").iso;
52
+ const { getActionGroup, renderParamsForCall, renderSubtitleForCall, renderTitleForCall, truncateParam } = require("playwright-core/lib/coreBundle").iso;
54
53
  const { escapeHTML } = require("playwright-core/lib/coreBundle").iso;
55
54
  const { jsonStringifyForceASCII } = require("playwright-core/lib/coreBundle").utils;
56
55
  const { createGuid } = require("playwright-core/lib/coreBundle").utils;
@@ -90,43 +89,41 @@ const utilityFixtures = {
90
89
  const csiListener = {
91
90
  onApiCallBegin: (data, channel) => {
92
91
  const testInfo2 = globals.currentTestInfo();
93
- if (!testInfo2 || data.apiName.includes("setTestIdAttribute") || data.apiName === "tracing.groupEnd")
92
+ if (!testInfo2)
94
93
  return;
94
+ if (channel.type === "Tracing" && channel.method === "tracingGroupEnd") {
95
+ data.userData = (error) => tracingGroupSteps.pop()?.complete({ error });
96
+ return;
97
+ }
95
98
  const zone = currentZone().data("stepZone");
96
- const isExpectCall = data.apiName === "locator._expect" || data.apiName === "frame._expect" || data.apiName === "page._expectScreenshot";
99
+ const isExpectCall = channel.type === "Frame" && channel.method === "expect" || channel.type === "Page" && channel.method === "expectScreenshot";
97
100
  if (zone && zone.category === "expect" && isExpectCall) {
98
- if (zone.apiName)
99
- data.apiName = zone.apiName;
100
- if (zone.shortTitle || zone.title)
101
- data.title = zone.shortTitle ?? zone.title;
102
101
  data.stepId = zone.stepId;
103
102
  if (resultScreenshots && channel.params?.selector)
104
103
  data._channel = channel;
105
104
  return;
106
105
  }
106
+ const params = renderParamsForCall({ type: channel.type, method: channel.method, params: channel.params });
107
107
  const step = testInfo2._addStep({
108
108
  location: data.frames[0],
109
109
  category: "pw:api",
110
110
  title: renderTitle(channel.type, channel.method, channel.params, data.title),
111
+ subtitle: renderSubtitle(channel.type, channel.method, channel.params),
111
112
  apiName: data.apiName,
112
- params: channel.params,
113
+ channelMethod: `${channel.type}.${channel.method}`,
114
+ params,
113
115
  group: getActionGroup({ type: channel.type, method: channel.method })
114
116
  }, tracingGroupSteps[tracingGroupSteps.length - 1]);
115
- data.userData = step;
116
117
  data.stepId = step.stepId;
117
- if (data.apiName === "tracing.group")
118
+ if (channel.type === "Tracing" && channel.method === "tracingGroup") {
118
119
  tracingGroupSteps.push(step);
120
+ } else {
121
+ data.userData = (error) => step.complete({ error });
122
+ }
119
123
  if (resultScreenshots && channel.params?.selector)
120
124
  data._channel = channel;
121
125
  },
122
126
  onApiCallEnd: async (data) => {
123
- if (data.apiName === "tracing.group")
124
- return;
125
- if (data.apiName === "tracing.groupEnd") {
126
- const step2 = tracingGroupSteps.pop();
127
- step2?.complete({ error: data.error });
128
- return;
129
- }
130
127
  const channel = data._channel;
131
128
  if (channel && !data.error) {
132
129
  const testInfo2 = globals.currentTestInfo();
@@ -137,8 +134,8 @@ const utilityFixtures = {
137
134
  }
138
135
  }
139
136
  }
140
- const step = data.userData;
141
- step?.complete({ error: data.error });
137
+ const completeStep = data.userData;
138
+ completeStep?.(data.error);
142
139
  },
143
140
  onWillPause: ({ keepTestTimeout }) => {
144
141
  if (!keepTestTimeout)
@@ -257,8 +254,10 @@ const playwrightFixtures = {
257
254
  acceptDownloads: [({ contextOptions }, use) => use(contextOptions.acceptDownloads ?? true), { option: true, box: true }],
258
255
  bypassCSP: [({ contextOptions }, use) => use(contextOptions.bypassCSP ?? false), { option: true, box: true }],
259
256
  colorScheme: [({ contextOptions }, use) => use(contextOptions.colorScheme === void 0 ? "light" : contextOptions.colorScheme), { option: true, box: true }],
257
+ contrast: [({ contextOptions }, use) => use(contextOptions.contrast === void 0 ? "no-preference" : contextOptions.contrast), { option: true, box: true }],
260
258
  deviceScaleFactor: [({ contextOptions }, use) => use(contextOptions.deviceScaleFactor), { option: true, box: true }],
261
259
  extraHTTPHeaders: [({ contextOptions }, use) => use(contextOptions.extraHTTPHeaders), { option: true, box: true }],
260
+ forcedColors: [({ contextOptions }, use) => use(contextOptions.forcedColors === void 0 ? "none" : contextOptions.forcedColors), { option: true, box: true }],
262
261
  geolocation: [({ contextOptions }, use) => use(contextOptions.geolocation), { option: true, box: true }],
263
262
  hasTouch: [({ contextOptions }, use) => use(contextOptions.hasTouch ?? false), { option: true, box: true }],
264
263
  httpCredentials: [({ contextOptions }, use) => use(contextOptions.httpCredentials), { option: true, box: true }],
@@ -269,6 +268,7 @@ const playwrightFixtures = {
269
268
  offline: [({ contextOptions }, use) => use(contextOptions.offline ?? false), { option: true, box: true }],
270
269
  permissions: [({ contextOptions }, use) => use(contextOptions.permissions), { option: true, box: true }],
271
270
  proxy: [({ contextOptions }, use) => use(contextOptions.proxy), { option: true, box: true }],
271
+ reducedMotion: [({ contextOptions }, use) => use(contextOptions.reducedMotion === void 0 ? "no-preference" : contextOptions.reducedMotion), { option: true, box: true }],
272
272
  storageState: [({ contextOptions }, use) => use(contextOptions.storageState), { option: true, box: true }],
273
273
  clientCertificates: [({ contextOptions }, use) => use(contextOptions.clientCertificates), { option: true, box: true }],
274
274
  timezoneId: [({ contextOptions }, use) => use(contextOptions.timezoneId), { option: true, box: true }],
@@ -286,8 +286,10 @@ const playwrightFixtures = {
286
286
  bypassCSP,
287
287
  clientCertificates,
288
288
  colorScheme,
289
+ contrast,
289
290
  deviceScaleFactor,
290
291
  extraHTTPHeaders,
292
+ forcedColors,
291
293
  hasTouch,
292
294
  geolocation,
293
295
  httpCredentials,
@@ -298,6 +300,7 @@ const playwrightFixtures = {
298
300
  offline,
299
301
  permissions,
300
302
  proxy,
303
+ reducedMotion,
301
304
  storageState,
302
305
  viewport,
303
306
  timezoneId,
@@ -313,10 +316,14 @@ const playwrightFixtures = {
313
316
  options.bypassCSP = bypassCSP;
314
317
  if (colorScheme !== void 0)
315
318
  options.colorScheme = colorScheme;
319
+ if (contrast !== void 0)
320
+ options.contrast = contrast;
316
321
  if (deviceScaleFactor !== void 0)
317
322
  options.deviceScaleFactor = deviceScaleFactor;
318
323
  if (extraHTTPHeaders !== void 0)
319
324
  options.extraHTTPHeaders = extraHTTPHeaders;
325
+ if (forcedColors !== void 0)
326
+ options.forcedColors = forcedColors;
320
327
  if (geolocation !== void 0)
321
328
  options.geolocation = geolocation;
322
329
  if (hasTouch !== void 0)
@@ -337,6 +344,8 @@ const playwrightFixtures = {
337
344
  options.permissions = permissions;
338
345
  if (proxy !== void 0)
339
346
  options.proxy = proxy;
347
+ if (reducedMotion !== void 0)
348
+ options.reducedMotion = reducedMotion;
340
349
  if (storageState !== void 0)
341
350
  options.storageState = storageState;
342
351
  if (clientCertificates?.length)
@@ -660,6 +669,7 @@ class ArtifactsRecorder {
660
669
  }
661
670
  async didCreateBrowserContext(context) {
662
671
  await this._startTraceChunkOnContextCreation(context, context.tracing);
672
+ await this._startTraceChunkOnContextCreation(context.request, context.request.tracing);
663
673
  }
664
674
  async willCloseBrowserContext(context) {
665
675
  await this._stopTracing(context, context.tracing);
@@ -745,6 +755,7 @@ class ArtifactsRecorder {
745
755
  const leftoverContexts = this._playwright._allContexts();
746
756
  const leftoverApiRequests = Array.from(this._playwright.request._contexts);
747
757
  await Promise.all(leftoverContexts.map(async (context2) => {
758
+ await this._stopTracing(context2.request, context2.request.tracing);
748
759
  await this._stopTracing(context2, context2.tracing);
749
760
  }).concat(leftoverApiRequests.map(async (context2) => {
750
761
  await this._stopTracing(context2, context2.tracing);
@@ -900,11 +911,11 @@ function createTestOverlay(parts, position, fontSize) {
900
911
  </div>`;
901
912
  }
902
913
  function renderTitle(type, method, params, title) {
903
- const prefix = renderTitleForCall({ title, type, method, params });
904
- let selector;
905
- if (params?.["selector"] && typeof params.selector === "string")
906
- selector = asLocatorDescription("javascript", params.selector);
907
- return prefix + (selector ? ` ${selector}` : "");
914
+ return renderTitleForCall({ title, type, method, params });
915
+ }
916
+ function renderSubtitle(type, method, params) {
917
+ const subtitle = renderSubtitleForCall({ type, method, params });
918
+ return subtitle === void 0 ? void 0 : truncateParam(subtitle);
908
919
  }
909
920
  function tracing() {
910
921
  return test.info()._tracing;