patchwright 1.64.1 → 1.65.1
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/README.md +116 -145
- package/helpers.mjs +387 -0
- package/lib/cli/testActions.js +0 -1
- package/lib/common/index.js +142 -65
- package/lib/common/index.js.txt +7 -7
- package/lib/matchers/expect.js +56 -30
- package/lib/matchers/expect.js.LICENSE +3 -3
- package/lib/matchers/expect.js.txt +4 -4
- package/lib/mcp/test/testContext.js +2 -8
- package/lib/runner/index.js +500 -401
- package/lib/runner/index.js.txt +24 -23
- package/lib/transform/babelBundle.js +81 -57
- package/lib/transform/babelBundle.js.txt +2 -2
- package/lib/transform/esmLoader.js +361 -163
- package/lib/transform/esmLoader.js.LICENSE +3 -3
- package/lib/transform/esmLoader.js.txt +9 -8
- package/lib/worker/workerProcessEntry.js +6 -14
- package/lib/worker/workerProcessEntry.js.txt +2 -2
- package/package.json +6 -5
- package/types/test.d.ts +365 -41
- package/types/testReporter.d.ts +22 -2
package/lib/common/index.js
CHANGED
|
@@ -65,6 +65,7 @@ __export(compilationCache_exports, {
|
|
|
65
65
|
getFromCompilationCache: () => getFromCompilationCache,
|
|
66
66
|
installSourceMapSupport: () => installSourceMapSupport,
|
|
67
67
|
internalDependenciesForTestFile: () => internalDependenciesForTestFile,
|
|
68
|
+
recordResolvedFile: () => recordResolvedFile,
|
|
68
69
|
serializeCompilationCache: () => serializeCompilationCache,
|
|
69
70
|
startCollectingFileDeps: () => startCollectingFileDeps,
|
|
70
71
|
stopCollectingFileDeps: () => stopCollectingFileDeps
|
|
@@ -72,11 +73,13 @@ __export(compilationCache_exports, {
|
|
|
72
73
|
var import_fs = __toESM(require("fs"));
|
|
73
74
|
var import_os = __toESM(require("os"));
|
|
74
75
|
var import_path = __toESM(require("path"));
|
|
76
|
+
var import_url = __toESM(require("url"));
|
|
75
77
|
var import_globals = require("../globals");
|
|
76
78
|
var import_package = require("../package");
|
|
77
79
|
var sourceMapSupport = require("patchwright-core/lib/utilsBundle").sourceMapSupport;
|
|
80
|
+
var { MultiMap } = require("patchwright-core/lib/coreBundle").iso;
|
|
78
81
|
var { calculateSha1 } = require("patchwright-core/lib/coreBundle").utils;
|
|
79
|
-
var cacheDir = process.env.PWTEST_CACHE_DIR || (() => {
|
|
82
|
+
var cacheDir = process.env.PLAYWRIGHT_TRANSFORM_CACHE_DIR || process.env.PWTEST_CACHE_DIR || (() => {
|
|
80
83
|
if (process.platform === "win32")
|
|
81
84
|
return import_path.default.join(import_os.default.tmpdir(), `playwright-transform-cache`);
|
|
82
85
|
return import_path.default.join(import_os.default.tmpdir(), `playwright-transform-cache-` + process.geteuid?.());
|
|
@@ -200,12 +203,30 @@ function clearOldCacheEntries(cacheFolderName, filePathHash) {
|
|
|
200
203
|
}
|
|
201
204
|
}
|
|
202
205
|
var depsCollector2;
|
|
206
|
+
var importGraph = new MultiMap();
|
|
207
|
+
function recordResolvedFile(resolvedUrl, parentUrl) {
|
|
208
|
+
if ((0, import_globals.isWorkerProcess)() || !resolvedUrl?.startsWith("file://"))
|
|
209
|
+
return;
|
|
210
|
+
const child = import_url.default.fileURLToPath(resolvedUrl);
|
|
211
|
+
depsCollector2?.add(child);
|
|
212
|
+
if (!parentUrl?.startsWith("file://"))
|
|
213
|
+
return;
|
|
214
|
+
const parent = import_url.default.fileURLToPath(parentUrl);
|
|
215
|
+
if (!belongsToNodeModules(parent) && !importGraph.hasValue(parent, child))
|
|
216
|
+
importGraph.set(parent, child);
|
|
217
|
+
}
|
|
203
218
|
function startCollectingFileDeps() {
|
|
204
219
|
depsCollector2 = /* @__PURE__ */ new Set();
|
|
205
220
|
}
|
|
206
|
-
function stopCollectingFileDeps(filename) {
|
|
221
|
+
function stopCollectingFileDeps(filename, additionalDeps = []) {
|
|
207
222
|
if (!depsCollector2)
|
|
208
223
|
return;
|
|
224
|
+
for (const dep of additionalDeps)
|
|
225
|
+
depsCollector2.add(dep);
|
|
226
|
+
for (const dep of depsCollector2) {
|
|
227
|
+
for (const child of importGraph.get(dep))
|
|
228
|
+
depsCollector2.add(child);
|
|
229
|
+
}
|
|
209
230
|
depsCollector2.delete(filename);
|
|
210
231
|
for (const dep of depsCollector2) {
|
|
211
232
|
if (belongsToNodeModules(dep))
|
|
@@ -531,7 +552,7 @@ var FullConfigInternal = class {
|
|
|
531
552
|
updateSnapshots: takeFirst(configCLIOverrides.updateSnapshots, userConfig.updateSnapshots, "default"),
|
|
532
553
|
updateSourceMethod: takeFirst(configCLIOverrides.updateSourceMethod, userConfig.updateSourceMethod, "patch"),
|
|
533
554
|
version: import_package2.packageJSON.version,
|
|
534
|
-
workers: resolveWorkers(takeFirst(configCLIOverrides.debug
|
|
555
|
+
workers: resolveWorkers(takeFirst(configCLIOverrides.debug ? 1 : void 0, configCLIOverrides.workers, userConfig.workers, "50%")),
|
|
535
556
|
webServer: null
|
|
536
557
|
};
|
|
537
558
|
for (const key in userConfig) {
|
|
@@ -690,7 +711,7 @@ function toReporters(reporters) {
|
|
|
690
711
|
return [[reporters]];
|
|
691
712
|
return reporters;
|
|
692
713
|
}
|
|
693
|
-
var builtInReporters = ["list", "line", "dot", "json", "junit", "null", "github", "html", "blob", "perfetto", "coverage"];
|
|
714
|
+
var builtInReporters = ["list", "line", "dot", "failures", "json", "junit", "null", "github", "html", "blob", "perfetto", "coverage"];
|
|
694
715
|
function resolveScript(id, rootDir) {
|
|
695
716
|
if (!id)
|
|
696
717
|
return void 0;
|
|
@@ -722,7 +743,10 @@ var import_path7 = __toESM(require("path"));
|
|
|
722
743
|
// packages/playwright/src/transform/transform.ts
|
|
723
744
|
var transform_exports = {};
|
|
724
745
|
__export(transform_exports, {
|
|
746
|
+
hasTransformedExtension: () => hasTransformedExtension,
|
|
725
747
|
incorporateCompilationCache: () => incorporateCompilationCache,
|
|
748
|
+
installTransformIfNeeded: () => installTransformIfNeeded,
|
|
749
|
+
isStyleFile: () => isStyleFile,
|
|
726
750
|
requireOrImport: () => requireOrImport,
|
|
727
751
|
resolveHook: () => resolveHook,
|
|
728
752
|
setSingleTSConfig: () => setSingleTSConfig,
|
|
@@ -736,7 +760,7 @@ __export(transform_exports, {
|
|
|
736
760
|
var import_fs6 = __toESM(require("fs"));
|
|
737
761
|
var import_module2 = __toESM(require("module"));
|
|
738
762
|
var import_path6 = __toESM(require("path"));
|
|
739
|
-
var
|
|
763
|
+
var import_url3 = __toESM(require("url"));
|
|
740
764
|
var import_crypto = __toESM(require("crypto"));
|
|
741
765
|
|
|
742
766
|
// packages/playwright/src/transform/tsconfig-loader.ts
|
|
@@ -755,13 +779,26 @@ ${e.message}`);
|
|
|
755
779
|
}
|
|
756
780
|
}
|
|
757
781
|
function resolveConfigFile(baseConfigFile, referencedConfigFile) {
|
|
758
|
-
if (!referencedConfigFile.endsWith(".json"))
|
|
759
|
-
referencedConfigFile += ".json";
|
|
760
782
|
const currentDir = import_path4.default.dirname(baseConfigFile);
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
783
|
+
const referencedFile = referencedConfigFile.endsWith(".json") ? referencedConfigFile : referencedConfigFile + ".json";
|
|
784
|
+
const resolvedConfigFile = import_path4.default.resolve(currentDir, referencedFile);
|
|
785
|
+
if (import_fs4.default.existsSync(resolvedConfigFile) || referencedConfigFile.startsWith(".") || import_path4.default.isAbsolute(referencedConfigFile))
|
|
786
|
+
return resolvedConfigFile;
|
|
787
|
+
const packageDir = import_path4.default.join(currentDir, "node_modules", referencedConfigFile);
|
|
788
|
+
const candidates = [import_path4.default.join(currentDir, "node_modules", referencedFile)];
|
|
789
|
+
const packageTsconfig = packageJsonTsconfigField(import_path4.default.join(packageDir, "package.json"));
|
|
790
|
+
if (packageTsconfig)
|
|
791
|
+
candidates.push(import_path4.default.resolve(packageDir, packageTsconfig));
|
|
792
|
+
candidates.push(import_path4.default.join(packageDir, "tsconfig.json"));
|
|
793
|
+
return candidates.find((candidate) => import_fs4.default.existsSync(candidate)) ?? resolvedConfigFile;
|
|
794
|
+
}
|
|
795
|
+
function packageJsonTsconfigField(packageJsonFile) {
|
|
796
|
+
try {
|
|
797
|
+
const tsconfig = JSON.parse(import_fs4.default.readFileSync(packageJsonFile, "utf8")).tsconfig;
|
|
798
|
+
return typeof tsconfig === "string" ? tsconfig : void 0;
|
|
799
|
+
} catch {
|
|
800
|
+
return void 0;
|
|
801
|
+
}
|
|
765
802
|
}
|
|
766
803
|
function innerLoadTsConfig(configFilePath, references, visited = /* @__PURE__ */ new Map()) {
|
|
767
804
|
if (visited.has(configFilePath))
|
|
@@ -787,6 +824,10 @@ function innerLoadTsConfig(configFilePath, references, visited = /* @__PURE__ */
|
|
|
787
824
|
if (parsedConfig.compilerOptions?.[name] !== void 0)
|
|
788
825
|
result2[name] = parsedConfig.compilerOptions[name];
|
|
789
826
|
}
|
|
827
|
+
if (parsedConfig.compilerOptions?.target !== void 0)
|
|
828
|
+
result2.target = parsedConfig.compilerOptions.target;
|
|
829
|
+
if (parsedConfig.compilerOptions?.useDefineForClassFields !== void 0)
|
|
830
|
+
result2.useDefineForClassFields = parsedConfig.compilerOptions.useDefineForClassFields;
|
|
790
831
|
if (parsedConfig.compilerOptions?.paths !== void 0) {
|
|
791
832
|
result2.paths = {
|
|
792
833
|
mapping: parsedConfig.compilerOptions.paths,
|
|
@@ -817,18 +858,17 @@ var import_package3 = require("../package");
|
|
|
817
858
|
|
|
818
859
|
// packages/playwright/src/transform/esmLoaderSync.ts
|
|
819
860
|
var import_fs5 = __toESM(require("fs"));
|
|
820
|
-
var
|
|
861
|
+
var import_url2 = __toESM(require("url"));
|
|
821
862
|
function resolve(specifier, context, nextResolve) {
|
|
822
863
|
if (context.parentURL && context.parentURL.startsWith("file://")) {
|
|
823
|
-
const filename =
|
|
864
|
+
const filename = import_url2.default.fileURLToPath(context.parentURL);
|
|
824
865
|
const resolved = resolveHook(filename, specifier);
|
|
825
866
|
if (resolved !== void 0) {
|
|
826
|
-
specifier = new Set(context.conditions).has("import") ?
|
|
867
|
+
specifier = new Set(context.conditions).has("import") ? import_url2.default.pathToFileURL(resolved).toString() : resolved;
|
|
827
868
|
}
|
|
828
869
|
}
|
|
829
870
|
const result2 = nextResolve(specifier, context);
|
|
830
|
-
|
|
831
|
-
currentFileDepsCollector()?.add(import_url.default.fileURLToPath(result2.url));
|
|
871
|
+
recordResolvedFile(result2?.url, context.parentURL);
|
|
832
872
|
return result2;
|
|
833
873
|
}
|
|
834
874
|
var kSupportedFormats = /* @__PURE__ */ new Map([
|
|
@@ -845,8 +885,10 @@ function load(moduleUrl, context, nextLoad) {
|
|
|
845
885
|
return nextLoad(moduleUrl, context);
|
|
846
886
|
if (!moduleUrl.startsWith("file://"))
|
|
847
887
|
return nextLoad(moduleUrl, context);
|
|
848
|
-
const filename =
|
|
849
|
-
if (
|
|
888
|
+
const filename = import_url2.default.fileURLToPath(moduleUrl);
|
|
889
|
+
if (isStyleFile(filename))
|
|
890
|
+
return { format: "commonjs", source: "", shortCircuit: true };
|
|
891
|
+
if (!shouldTransform(filename) || !hasTransformedExtension(filename))
|
|
850
892
|
return nextLoad(moduleUrl, context);
|
|
851
893
|
const isRequire = !new Set(context.conditions).has("import");
|
|
852
894
|
const format = isRequire ? "commonjs" : kSupportedFormats.get(context.format) || (fileIsModule(filename) ? "module" : "commonjs");
|
|
@@ -961,9 +1003,15 @@ function validateTsConfig(tsconfig) {
|
|
|
961
1003
|
jsxFactory: tsconfig.jsxFactory,
|
|
962
1004
|
jsxFragmentFactory: tsconfig.jsxFragmentFactory,
|
|
963
1005
|
jsxImportSource: tsconfig.jsxImportSource
|
|
964
|
-
} : void 0
|
|
1006
|
+
} : void 0,
|
|
1007
|
+
useDefineForClassFields: tsconfig.useDefineForClassFields ?? (tsconfig.target ? targetUsesDefineForClassFields(tsconfig.target) : void 0)
|
|
965
1008
|
};
|
|
966
1009
|
}
|
|
1010
|
+
function targetUsesDefineForClassFields(target) {
|
|
1011
|
+
const normalized = target.toLowerCase();
|
|
1012
|
+
const year = normalized.match(/^es(\d{4})$/)?.[1];
|
|
1013
|
+
return normalized === "esnext" || !!year && +year >= 2022;
|
|
1014
|
+
}
|
|
967
1015
|
function loadAndValidateTsconfigsForFile(file2) {
|
|
968
1016
|
if (_singleTSConfigPath && !_singleTSConfig)
|
|
969
1017
|
_singleTSConfig = loadTsConfig(_singleTSConfigPath).map(validateTsConfig);
|
|
@@ -1058,37 +1106,48 @@ function resolveHook(filename, specifier) {
|
|
|
1058
1106
|
return resolveImportSpecifierAfterMapping(specifier, false);
|
|
1059
1107
|
}
|
|
1060
1108
|
}
|
|
1109
|
+
var kStyleExtensions = [".css", ".less", ".scss"];
|
|
1110
|
+
function isStyleFile(filename) {
|
|
1111
|
+
return kStyleExtensions.includes(import_path6.default.extname(filename));
|
|
1112
|
+
}
|
|
1061
1113
|
function shouldTransform(filename) {
|
|
1062
1114
|
if (_externalMatcher(filename))
|
|
1063
1115
|
return false;
|
|
1064
1116
|
return !belongsToNodeModules(filename);
|
|
1065
1117
|
}
|
|
1118
|
+
var kTransformedExtensions = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".mts", ".cjs", ".cts"];
|
|
1119
|
+
function hasTransformedExtension(filename) {
|
|
1120
|
+
const extension = import_path6.default.extname(filename);
|
|
1121
|
+
return !extension || kTransformedExtensions.includes(extension);
|
|
1122
|
+
}
|
|
1066
1123
|
function transformHook(originalCode, filename, moduleUrl) {
|
|
1067
1124
|
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));
|
|
1068
1125
|
const pluginsEpilogue = hasPreprocessor ? [[process.env.PW_TEST_SOURCE_TRANSFORM]] : [];
|
|
1069
|
-
const
|
|
1070
|
-
const
|
|
1126
|
+
const tsconfigs = loadAndValidateTsconfigsForFile(filename);
|
|
1127
|
+
const jsx = tsconfigs.find((tsconfig) => tsconfig.jsx)?.jsx;
|
|
1128
|
+
const useDefineForClassFields = tsconfigs.find((tsconfig) => tsconfig.useDefineForClassFields !== void 0)?.useDefineForClassFields ?? true;
|
|
1129
|
+
const hash = calculateHash(originalCode, filename, !!moduleUrl, pluginsEpilogue, useDefineForClassFields, jsx);
|
|
1071
1130
|
const { cachedCode, addToCache, serializedCache } = getFromCompilationCache(filename, hash, moduleUrl);
|
|
1072
1131
|
if (cachedCode !== void 0)
|
|
1073
1132
|
return { code: cachedCode, serializedCache };
|
|
1074
1133
|
process.env.BROWSERSLIST_IGNORE_OLD_DATA = "true";
|
|
1075
1134
|
const { babelTransform } = require((0, import_package3.libPath)("transform", "babelBundle"));
|
|
1076
|
-
const babelResult = babelTransform(originalCode, filename, !!moduleUrl, pluginsEpilogue, jsx);
|
|
1135
|
+
const babelResult = babelTransform(originalCode, filename, !!moduleUrl, pluginsEpilogue, useDefineForClassFields, jsx);
|
|
1077
1136
|
if (!babelResult?.code)
|
|
1078
1137
|
return { code: originalCode, serializedCache };
|
|
1079
1138
|
const { code, map } = babelResult;
|
|
1080
1139
|
const added = addToCache(code, map);
|
|
1081
1140
|
return { code, serializedCache: added.serializedCache };
|
|
1082
1141
|
}
|
|
1083
|
-
function calculateHash(content, filePath, isModule2, pluginsEpilogue, jsx) {
|
|
1084
|
-
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(",")).update(jsx ? JSON.stringify(jsx) : "").digest("hex");
|
|
1142
|
+
function calculateHash(content, filePath, isModule2, pluginsEpilogue, useDefineForClassFields, jsx) {
|
|
1143
|
+
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(",")).update(useDefineForClassFields ? "define" : "assign").update(jsx ? JSON.stringify(jsx) : "").digest("hex");
|
|
1085
1144
|
return hash;
|
|
1086
1145
|
}
|
|
1087
1146
|
async function requireOrImport(file) {
|
|
1088
1147
|
installTransformIfNeeded();
|
|
1089
1148
|
const isModule = fileIsModule(file);
|
|
1090
1149
|
if (isModule) {
|
|
1091
|
-
const fileName =
|
|
1150
|
+
const fileName = import_url3.default.pathToFileURL(file);
|
|
1092
1151
|
const esmImport = () => eval(`import(${JSON.stringify(fileName)})`);
|
|
1093
1152
|
if (loaderChannel) {
|
|
1094
1153
|
await eval(`import(${JSON.stringify(fileName + ".esm.preflight")})`).catch((error) => debugTest("Failed to load preflight for " + file + ", source maps may be missing for errors thrown during loading.", error)).finally(nextTask);
|
|
@@ -1113,6 +1172,8 @@ function installTransformIfNeeded() {
|
|
|
1113
1172
|
if (transformInstalled)
|
|
1114
1173
|
return;
|
|
1115
1174
|
transformInstalled = true;
|
|
1175
|
+
if ("Bun" in globalThis)
|
|
1176
|
+
return;
|
|
1116
1177
|
registerESMLoader();
|
|
1117
1178
|
installSourceMapSupport();
|
|
1118
1179
|
if (loaderChannel) {
|
|
@@ -1136,7 +1197,11 @@ function installCJSHooks() {
|
|
|
1136
1197
|
import_module2.default._resolveFilename = resolveFilename;
|
|
1137
1198
|
addHook((code, filename) => {
|
|
1138
1199
|
return transformHook(code, filename).code;
|
|
1139
|
-
}, shouldTransform,
|
|
1200
|
+
}, shouldTransform, kTransformedExtensions);
|
|
1201
|
+
const extensions = import_module2.default._extensions;
|
|
1202
|
+
for (const ext of kStyleExtensions)
|
|
1203
|
+
extensions[ext] = () => {
|
|
1204
|
+
};
|
|
1140
1205
|
}
|
|
1141
1206
|
var collectCJSDependencies = (module2, dependencies) => {
|
|
1142
1207
|
module2.children.forEach((child) => {
|
|
@@ -1149,26 +1214,41 @@ var collectCJSDependencies = (module2, dependencies) => {
|
|
|
1149
1214
|
function wrapFunctionWithLocation(func) {
|
|
1150
1215
|
return (...args) => {
|
|
1151
1216
|
const oldPrepareStackTrace = Error.prepareStackTrace;
|
|
1152
|
-
Error.prepareStackTrace = (error, stackFrames) => {
|
|
1153
|
-
const frame = sourceMapSupport2.wrapCallSite(stackFrames[1]);
|
|
1154
|
-
const fileName2 = frame.getFileName();
|
|
1155
|
-
const file2 = fileName2 && fileName2.startsWith("file://") ? import_url2.default.fileURLToPath(fileName2) : fileName2;
|
|
1156
|
-
return {
|
|
1157
|
-
file: file2,
|
|
1158
|
-
line: frame.getLineNumber(),
|
|
1159
|
-
column: frame.getColumnNumber()
|
|
1160
|
-
};
|
|
1161
|
-
};
|
|
1162
1217
|
const oldStackTraceLimit = Error.stackTraceLimit;
|
|
1218
|
+
Error.prepareStackTrace = bunHasZeroBasedColumns ? bunCallerLocation : nodeCallerLocation;
|
|
1163
1219
|
Error.stackTraceLimit = 2;
|
|
1164
1220
|
const obj = {};
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1221
|
+
let location;
|
|
1222
|
+
try {
|
|
1223
|
+
Error.captureStackTrace(obj);
|
|
1224
|
+
location = obj.stack;
|
|
1225
|
+
} finally {
|
|
1226
|
+
Error.stackTraceLimit = oldStackTraceLimit;
|
|
1227
|
+
Error.prepareStackTrace = oldPrepareStackTrace;
|
|
1228
|
+
}
|
|
1169
1229
|
return func(location, ...args);
|
|
1170
1230
|
};
|
|
1171
1231
|
}
|
|
1232
|
+
function nodeCallerLocation(error, stackFrames) {
|
|
1233
|
+
const frame = sourceMapSupport2.wrapCallSite(stackFrames[1]);
|
|
1234
|
+
const fileName2 = frame.getFileName();
|
|
1235
|
+
const file2 = fileName2 && fileName2.startsWith("file://") ? import_url3.default.fileURLToPath(fileName2) : fileName2;
|
|
1236
|
+
return {
|
|
1237
|
+
file: file2,
|
|
1238
|
+
line: frame.getLineNumber(),
|
|
1239
|
+
column: frame.getColumnNumber()
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
var bunHasZeroBasedColumns = "Bun" in globalThis && Bun.semver.order(Bun.version, "1.4.4") < 0;
|
|
1243
|
+
function bunCallerLocation(error, stackFrames) {
|
|
1244
|
+
const frame = stackFrames[1];
|
|
1245
|
+
const position = sourceMapSupport2.mapSourcePosition({ source: frame.getFileName(), line: frame.getLineNumber(), column: frame.getColumnNumber() });
|
|
1246
|
+
return {
|
|
1247
|
+
file: position.source,
|
|
1248
|
+
line: position.line,
|
|
1249
|
+
column: position.column + 1
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1172
1252
|
function isRelativeSpecifier(specifier) {
|
|
1173
1253
|
return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
|
|
1174
1254
|
}
|
|
@@ -1179,8 +1259,6 @@ var loaderChannel;
|
|
|
1179
1259
|
function registerESMLoader() {
|
|
1180
1260
|
if (process.env.PW_DISABLE_TS_ESM)
|
|
1181
1261
|
return;
|
|
1182
|
-
if ("Bun" in globalThis)
|
|
1183
|
-
return;
|
|
1184
1262
|
const nodeModule = require("node:module");
|
|
1185
1263
|
if (nodeModule.registerHooks && !process.env.PLAYWRIGHT_FORCE_ASYNC_LOADER) {
|
|
1186
1264
|
nodeModule.registerHooks({ resolve, load });
|
|
@@ -1189,7 +1267,7 @@ function registerESMLoader() {
|
|
|
1189
1267
|
if (!nodeModule.register)
|
|
1190
1268
|
return;
|
|
1191
1269
|
const { port1, port2 } = new MessageChannel();
|
|
1192
|
-
nodeModule.register(
|
|
1270
|
+
nodeModule.register(import_url3.default.pathToFileURL(require.resolve("../transform/esmLoader.js")), {
|
|
1193
1271
|
data: { port: port2 },
|
|
1194
1272
|
transferList: [port2]
|
|
1195
1273
|
});
|
|
@@ -1209,7 +1287,7 @@ async function startCollectingFileDeps2() {
|
|
|
1209
1287
|
async function stopCollectingFileDeps2(file2) {
|
|
1210
1288
|
stopCollectingFileDeps(file2);
|
|
1211
1289
|
if (loaderChannel)
|
|
1212
|
-
await loaderChannel.send("stopCollectingFileDeps", { file: file2 });
|
|
1290
|
+
await loaderChannel.send("stopCollectingFileDeps", { file: file2, dependencies: [...dependenciesForTestFile(file2)] });
|
|
1213
1291
|
}
|
|
1214
1292
|
async function incorporateCompilationCache() {
|
|
1215
1293
|
if (!loaderChannel)
|
|
@@ -1281,8 +1359,8 @@ async function deserializeConfig(data) {
|
|
|
1281
1359
|
}
|
|
1282
1360
|
async function loadUserConfig(location) {
|
|
1283
1361
|
let object = location.resolvedConfigFile ? await requireOrImport(location.resolvedConfigFile) : {};
|
|
1284
|
-
if (object && typeof object === "object"
|
|
1285
|
-
object = object["default"];
|
|
1362
|
+
if (object && typeof object === "object")
|
|
1363
|
+
object = "default" in object ? object["default"] : { ...object };
|
|
1286
1364
|
return object;
|
|
1287
1365
|
}
|
|
1288
1366
|
async function loadConfig(location, overrides, ignoreProjectDependencies = false, metadata) {
|
|
@@ -1507,8 +1585,8 @@ function resolveConfigFile2(configFileOrDirectory) {
|
|
|
1507
1585
|
async function loadConfigFromFile(configFile, overrides, ignoreDeps) {
|
|
1508
1586
|
return await loadConfig(resolveConfigLocation(configFile), overrides, ignoreDeps);
|
|
1509
1587
|
}
|
|
1510
|
-
async function loadEmptyConfigForMergeReports() {
|
|
1511
|
-
return await loadConfig({ configDir: process.cwd() });
|
|
1588
|
+
async function loadEmptyConfigForMergeReports(overrides) {
|
|
1589
|
+
return await loadConfig({ configDir: process.cwd() }, overrides);
|
|
1512
1590
|
}
|
|
1513
1591
|
|
|
1514
1592
|
// packages/playwright/src/common/fixtures.ts
|
|
@@ -2368,7 +2446,7 @@ var TestTypeImpl = class _TestTypeImpl {
|
|
|
2368
2446
|
} else {
|
|
2369
2447
|
if (modifierArgs.length >= 1 && !modifierArgs[0])
|
|
2370
2448
|
return;
|
|
2371
|
-
const description = modifierArgs[1];
|
|
2449
|
+
const description = modifierArgs.length === 1 && typeof modifierArgs[0] === "string" ? modifierArgs[0] : modifierArgs[1];
|
|
2372
2450
|
suite._staticAnnotations.push({ type, description, location });
|
|
2373
2451
|
}
|
|
2374
2452
|
return;
|
|
@@ -2862,7 +2940,6 @@ __export(testLoader_exports, {
|
|
|
2862
2940
|
loadTestFile: () => loadTestFile
|
|
2863
2941
|
});
|
|
2864
2942
|
var import_path9 = __toESM(require("path"));
|
|
2865
|
-
var import_util11 = __toESM(require("util"));
|
|
2866
2943
|
var import_globals3 = require("../globals");
|
|
2867
2944
|
var defaultTimeout2 = 3e4;
|
|
2868
2945
|
var cachedFileSuites = /* @__PURE__ */ new Map();
|
|
@@ -2874,15 +2951,16 @@ async function loadTestFile(file2, config, testErrors) {
|
|
|
2874
2951
|
suite.location = { file: file2, line: 0, column: 0 };
|
|
2875
2952
|
suite._tags = [...config.config.tags];
|
|
2876
2953
|
(0, import_globals3.setCurrentlyLoadingFileSuite)(suite);
|
|
2877
|
-
if (!(0, import_globals3.isWorkerProcess)())
|
|
2878
|
-
await startCollectingFileDeps2();
|
|
2879
2954
|
try {
|
|
2955
|
+
installTransformIfNeeded();
|
|
2956
|
+
if (!(0, import_globals3.isWorkerProcess)())
|
|
2957
|
+
await startCollectingFileDeps2();
|
|
2880
2958
|
await requireOrImport(file2);
|
|
2881
2959
|
cachedFileSuites.set(file2, suite);
|
|
2882
2960
|
} catch (e) {
|
|
2883
2961
|
if (!testErrors)
|
|
2884
2962
|
throw e;
|
|
2885
|
-
testErrors.push(
|
|
2963
|
+
testErrors.push(...serializeLoadErrors(e));
|
|
2886
2964
|
} finally {
|
|
2887
2965
|
(0, import_globals3.setCurrentlyLoadingFileSuite)(void 0);
|
|
2888
2966
|
if (!(0, import_globals3.isWorkerProcess)())
|
|
@@ -2901,18 +2979,17 @@ async function loadTestFile(file2, config, testErrors) {
|
|
|
2901
2979
|
}
|
|
2902
2980
|
return suite;
|
|
2903
2981
|
}
|
|
2904
|
-
function
|
|
2905
|
-
if (error instanceof
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
}
|
|
2915
|
-
return { value: import_util11.default.inspect(error) };
|
|
2982
|
+
function serializeLoadErrors(error) {
|
|
2983
|
+
if (error instanceof AggregateError)
|
|
2984
|
+
return error.errors.flatMap(serializeLoadErrors);
|
|
2985
|
+
const result2 = serializeError(error);
|
|
2986
|
+
if (error instanceof Error)
|
|
2987
|
+
result2.location = parseErrorLocation(error);
|
|
2988
|
+
return [result2];
|
|
2989
|
+
}
|
|
2990
|
+
function parseErrorLocation(error) {
|
|
2991
|
+
const location = error.loc ?? error.position;
|
|
2992
|
+
return location && { file: location.file, line: location.line, column: location.column };
|
|
2916
2993
|
}
|
|
2917
2994
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2918
2995
|
0 && (module.exports = {
|
package/lib/common/index.js.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# packages/playwright/lib/common/index.js
|
|
2
|
-
# total:
|
|
2
|
+
# total: 117.7 KB
|
|
3
3
|
|
|
4
4
|
## Inlined (20)
|
|
5
5
|
12.5 KB packages/playwright/src/common/config.ts
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
3.9 KB packages/playwright/src/common/process.ts
|
|
12
12
|
4.9 KB packages/playwright/src/common/suiteUtils.ts
|
|
13
13
|
8.7 KB packages/playwright/src/common/test.ts
|
|
14
|
-
2.
|
|
15
|
-
|
|
14
|
+
2.1 KB packages/playwright/src/common/testLoader.ts
|
|
15
|
+
13.0 KB packages/playwright/src/common/testType.ts
|
|
16
16
|
1.4 KB packages/playwright/src/common/validators.ts
|
|
17
17
|
1.3 KB packages/playwright/src/isomorphic/teleReceiver.ts
|
|
18
|
-
7
|
|
19
|
-
1.
|
|
18
|
+
8.7 KB packages/playwright/src/transform/compilationCache.ts
|
|
19
|
+
1.8 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
|
-
|
|
23
|
-
|
|
22
|
+
13.8 KB packages/playwright/src/transform/transform.ts
|
|
23
|
+
4.2 KB packages/playwright/src/transform/tsconfig-loader.ts
|
|
24
24
|
7.0 KB packages/playwright/src/util.ts
|
|
25
25
|
|
|
26
26
|
## External (7)
|
package/lib/matchers/expect.js
CHANGED
|
@@ -7336,7 +7336,7 @@ var require_scan = __commonJS({
|
|
|
7336
7336
|
var scan = (input, options) => {
|
|
7337
7337
|
const opts = options || {};
|
|
7338
7338
|
const length = input.length - 1;
|
|
7339
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
7339
|
+
const scanToEnd = opts.parts === true || opts.tokens === true || opts.scanToEnd === true;
|
|
7340
7340
|
const slashes = [];
|
|
7341
7341
|
const tokens = [];
|
|
7342
7342
|
const parts = [];
|
|
@@ -7442,14 +7442,18 @@ var require_scan = __commonJS({
|
|
|
7442
7442
|
negatedExtglob = true;
|
|
7443
7443
|
}
|
|
7444
7444
|
if (scanToEnd === true) {
|
|
7445
|
+
let parens = 0;
|
|
7445
7446
|
while (eos() !== true && (code = advance())) {
|
|
7446
7447
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
7447
7448
|
backslashes = token.backslashes = true;
|
|
7448
|
-
|
|
7449
|
+
advance();
|
|
7450
|
+
continue;
|
|
7451
|
+
}
|
|
7452
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
7453
|
+
parens++;
|
|
7449
7454
|
continue;
|
|
7450
7455
|
}
|
|
7451
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
7452
|
-
isGlob = token.isGlob = true;
|
|
7456
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
7453
7457
|
finished = true;
|
|
7454
7458
|
break;
|
|
7455
7459
|
}
|
|
@@ -7503,13 +7507,18 @@ var require_scan = __commonJS({
|
|
|
7503
7507
|
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
7504
7508
|
isGlob = token.isGlob = true;
|
|
7505
7509
|
if (scanToEnd === true) {
|
|
7510
|
+
let parens = 1;
|
|
7506
7511
|
while (eos() !== true && (code = advance())) {
|
|
7507
|
-
if (code ===
|
|
7512
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
7508
7513
|
backslashes = token.backslashes = true;
|
|
7509
|
-
|
|
7514
|
+
advance();
|
|
7510
7515
|
continue;
|
|
7511
7516
|
}
|
|
7512
|
-
if (code ===
|
|
7517
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
7518
|
+
parens++;
|
|
7519
|
+
continue;
|
|
7520
|
+
}
|
|
7521
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
7513
7522
|
finished = true;
|
|
7514
7523
|
break;
|
|
7515
7524
|
}
|
|
@@ -7582,32 +7591,31 @@ var require_scan = __commonJS({
|
|
|
7582
7591
|
if (opts.parts === true || opts.tokens === true) {
|
|
7583
7592
|
let prevIndex;
|
|
7584
7593
|
for (let idx = 0; idx < slashes.length; idx++) {
|
|
7585
|
-
const
|
|
7594
|
+
const n2 = prevIndex !== void 0 ? prevIndex + 1 : start;
|
|
7586
7595
|
const i = slashes[idx];
|
|
7587
|
-
const
|
|
7596
|
+
const value2 = input.slice(n2, i);
|
|
7588
7597
|
if (opts.tokens) {
|
|
7589
7598
|
if (idx === 0 && start !== 0) {
|
|
7590
7599
|
tokens[idx].isPrefix = true;
|
|
7591
7600
|
tokens[idx].value = prefix;
|
|
7592
7601
|
} else {
|
|
7593
|
-
tokens[idx].value =
|
|
7602
|
+
tokens[idx].value = value2;
|
|
7594
7603
|
}
|
|
7595
7604
|
depth(tokens[idx]);
|
|
7596
7605
|
state.maxDepth += tokens[idx].depth;
|
|
7597
7606
|
}
|
|
7598
|
-
if (
|
|
7599
|
-
parts.push(
|
|
7607
|
+
if (i >= start) {
|
|
7608
|
+
parts.push(value2);
|
|
7609
|
+
prevIndex = i;
|
|
7600
7610
|
}
|
|
7601
|
-
prevIndex = i;
|
|
7602
7611
|
}
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
}
|
|
7612
|
+
const n = prevIndex !== void 0 ? prevIndex + 1 : start;
|
|
7613
|
+
const value = input.slice(n);
|
|
7614
|
+
parts.push(value);
|
|
7615
|
+
if (opts.tokens && prevIndex && prevIndex + 1 < input.length) {
|
|
7616
|
+
tokens[tokens.length - 1].value = value;
|
|
7617
|
+
depth(tokens[tokens.length - 1]);
|
|
7618
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
7611
7619
|
}
|
|
7612
7620
|
state.slashes = slashes;
|
|
7613
7621
|
state.parts = parts;
|
|
@@ -7796,7 +7804,11 @@ var require_parse = __commonJS({
|
|
|
7796
7804
|
}
|
|
7797
7805
|
}
|
|
7798
7806
|
};
|
|
7799
|
-
var
|
|
7807
|
+
var buildCharClassStar = (chars) => {
|
|
7808
|
+
const source = chars.length === 1 ? utils2.escapeRegex(chars[0]) : `[${chars.map((ch) => utils2.escapeRegex(ch)).join("")}]`;
|
|
7809
|
+
return `${source}*`;
|
|
7810
|
+
};
|
|
7811
|
+
var getStarExtglobSequenceChars = (pattern) => {
|
|
7800
7812
|
let index = 0;
|
|
7801
7813
|
const chars = [];
|
|
7802
7814
|
while (index < pattern.length) {
|
|
@@ -7818,8 +7830,7 @@ var require_parse = __commonJS({
|
|
|
7818
7830
|
if (chars.length < 1) {
|
|
7819
7831
|
return;
|
|
7820
7832
|
}
|
|
7821
|
-
|
|
7822
|
-
return `${source}*`;
|
|
7833
|
+
return chars;
|
|
7823
7834
|
};
|
|
7824
7835
|
var repeatedExtglobRecursion = (pattern) => {
|
|
7825
7836
|
let depth = 0;
|
|
@@ -7843,15 +7854,29 @@ var require_parse = __commonJS({
|
|
|
7843
7854
|
return { risky: true };
|
|
7844
7855
|
}
|
|
7845
7856
|
}
|
|
7857
|
+
const safeChars = [];
|
|
7858
|
+
let sawStarSequence = false;
|
|
7859
|
+
let combinable = true;
|
|
7846
7860
|
for (const branch of branches) {
|
|
7847
|
-
const
|
|
7848
|
-
if (
|
|
7849
|
-
|
|
7861
|
+
const chars = getStarExtglobSequenceChars(branch);
|
|
7862
|
+
if (chars) {
|
|
7863
|
+
sawStarSequence = true;
|
|
7864
|
+
safeChars.push(...chars);
|
|
7865
|
+
continue;
|
|
7866
|
+
}
|
|
7867
|
+
const literal = normalizeSimpleBranch(branch);
|
|
7868
|
+
if (literal && literal.length === 1) {
|
|
7869
|
+
safeChars.push(literal);
|
|
7870
|
+
continue;
|
|
7850
7871
|
}
|
|
7872
|
+
combinable = false;
|
|
7851
7873
|
if (repeatedExtglobRecursion(branch) > max) {
|
|
7852
7874
|
return { risky: true };
|
|
7853
7875
|
}
|
|
7854
7876
|
}
|
|
7877
|
+
if (sawStarSequence) {
|
|
7878
|
+
return combinable ? { risky: true, safeOutput: buildCharClassStar([...new Set(safeChars)]) } : { risky: true };
|
|
7879
|
+
}
|
|
7855
7880
|
return { risky: false };
|
|
7856
7881
|
};
|
|
7857
7882
|
var parse = (input, options) => {
|
|
@@ -8433,6 +8458,7 @@ var require_parse = __commonJS({
|
|
|
8433
8458
|
rest = rest.slice(3);
|
|
8434
8459
|
consume("/**", 3);
|
|
8435
8460
|
}
|
|
8461
|
+
const isEnd = eos() || state.parens > 0 && rest === ")".repeat(state.parens) && !extglobs.some((extglob) => extglob.type === "negate");
|
|
8436
8462
|
if (prior.type === "bos" && eos()) {
|
|
8437
8463
|
prev.type = "globstar";
|
|
8438
8464
|
prev.value += value;
|
|
@@ -8442,7 +8468,7 @@ var require_parse = __commonJS({
|
|
|
8442
8468
|
consume(value);
|
|
8443
8469
|
continue;
|
|
8444
8470
|
}
|
|
8445
|
-
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar &&
|
|
8471
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && isEnd) {
|
|
8446
8472
|
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
8447
8473
|
prior.output = `(?:${prior.output}`;
|
|
8448
8474
|
prev.type = "globstar";
|
|
@@ -8701,9 +8727,9 @@ var require_picomatch = __commonJS({
|
|
|
8701
8727
|
}
|
|
8702
8728
|
return { isMatch: Boolean(match), match, output };
|
|
8703
8729
|
};
|
|
8704
|
-
picomatch.matchBase = (input, glob, options) => {
|
|
8730
|
+
picomatch.matchBase = (input, glob, options, posix = options && options.windows) => {
|
|
8705
8731
|
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
8706
|
-
return regex.test(utils2.basename(input));
|
|
8732
|
+
return regex.test(utils2.basename(input, { windows: posix }));
|
|
8707
8733
|
};
|
|
8708
8734
|
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
8709
8735
|
picomatch.parse = (pattern, options) => {
|