First Commit

This commit is contained in:
2025-08-28 19:35:28 -07:00
commit 264e65006a
488 changed files with 155661 additions and 0 deletions

274
node_modules/playwright/lib/common/config.js generated vendored Normal file
View File

@@ -0,0 +1,274 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var config_exports = {};
__export(config_exports, {
FullConfigInternal: () => FullConfigInternal,
FullProjectInternal: () => FullProjectInternal,
builtInReporters: () => builtInReporters,
defaultGrep: () => defaultGrep,
defaultReporter: () => defaultReporter,
defaultTimeout: () => defaultTimeout,
getProjectId: () => getProjectId,
takeFirst: () => takeFirst,
toReporters: () => toReporters
});
module.exports = __toCommonJS(config_exports);
var import_fs = __toESM(require("fs"));
var import_os = __toESM(require("os"));
var import_path = __toESM(require("path"));
var import_util = require("../util");
const defaultTimeout = 3e4;
class FullConfigInternal {
constructor(location, userConfig, configCLIOverrides, metadata) {
this.projects = [];
this.cliArgs = [];
this.cliListOnly = false;
this.preOnlyTestFilters = [];
this.postShardTestFilters = [];
this.defineConfigWasUsed = false;
this.globalSetups = [];
this.globalTeardowns = [];
if (configCLIOverrides.projects && userConfig.projects)
throw new Error(`Cannot use --browser option when configuration file defines projects. Specify browserName in the projects instead.`);
const { resolvedConfigFile, configDir } = location;
const packageJsonPath = (0, import_util.getPackageJsonPath)(configDir);
const packageJsonDir = packageJsonPath ? import_path.default.dirname(packageJsonPath) : process.cwd();
this.configDir = configDir;
this.configCLIOverrides = configCLIOverrides;
const privateConfiguration = userConfig["@playwright/test"];
this.plugins = (privateConfiguration?.plugins || []).map((p) => ({ factory: p }));
this.singleTSConfigPath = pathResolve(configDir, userConfig.tsconfig);
this.captureGitInfo = userConfig.captureGitInfo;
this.failOnFlakyTests = takeFirst(configCLIOverrides.failOnFlakyTests, userConfig.failOnFlakyTests, false);
this.globalSetups = (Array.isArray(userConfig.globalSetup) ? userConfig.globalSetup : [userConfig.globalSetup]).map((s) => resolveScript(s, configDir)).filter((script) => script !== void 0);
this.globalTeardowns = (Array.isArray(userConfig.globalTeardown) ? userConfig.globalTeardown : [userConfig.globalTeardown]).map((s) => resolveScript(s, configDir)).filter((script) => script !== void 0);
userConfig.metadata = userConfig.metadata || {};
this.config = {
configFile: resolvedConfigFile,
rootDir: pathResolve(configDir, userConfig.testDir) || configDir,
forbidOnly: takeFirst(configCLIOverrides.forbidOnly, userConfig.forbidOnly, false),
fullyParallel: takeFirst(configCLIOverrides.fullyParallel, userConfig.fullyParallel, false),
globalSetup: this.globalSetups[0] ?? null,
globalTeardown: this.globalTeardowns[0] ?? null,
globalTimeout: takeFirst(configCLIOverrides.debug ? 0 : void 0, configCLIOverrides.globalTimeout, userConfig.globalTimeout, 0),
grep: takeFirst(userConfig.grep, defaultGrep),
grepInvert: takeFirst(userConfig.grepInvert, null),
maxFailures: takeFirst(configCLIOverrides.debug ? 1 : void 0, configCLIOverrides.maxFailures, userConfig.maxFailures, 0),
metadata: metadata ?? userConfig.metadata,
preserveOutput: takeFirst(userConfig.preserveOutput, "always"),
reporter: takeFirst(configCLIOverrides.reporter, resolveReporters(userConfig.reporter, configDir), [[defaultReporter]]),
reportSlowTests: takeFirst(userConfig.reportSlowTests, {
max: 5,
threshold: 3e5
/* 5 minutes */
}),
quiet: takeFirst(configCLIOverrides.quiet, userConfig.quiet, false),
projects: [],
shard: takeFirst(configCLIOverrides.shard, userConfig.shard, null),
updateSnapshots: takeFirst(configCLIOverrides.updateSnapshots, userConfig.updateSnapshots, "missing"),
updateSourceMethod: takeFirst(configCLIOverrides.updateSourceMethod, userConfig.updateSourceMethod, "patch"),
version: require("../../package.json").version,
workers: resolveWorkers(takeFirst(configCLIOverrides.debug ? 1 : void 0, configCLIOverrides.workers, userConfig.workers, "50%")),
webServer: null
};
for (const key in userConfig) {
if (key.startsWith("@"))
this.config[key] = userConfig[key];
}
this.config[configInternalSymbol] = this;
const webServers = takeFirst(userConfig.webServer, null);
if (Array.isArray(webServers)) {
this.config.webServer = null;
this.webServers = webServers;
} else if (webServers) {
this.config.webServer = webServers;
this.webServers = [webServers];
} else {
this.webServers = [];
}
const projectConfigs = configCLIOverrides.projects || userConfig.projects || [userConfig];
this.projects = projectConfigs.map((p) => new FullProjectInternal(configDir, userConfig, this, p, this.configCLIOverrides, packageJsonDir));
resolveProjectDependencies(this.projects);
this._assignUniqueProjectIds(this.projects);
this.config.projects = this.projects.map((p) => p.project);
}
_assignUniqueProjectIds(projects) {
const usedNames = /* @__PURE__ */ new Set();
for (const p of projects) {
const name = p.project.name || "";
for (let i = 0; i < projects.length; ++i) {
const candidate = name + (i ? i : "");
if (usedNames.has(candidate))
continue;
p.id = candidate;
p.project.__projectId = p.id;
usedNames.add(candidate);
break;
}
}
}
}
class FullProjectInternal {
constructor(configDir, config, fullConfig, projectConfig, configCLIOverrides, packageJsonDir) {
this.id = "";
this.deps = [];
this.fullConfig = fullConfig;
const testDir = takeFirst(pathResolve(configDir, projectConfig.testDir), pathResolve(configDir, config.testDir), fullConfig.configDir);
this.snapshotPathTemplate = takeFirst(projectConfig.snapshotPathTemplate, config.snapshotPathTemplate);
this.project = {
grep: takeFirst(projectConfig.grep, config.grep, defaultGrep),
grepInvert: takeFirst(projectConfig.grepInvert, config.grepInvert, null),
outputDir: takeFirst(configCLIOverrides.outputDir, pathResolve(configDir, projectConfig.outputDir), pathResolve(configDir, config.outputDir), import_path.default.join(packageJsonDir, "test-results")),
// Note: we either apply the cli override for repeatEach or not, depending on whether the
// project is top-level vs dependency. See collectProjectsAndTestFiles in loadUtils.
repeatEach: takeFirst(projectConfig.repeatEach, config.repeatEach, 1),
retries: takeFirst(configCLIOverrides.retries, projectConfig.retries, config.retries, 0),
metadata: takeFirst(projectConfig.metadata, config.metadata, {}),
name: takeFirst(projectConfig.name, config.name, ""),
testDir,
snapshotDir: takeFirst(pathResolve(configDir, projectConfig.snapshotDir), pathResolve(configDir, config.snapshotDir), testDir),
testIgnore: takeFirst(projectConfig.testIgnore, config.testIgnore, []),
testMatch: takeFirst(projectConfig.testMatch, config.testMatch, "**/*.@(spec|test).?(c|m)[jt]s?(x)"),
timeout: takeFirst(configCLIOverrides.debug ? 0 : void 0, configCLIOverrides.timeout, projectConfig.timeout, config.timeout, defaultTimeout),
use: (0, import_util.mergeObjects)(config.use, projectConfig.use, configCLIOverrides.use),
dependencies: projectConfig.dependencies || [],
teardown: projectConfig.teardown
};
this.fullyParallel = takeFirst(configCLIOverrides.fullyParallel, projectConfig.fullyParallel, config.fullyParallel, void 0);
this.expect = takeFirst(projectConfig.expect, config.expect, {});
if (this.expect.toHaveScreenshot?.stylePath) {
const stylePaths = Array.isArray(this.expect.toHaveScreenshot.stylePath) ? this.expect.toHaveScreenshot.stylePath : [this.expect.toHaveScreenshot.stylePath];
this.expect.toHaveScreenshot.stylePath = stylePaths.map((stylePath) => import_path.default.resolve(configDir, stylePath));
}
this.respectGitIgnore = takeFirst(projectConfig.respectGitIgnore, config.respectGitIgnore, !projectConfig.testDir && !config.testDir);
this.ignoreSnapshots = takeFirst(configCLIOverrides.ignoreSnapshots, projectConfig.ignoreSnapshots, config.ignoreSnapshots, false);
this.workers = projectConfig.workers ? resolveWorkers(projectConfig.workers) : void 0;
if (configCLIOverrides.debug && this.workers)
this.workers = 1;
}
}
function takeFirst(...args) {
for (const arg of args) {
if (arg !== void 0)
return arg;
}
return void 0;
}
function pathResolve(baseDir, relative) {
if (!relative)
return void 0;
return import_path.default.resolve(baseDir, relative);
}
function resolveReporters(reporters, rootDir) {
return toReporters(reporters)?.map(([id, arg]) => {
if (builtInReporters.includes(id))
return [id, arg];
return [require.resolve(id, { paths: [rootDir] }), arg];
});
}
function resolveWorkers(workers) {
if (typeof workers === "string") {
if (workers.endsWith("%")) {
const cpus = import_os.default.cpus().length;
return Math.max(1, Math.floor(cpus * (parseInt(workers, 10) / 100)));
}
const parsedWorkers = parseInt(workers, 10);
if (isNaN(parsedWorkers))
throw new Error(`Workers ${workers} must be a number or percentage.`);
return parsedWorkers;
}
return workers;
}
function resolveProjectDependencies(projects) {
const teardownSet = /* @__PURE__ */ new Set();
for (const project of projects) {
for (const dependencyName of project.project.dependencies) {
const dependencies = projects.filter((p) => p.project.name === dependencyName);
if (!dependencies.length)
throw new Error(`Project '${project.project.name}' depends on unknown project '${dependencyName}'`);
if (dependencies.length > 1)
throw new Error(`Project dependencies should have unique names, reading ${dependencyName}`);
project.deps.push(...dependencies);
}
if (project.project.teardown) {
const teardowns = projects.filter((p) => p.project.name === project.project.teardown);
if (!teardowns.length)
throw new Error(`Project '${project.project.name}' has unknown teardown project '${project.project.teardown}'`);
if (teardowns.length > 1)
throw new Error(`Project teardowns should have unique names, reading ${project.project.teardown}`);
const teardown = teardowns[0];
project.teardown = teardown;
teardownSet.add(teardown);
}
}
for (const teardown of teardownSet) {
if (teardown.deps.length)
throw new Error(`Teardown project ${teardown.project.name} must not have dependencies`);
}
for (const project of projects) {
for (const dep of project.deps) {
if (teardownSet.has(dep))
throw new Error(`Project ${project.project.name} must not depend on a teardown project ${dep.project.name}`);
}
}
}
function toReporters(reporters) {
if (!reporters)
return;
if (typeof reporters === "string")
return [[reporters]];
return reporters;
}
const builtInReporters = ["list", "line", "dot", "json", "junit", "null", "github", "html", "blob"];
function resolveScript(id, rootDir) {
if (!id)
return void 0;
const localPath = import_path.default.resolve(rootDir, id);
if (import_fs.default.existsSync(localPath))
return localPath;
return require.resolve(id, { paths: [rootDir] });
}
const defaultGrep = /.*/;
const defaultReporter = process.env.CI ? "dot" : "list";
const configInternalSymbol = Symbol("configInternalSymbol");
function getProjectId(project) {
return project.__projectId;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
FullConfigInternal,
FullProjectInternal,
builtInReporters,
defaultGrep,
defaultReporter,
defaultTimeout,
getProjectId,
takeFirst,
toReporters
});

344
node_modules/playwright/lib/common/configLoader.js generated vendored Normal file
View File

@@ -0,0 +1,344 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var configLoader_exports = {};
__export(configLoader_exports, {
defineConfig: () => defineConfig,
deserializeConfig: () => deserializeConfig,
loadConfig: () => loadConfig,
loadConfigFromFile: () => loadConfigFromFile,
loadEmptyConfigForMergeReports: () => loadEmptyConfigForMergeReports,
resolveConfigLocation: () => resolveConfigLocation
});
module.exports = __toCommonJS(configLoader_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_transform = require("../transform/transform");
var import_util = require("../util");
var import_config = require("./config");
var import_esmLoaderHost = require("./esmLoaderHost");
var import_compilationCache = require("../transform/compilationCache");
const kDefineConfigWasUsed = Symbol("defineConfigWasUsed");
const defineConfig = (...configs) => {
let result = configs[0];
for (let i = 1; i < configs.length; ++i) {
const config = configs[i];
const prevProjects = result.projects;
result = {
...result,
...config,
expect: {
...result.expect,
...config.expect
},
use: {
...result.use,
...config.use
},
build: {
...result.build,
...config.build
},
webServer: [
...Array.isArray(result.webServer) ? result.webServer : result.webServer ? [result.webServer] : [],
...Array.isArray(config.webServer) ? config.webServer : config.webServer ? [config.webServer] : []
]
};
if (!result.projects && !config.projects)
continue;
const projectOverrides = /* @__PURE__ */ new Map();
for (const project of config.projects || [])
projectOverrides.set(project.name, project);
const projects = [];
for (const project of prevProjects || []) {
const projectOverride = projectOverrides.get(project.name);
if (projectOverride) {
projects.push({
...project,
...projectOverride,
use: {
...project.use,
...projectOverride.use
}
});
projectOverrides.delete(project.name);
} else {
projects.push(project);
}
}
projects.push(...projectOverrides.values());
result.projects = projects;
}
result[kDefineConfigWasUsed] = true;
return result;
};
async function deserializeConfig(data) {
if (data.compilationCache)
(0, import_compilationCache.addToCompilationCache)(data.compilationCache);
return await loadConfig(data.location, data.configCLIOverrides, void 0, data.metadata ? JSON.parse(data.metadata) : void 0);
}
async function loadUserConfig(location) {
let object = location.resolvedConfigFile ? await (0, import_transform.requireOrImport)(location.resolvedConfigFile) : {};
if (object && typeof object === "object" && "default" in object)
object = object["default"];
return object;
}
async function loadConfig(location, overrides, ignoreProjectDependencies = false, metadata) {
if (!(0, import_esmLoaderHost.registerESMLoader)()) {
if (location.resolvedConfigFile && (0, import_util.fileIsModule)(location.resolvedConfigFile))
throw (0, import_util.errorWithFile)(location.resolvedConfigFile, `Playwright requires Node.js 18.19 or higher to load esm modules. Please update your version of Node.js.`);
}
(0, import_transform.setSingleTSConfig)(overrides?.tsconfig);
await (0, import_esmLoaderHost.configureESMLoader)();
const userConfig = await loadUserConfig(location);
validateConfig(location.resolvedConfigFile || "<default config>", userConfig);
const fullConfig = new import_config.FullConfigInternal(location, userConfig, overrides || {}, metadata);
fullConfig.defineConfigWasUsed = !!userConfig[kDefineConfigWasUsed];
if (ignoreProjectDependencies) {
for (const project of fullConfig.projects) {
project.deps = [];
project.teardown = void 0;
}
}
const babelPlugins = userConfig["@playwright/test"]?.babelPlugins || [];
const external = userConfig.build?.external || [];
(0, import_transform.setTransformConfig)({ babelPlugins, external });
if (!overrides?.tsconfig)
(0, import_transform.setSingleTSConfig)(fullConfig?.singleTSConfigPath);
await (0, import_esmLoaderHost.configureESMLoaderTransformConfig)();
return fullConfig;
}
function validateConfig(file, config) {
if (typeof config !== "object" || !config)
throw (0, import_util.errorWithFile)(file, `Configuration file must export a single object`);
validateProject(file, config, "config");
if ("forbidOnly" in config && config.forbidOnly !== void 0) {
if (typeof config.forbidOnly !== "boolean")
throw (0, import_util.errorWithFile)(file, `config.forbidOnly must be a boolean`);
}
if ("globalSetup" in config && config.globalSetup !== void 0) {
if (Array.isArray(config.globalSetup)) {
config.globalSetup.forEach((item, index) => {
if (typeof item !== "string")
throw (0, import_util.errorWithFile)(file, `config.globalSetup[${index}] must be a string`);
});
} else if (typeof config.globalSetup !== "string") {
throw (0, import_util.errorWithFile)(file, `config.globalSetup must be a string`);
}
}
if ("globalTeardown" in config && config.globalTeardown !== void 0) {
if (Array.isArray(config.globalTeardown)) {
config.globalTeardown.forEach((item, index) => {
if (typeof item !== "string")
throw (0, import_util.errorWithFile)(file, `config.globalTeardown[${index}] must be a string`);
});
} else if (typeof config.globalTeardown !== "string") {
throw (0, import_util.errorWithFile)(file, `config.globalTeardown must be a string`);
}
}
if ("globalTimeout" in config && config.globalTimeout !== void 0) {
if (typeof config.globalTimeout !== "number" || config.globalTimeout < 0)
throw (0, import_util.errorWithFile)(file, `config.globalTimeout must be a non-negative number`);
}
if ("grep" in config && config.grep !== void 0) {
if (Array.isArray(config.grep)) {
config.grep.forEach((item, index) => {
if (!(0, import_utils.isRegExp)(item))
throw (0, import_util.errorWithFile)(file, `config.grep[${index}] must be a RegExp`);
});
} else if (!(0, import_utils.isRegExp)(config.grep)) {
throw (0, import_util.errorWithFile)(file, `config.grep must be a RegExp`);
}
}
if ("grepInvert" in config && config.grepInvert !== void 0) {
if (Array.isArray(config.grepInvert)) {
config.grepInvert.forEach((item, index) => {
if (!(0, import_utils.isRegExp)(item))
throw (0, import_util.errorWithFile)(file, `config.grepInvert[${index}] must be a RegExp`);
});
} else if (!(0, import_utils.isRegExp)(config.grepInvert)) {
throw (0, import_util.errorWithFile)(file, `config.grepInvert must be a RegExp`);
}
}
if ("maxFailures" in config && config.maxFailures !== void 0) {
if (typeof config.maxFailures !== "number" || config.maxFailures < 0)
throw (0, import_util.errorWithFile)(file, `config.maxFailures must be a non-negative number`);
}
if ("preserveOutput" in config && config.preserveOutput !== void 0) {
if (typeof config.preserveOutput !== "string" || !["always", "never", "failures-only"].includes(config.preserveOutput))
throw (0, import_util.errorWithFile)(file, `config.preserveOutput must be one of "always", "never" or "failures-only"`);
}
if ("projects" in config && config.projects !== void 0) {
if (!Array.isArray(config.projects))
throw (0, import_util.errorWithFile)(file, `config.projects must be an array`);
config.projects.forEach((project, index) => {
validateProject(file, project, `config.projects[${index}]`);
});
}
if ("quiet" in config && config.quiet !== void 0) {
if (typeof config.quiet !== "boolean")
throw (0, import_util.errorWithFile)(file, `config.quiet must be a boolean`);
}
if ("reporter" in config && config.reporter !== void 0) {
if (Array.isArray(config.reporter)) {
config.reporter.forEach((item, index) => {
if (!Array.isArray(item) || item.length <= 0 || item.length > 2 || typeof item[0] !== "string")
throw (0, import_util.errorWithFile)(file, `config.reporter[${index}] must be a tuple [name, optionalArgument]`);
});
} else if (typeof config.reporter !== "string") {
throw (0, import_util.errorWithFile)(file, `config.reporter must be a string`);
}
}
if ("reportSlowTests" in config && config.reportSlowTests !== void 0 && config.reportSlowTests !== null) {
if (!config.reportSlowTests || typeof config.reportSlowTests !== "object")
throw (0, import_util.errorWithFile)(file, `config.reportSlowTests must be an object`);
if (!("max" in config.reportSlowTests) || typeof config.reportSlowTests.max !== "number" || config.reportSlowTests.max < 0)
throw (0, import_util.errorWithFile)(file, `config.reportSlowTests.max must be a non-negative number`);
if (!("threshold" in config.reportSlowTests) || typeof config.reportSlowTests.threshold !== "number" || config.reportSlowTests.threshold < 0)
throw (0, import_util.errorWithFile)(file, `config.reportSlowTests.threshold must be a non-negative number`);
}
if ("shard" in config && config.shard !== void 0 && config.shard !== null) {
if (!config.shard || typeof config.shard !== "object")
throw (0, import_util.errorWithFile)(file, `config.shard must be an object`);
if (!("total" in config.shard) || typeof config.shard.total !== "number" || config.shard.total < 1)
throw (0, import_util.errorWithFile)(file, `config.shard.total must be a positive number`);
if (!("current" in config.shard) || typeof config.shard.current !== "number" || config.shard.current < 1 || config.shard.current > config.shard.total)
throw (0, import_util.errorWithFile)(file, `config.shard.current must be a positive number, not greater than config.shard.total`);
}
if ("updateSnapshots" in config && config.updateSnapshots !== void 0) {
if (typeof config.updateSnapshots !== "string" || !["all", "changed", "missing", "none"].includes(config.updateSnapshots))
throw (0, import_util.errorWithFile)(file, `config.updateSnapshots must be one of "all", "changed", "missing" or "none"`);
}
if ("tsconfig" in config && config.tsconfig !== void 0) {
if (typeof config.tsconfig !== "string")
throw (0, import_util.errorWithFile)(file, `config.tsconfig must be a string`);
if (!import_fs.default.existsSync(import_path.default.resolve(file, "..", config.tsconfig)))
throw (0, import_util.errorWithFile)(file, `config.tsconfig does not exist`);
}
}
function validateProject(file, project, title) {
if (typeof project !== "object" || !project)
throw (0, import_util.errorWithFile)(file, `${title} must be an object`);
if ("name" in project && project.name !== void 0) {
if (typeof project.name !== "string")
throw (0, import_util.errorWithFile)(file, `${title}.name must be a string`);
}
if ("outputDir" in project && project.outputDir !== void 0) {
if (typeof project.outputDir !== "string")
throw (0, import_util.errorWithFile)(file, `${title}.outputDir must be a string`);
}
if ("repeatEach" in project && project.repeatEach !== void 0) {
if (typeof project.repeatEach !== "number" || project.repeatEach < 0)
throw (0, import_util.errorWithFile)(file, `${title}.repeatEach must be a non-negative number`);
}
if ("retries" in project && project.retries !== void 0) {
if (typeof project.retries !== "number" || project.retries < 0)
throw (0, import_util.errorWithFile)(file, `${title}.retries must be a non-negative number`);
}
if ("testDir" in project && project.testDir !== void 0) {
if (typeof project.testDir !== "string")
throw (0, import_util.errorWithFile)(file, `${title}.testDir must be a string`);
}
for (const prop of ["testIgnore", "testMatch"]) {
if (prop in project && project[prop] !== void 0) {
const value = project[prop];
if (Array.isArray(value)) {
value.forEach((item, index) => {
if (typeof item !== "string" && !(0, import_utils.isRegExp)(item))
throw (0, import_util.errorWithFile)(file, `${title}.${prop}[${index}] must be a string or a RegExp`);
});
} else if (typeof value !== "string" && !(0, import_utils.isRegExp)(value)) {
throw (0, import_util.errorWithFile)(file, `${title}.${prop} must be a string or a RegExp`);
}
}
}
if ("timeout" in project && project.timeout !== void 0) {
if (typeof project.timeout !== "number" || project.timeout < 0)
throw (0, import_util.errorWithFile)(file, `${title}.timeout must be a non-negative number`);
}
if ("use" in project && project.use !== void 0) {
if (!project.use || typeof project.use !== "object")
throw (0, import_util.errorWithFile)(file, `${title}.use must be an object`);
}
if ("ignoreSnapshots" in project && project.ignoreSnapshots !== void 0) {
if (typeof project.ignoreSnapshots !== "boolean")
throw (0, import_util.errorWithFile)(file, `${title}.ignoreSnapshots must be a boolean`);
}
if ("workers" in project && project.workers !== void 0) {
if (typeof project.workers === "number" && project.workers <= 0)
throw (0, import_util.errorWithFile)(file, `${title}.workers must be a positive number`);
else if (typeof project.workers === "string" && !project.workers.endsWith("%"))
throw (0, import_util.errorWithFile)(file, `${title}.workers must be a number or percentage`);
}
}
function resolveConfigLocation(configFile) {
const configFileOrDirectory = configFile ? import_path.default.resolve(process.cwd(), configFile) : process.cwd();
const resolvedConfigFile = resolveConfigFile(configFileOrDirectory);
return {
resolvedConfigFile,
configDir: resolvedConfigFile ? import_path.default.dirname(resolvedConfigFile) : configFileOrDirectory
};
}
function resolveConfigFile(configFileOrDirectory) {
const resolveConfig = (configFile) => {
if (import_fs.default.existsSync(configFile))
return configFile;
};
const resolveConfigFileFromDirectory = (directory) => {
for (const ext of [".ts", ".js", ".mts", ".mjs", ".cts", ".cjs"]) {
const configFile = resolveConfig(import_path.default.resolve(directory, "playwright.config" + ext));
if (configFile)
return configFile;
}
};
if (!import_fs.default.existsSync(configFileOrDirectory))
throw new Error(`${configFileOrDirectory} does not exist`);
if (import_fs.default.statSync(configFileOrDirectory).isDirectory()) {
const configFile = resolveConfigFileFromDirectory(configFileOrDirectory);
if (configFile)
return configFile;
return void 0;
}
return configFileOrDirectory;
}
async function loadConfigFromFile(configFile, overrides, ignoreDeps) {
return await loadConfig(resolveConfigLocation(configFile), overrides, ignoreDeps);
}
async function loadEmptyConfigForMergeReports() {
return await loadConfig({ configDir: process.cwd() });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
defineConfig,
deserializeConfig,
loadConfig,
loadConfigFromFile,
loadEmptyConfigForMergeReports,
resolveConfigLocation
});

102
node_modules/playwright/lib/common/esmLoaderHost.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var esmLoaderHost_exports = {};
__export(esmLoaderHost_exports, {
configureESMLoader: () => configureESMLoader,
configureESMLoaderTransformConfig: () => configureESMLoaderTransformConfig,
incorporateCompilationCache: () => incorporateCompilationCache,
registerESMLoader: () => registerESMLoader,
startCollectingFileDeps: () => startCollectingFileDeps,
stopCollectingFileDeps: () => stopCollectingFileDeps
});
module.exports = __toCommonJS(esmLoaderHost_exports);
var import_url = __toESM(require("url"));
var import_compilationCache = require("../transform/compilationCache");
var import_portTransport = require("../transform/portTransport");
var import_transform = require("../transform/transform");
let loaderChannel;
function registerESMLoader() {
if (process.env.PW_DISABLE_TS_ESM)
return true;
if (loaderChannel)
return true;
const register = require("node:module").register;
if (!register)
return false;
const { port1, port2 } = new MessageChannel();
register(import_url.default.pathToFileURL(require.resolve("../transform/esmLoader")), {
data: { port: port2 },
transferList: [port2]
});
loaderChannel = createPortTransport(port1);
return true;
}
function createPortTransport(port) {
return new import_portTransport.PortTransport(port, async (method, params) => {
if (method === "pushToCompilationCache")
(0, import_compilationCache.addToCompilationCache)(params.cache);
});
}
async function startCollectingFileDeps() {
if (!loaderChannel)
return;
await loaderChannel.send("startCollectingFileDeps", {});
}
async function stopCollectingFileDeps(file) {
if (!loaderChannel)
return;
await loaderChannel.send("stopCollectingFileDeps", { file });
}
async function incorporateCompilationCache() {
if (!loaderChannel)
return;
const result = await loaderChannel.send("getCompilationCache", {});
(0, import_compilationCache.addToCompilationCache)(result.cache);
}
async function configureESMLoader() {
if (!loaderChannel)
return;
await loaderChannel.send("setSingleTSConfig", { tsconfig: (0, import_transform.singleTSConfig)() });
await loaderChannel.send("addToCompilationCache", { cache: (0, import_compilationCache.serializeCompilationCache)() });
}
async function configureESMLoaderTransformConfig() {
if (!loaderChannel)
return;
await loaderChannel.send("setSingleTSConfig", { tsconfig: (0, import_transform.singleTSConfig)() });
await loaderChannel.send("setTransformConfig", { config: (0, import_transform.transformConfig)() });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
configureESMLoader,
configureESMLoaderTransformConfig,
incorporateCompilationCache,
registerESMLoader,
startCollectingFileDeps,
stopCollectingFileDeps
});

49
node_modules/playwright/lib/common/expectBundle.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var expectBundle_exports = {};
__export(expectBundle_exports, {
EXPECTED_COLOR: () => EXPECTED_COLOR,
INVERTED_COLOR: () => INVERTED_COLOR,
RECEIVED_COLOR: () => RECEIVED_COLOR,
asymmetricMatchers: () => asymmetricMatchers,
expect: () => expect,
matcherUtils: () => matcherUtils,
mock: () => mock,
printReceived: () => printReceived
});
module.exports = __toCommonJS(expectBundle_exports);
const expect = require("./expectBundleImpl").expect;
const mock = require("./expectBundleImpl").mock;
const asymmetricMatchers = require("./expectBundleImpl").asymmetricMatchers;
const matcherUtils = require("./expectBundleImpl").matcherUtils;
const EXPECTED_COLOR = require("./expectBundleImpl").EXPECTED_COLOR;
const INVERTED_COLOR = require("./expectBundleImpl").INVERTED_COLOR;
const RECEIVED_COLOR = require("./expectBundleImpl").RECEIVED_COLOR;
const printReceived = require("./expectBundleImpl").printReceived;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
EXPECTED_COLOR,
INVERTED_COLOR,
RECEIVED_COLOR,
asymmetricMatchers,
expect,
matcherUtils,
mock,
printReceived
});

389
node_modules/playwright/lib/common/expectBundleImpl.js generated vendored Normal file

File diff suppressed because one or more lines are too long

302
node_modules/playwright/lib/common/fixtures.js generated vendored Normal file
View File

@@ -0,0 +1,302 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var fixtures_exports = {};
__export(fixtures_exports, {
FixturePool: () => FixturePool,
fixtureParameterNames: () => fixtureParameterNames,
formatPotentiallyInternalLocation: () => formatPotentiallyInternalLocation,
inheritFixtureNames: () => inheritFixtureNames
});
module.exports = __toCommonJS(fixtures_exports);
var import_crypto = __toESM(require("crypto"));
var import_util = require("../util");
const kScopeOrder = ["test", "worker"];
function isFixtureTuple(value) {
return Array.isArray(value) && typeof value[1] === "object";
}
function isFixtureOption(value) {
return isFixtureTuple(value) && !!value[1].option;
}
class FixturePool {
constructor(fixturesList, onLoadError, parentPool, disallowWorkerFixtures, optionOverrides) {
this._registrations = new Map(parentPool ? parentPool._registrations : []);
this._onLoadError = onLoadError;
const allOverrides = optionOverrides?.overrides ?? {};
const overrideKeys = new Set(Object.keys(allOverrides));
for (const list of fixturesList) {
this._appendFixtureList(list, !!disallowWorkerFixtures, false);
const selectedOverrides = {};
for (const [key, value] of Object.entries(list.fixtures)) {
if (isFixtureOption(value) && overrideKeys.has(key))
selectedOverrides[key] = [allOverrides[key], value[1]];
}
if (Object.entries(selectedOverrides).length)
this._appendFixtureList({ fixtures: selectedOverrides, location: optionOverrides.location }, !!disallowWorkerFixtures, true);
}
this.digest = this.validate();
}
_appendFixtureList(list, disallowWorkerFixtures, isOptionsOverride) {
const { fixtures, location } = list;
for (const entry of Object.entries(fixtures)) {
const name = entry[0];
let value = entry[1];
let options;
if (isFixtureTuple(value)) {
options = {
auto: value[1].auto ?? false,
scope: value[1].scope || "test",
option: !!value[1].option,
timeout: value[1].timeout,
customTitle: value[1].title,
box: value[1].box
};
value = value[0];
}
let fn = value;
const previous = this._registrations.get(name);
if (previous && options) {
if (previous.scope !== options.scope) {
this._addLoadError(`Fixture "${name}" has already been registered as a { scope: '${previous.scope}' } fixture defined in ${(0, import_util.formatLocation)(previous.location)}.`, location);
continue;
}
if (previous.auto !== options.auto) {
this._addLoadError(`Fixture "${name}" has already been registered as a { auto: '${previous.scope}' } fixture defined in ${(0, import_util.formatLocation)(previous.location)}.`, location);
continue;
}
} else if (previous) {
options = { auto: previous.auto, scope: previous.scope, option: previous.option, timeout: previous.timeout, customTitle: previous.customTitle };
} else if (!options) {
options = { auto: false, scope: "test", option: false, timeout: void 0 };
}
if (!kScopeOrder.includes(options.scope)) {
this._addLoadError(`Fixture "${name}" has unknown { scope: '${options.scope}' }.`, location);
continue;
}
if (options.scope === "worker" && disallowWorkerFixtures) {
this._addLoadError(`Cannot use({ ${name} }) in a describe group, because it forces a new worker.
Make it top-level in the test file or put in the configuration file.`, location);
continue;
}
if (fn === void 0 && options.option && previous) {
let original = previous;
while (!original.optionOverride && original.super)
original = original.super;
fn = original.fn;
}
const deps = fixtureParameterNames(fn, location, (e) => this._onLoadError(e));
const registration = { id: "", name, location, scope: options.scope, fn, auto: options.auto, option: options.option, timeout: options.timeout, customTitle: options.customTitle, box: options.box, deps, super: previous, optionOverride: isOptionsOverride };
registrationId(registration);
this._registrations.set(name, registration);
}
}
validate() {
const markers = /* @__PURE__ */ new Map();
const stack = [];
let hasDependencyErrors = false;
const addDependencyError = (message, location) => {
hasDependencyErrors = true;
this._addLoadError(message, location);
};
const visit = (registration, boxedOnly) => {
markers.set(registration, "visiting");
stack.push(registration);
for (const name of registration.deps) {
const dep = this.resolve(name, registration);
if (!dep) {
if (name === registration.name)
addDependencyError(`Fixture "${registration.name}" references itself, but does not have a base implementation.`, registration.location);
else
addDependencyError(`Fixture "${registration.name}" has unknown parameter "${name}".`, registration.location);
continue;
}
if (kScopeOrder.indexOf(registration.scope) > kScopeOrder.indexOf(dep.scope)) {
addDependencyError(`${registration.scope} fixture "${registration.name}" cannot depend on a ${dep.scope} fixture "${name}" defined in ${formatPotentiallyInternalLocation(dep.location)}.`, registration.location);
continue;
}
if (!markers.has(dep)) {
visit(dep, boxedOnly);
} else if (markers.get(dep) === "visiting") {
const index = stack.indexOf(dep);
const allRegs = stack.slice(index, stack.length);
const filteredRegs = allRegs.filter((r) => !r.box);
const regs = boxedOnly ? filteredRegs : allRegs;
const names2 = regs.map((r) => `"${r.name}"`);
addDependencyError(`Fixtures ${names2.join(" -> ")} -> "${dep.name}" form a dependency cycle: ${regs.map((r) => formatPotentiallyInternalLocation(r.location)).join(" -> ")} -> ${formatPotentiallyInternalLocation(dep.location)}`, dep.location);
continue;
}
}
markers.set(registration, "visited");
stack.pop();
};
const names = Array.from(this._registrations.keys()).sort();
for (const name of names) {
const registration = this._registrations.get(name);
if (!registration.box)
visit(registration, true);
}
if (!hasDependencyErrors) {
for (const name of names) {
const registration = this._registrations.get(name);
if (registration.box)
visit(registration, false);
}
}
const hash = import_crypto.default.createHash("sha1");
for (const name of names) {
const registration = this._registrations.get(name);
if (registration.scope === "worker")
hash.update(registration.id + ";");
}
return hash.digest("hex");
}
validateFunction(fn, prefix, location) {
for (const name of fixtureParameterNames(fn, location, (e) => this._onLoadError(e))) {
const registration = this._registrations.get(name);
if (!registration)
this._addLoadError(`${prefix} has unknown parameter "${name}".`, location);
}
}
resolve(name, forFixture) {
if (name === forFixture?.name)
return forFixture.super;
return this._registrations.get(name);
}
autoFixtures() {
return [...this._registrations.values()].filter((r) => r.auto !== false);
}
_addLoadError(message, location) {
this._onLoadError({ message, location });
}
}
const signatureSymbol = Symbol("signature");
function formatPotentiallyInternalLocation(location) {
const isUserFixture = location && (0, import_util.filterStackFile)(location.file);
return isUserFixture ? (0, import_util.formatLocation)(location) : "<builtin>";
}
function fixtureParameterNames(fn, location, onError) {
if (typeof fn !== "function")
return [];
if (!fn[signatureSymbol])
fn[signatureSymbol] = innerFixtureParameterNames(fn, location, onError);
return fn[signatureSymbol];
}
function inheritFixtureNames(from, to) {
to[signatureSymbol] = from[signatureSymbol];
}
function innerFixtureParameterNames(fn, location, onError) {
const text = filterOutComments(fn.toString());
const match = text.match(/(?:async)?(?:\s+function)?[^(]*\(([^)]*)/);
if (!match)
return [];
const trimmedParams = match[1].trim();
if (!trimmedParams)
return [];
const [firstParam] = splitByComma(trimmedParams);
if (firstParam[0] !== "{" || firstParam[firstParam.length - 1] !== "}") {
onError({ message: "First argument must use the object destructuring pattern: " + firstParam, location });
return [];
}
const props = splitByComma(firstParam.substring(1, firstParam.length - 1)).map((prop) => {
const colon = prop.indexOf(":");
return colon === -1 ? prop.trim() : prop.substring(0, colon).trim();
});
const restProperty = props.find((prop) => prop.startsWith("..."));
if (restProperty) {
onError({ message: `Rest property "${restProperty}" is not supported. List all used fixtures explicitly, separated by comma.`, location });
return [];
}
return props;
}
function filterOutComments(s) {
const result = [];
let commentState = "none";
for (let i = 0; i < s.length; ++i) {
if (commentState === "singleline") {
if (s[i] === "\n")
commentState = "none";
} else if (commentState === "multiline") {
if (s[i - 1] === "*" && s[i] === "/")
commentState = "none";
} else if (commentState === "none") {
if (s[i] === "/" && s[i + 1] === "/") {
commentState = "singleline";
} else if (s[i] === "/" && s[i + 1] === "*") {
commentState = "multiline";
i += 2;
} else {
result.push(s[i]);
}
}
}
return result.join("");
}
function splitByComma(s) {
const result = [];
const stack = [];
let start = 0;
for (let i = 0; i < s.length; i++) {
if (s[i] === "{" || s[i] === "[") {
stack.push(s[i] === "{" ? "}" : "]");
} else if (s[i] === stack[stack.length - 1]) {
stack.pop();
} else if (!stack.length && s[i] === ",") {
const token = s.substring(start, i).trim();
if (token)
result.push(token);
start = i + 1;
}
}
const lastToken = s.substring(start).trim();
if (lastToken)
result.push(lastToken);
return result;
}
const registrationIdMap = /* @__PURE__ */ new Map();
let lastId = 0;
function registrationId(registration) {
if (registration.id)
return registration.id;
const key = registration.name + "@@@" + (registration.super ? registrationId(registration.super) : "");
let map = registrationIdMap.get(key);
if (!map) {
map = /* @__PURE__ */ new Map();
registrationIdMap.set(key, map);
}
if (!map.has(registration.fn))
map.set(registration.fn, String(lastId++));
registration.id = map.get(registration.fn);
return registration.id;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
FixturePool,
fixtureParameterNames,
formatPotentiallyInternalLocation,
inheritFixtureNames
});

58
node_modules/playwright/lib/common/globals.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var globals_exports = {};
__export(globals_exports, {
currentTestInfo: () => currentTestInfo,
currentlyLoadingFileSuite: () => currentlyLoadingFileSuite,
isWorkerProcess: () => isWorkerProcess,
setCurrentTestInfo: () => setCurrentTestInfo,
setCurrentlyLoadingFileSuite: () => setCurrentlyLoadingFileSuite,
setIsWorkerProcess: () => setIsWorkerProcess
});
module.exports = __toCommonJS(globals_exports);
let currentTestInfoValue = null;
function setCurrentTestInfo(testInfo) {
currentTestInfoValue = testInfo;
}
function currentTestInfo() {
return currentTestInfoValue;
}
let currentFileSuite;
function setCurrentlyLoadingFileSuite(suite) {
currentFileSuite = suite;
}
function currentlyLoadingFileSuite() {
return currentFileSuite;
}
let _isWorkerProcess = false;
function setIsWorkerProcess() {
_isWorkerProcess = true;
}
function isWorkerProcess() {
return _isWorkerProcess;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
currentTestInfo,
currentlyLoadingFileSuite,
isWorkerProcess,
setCurrentTestInfo,
setCurrentlyLoadingFileSuite,
setIsWorkerProcess
});

60
node_modules/playwright/lib/common/ipc.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var ipc_exports = {};
__export(ipc_exports, {
serializeConfig: () => serializeConfig,
stdioChunkToParams: () => stdioChunkToParams
});
module.exports = __toCommonJS(ipc_exports);
var import_util = __toESM(require("util"));
var import_compilationCache = require("../transform/compilationCache");
function serializeConfig(config, passCompilationCache) {
const result = {
location: { configDir: config.configDir, resolvedConfigFile: config.config.configFile },
configCLIOverrides: config.configCLIOverrides,
compilationCache: passCompilationCache ? (0, import_compilationCache.serializeCompilationCache)() : void 0
};
try {
result.metadata = JSON.stringify(config.config.metadata);
} catch (error) {
}
return result;
}
function stdioChunkToParams(chunk) {
if (chunk instanceof Uint8Array)
return { buffer: Buffer.from(chunk).toString("base64") };
if (typeof chunk !== "string")
return { text: import_util.default.inspect(chunk) };
return { text: chunk };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
serializeConfig,
stdioChunkToParams
});

85
node_modules/playwright/lib/common/poolBuilder.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var poolBuilder_exports = {};
__export(poolBuilder_exports, {
PoolBuilder: () => PoolBuilder
});
module.exports = __toCommonJS(poolBuilder_exports);
var import_fixtures = require("./fixtures");
var import_util = require("../util");
class PoolBuilder {
constructor(type, project) {
this._testTypePools = /* @__PURE__ */ new Map();
this._type = type;
this._project = project;
}
static createForLoader() {
return new PoolBuilder("loader");
}
static createForWorker(project) {
return new PoolBuilder("worker", project);
}
buildPools(suite, testErrors) {
suite.forEachTest((test) => {
const pool = this._buildPoolForTest(test, testErrors);
if (this._type === "loader")
test._poolDigest = pool.digest;
if (this._type === "worker")
test._pool = pool;
});
}
_buildPoolForTest(test, testErrors) {
let pool = this._buildTestTypePool(test._testType, testErrors);
const parents = [];
for (let parent = test.parent; parent; parent = parent.parent)
parents.push(parent);
parents.reverse();
for (const parent of parents) {
if (parent._use.length)
pool = new import_fixtures.FixturePool(parent._use, (e) => this._handleLoadError(e, testErrors), pool, parent._type === "describe");
for (const hook of parent._hooks)
pool.validateFunction(hook.fn, hook.type + " hook", hook.location);
for (const modifier of parent._modifiers)
pool.validateFunction(modifier.fn, modifier.type + " modifier", modifier.location);
}
pool.validateFunction(test.fn, "Test", test.location);
return pool;
}
_buildTestTypePool(testType, testErrors) {
if (!this._testTypePools.has(testType)) {
const optionOverrides = {
overrides: this._project?.project?.use ?? {},
location: { file: `project#${this._project?.id}`, line: 1, column: 1 }
};
const pool = new import_fixtures.FixturePool(testType.fixtures, (e) => this._handleLoadError(e, testErrors), void 0, void 0, optionOverrides);
this._testTypePools.set(testType, pool);
}
return this._testTypePools.get(testType);
}
_handleLoadError(e, testErrors) {
if (testErrors)
testErrors.push(e);
else
throw new Error(`${(0, import_util.formatLocation)(e.location)}: ${e.message}`);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
PoolBuilder
});

104
node_modules/playwright/lib/common/process.js generated vendored Normal file
View File

@@ -0,0 +1,104 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var process_exports = {};
__export(process_exports, {
ProcessRunner: () => ProcessRunner
});
module.exports = __toCommonJS(process_exports);
var import_utils = require("playwright-core/lib/utils");
var import_util = require("../util");
class ProcessRunner {
async gracefullyClose() {
}
dispatchEvent(method, params) {
const response = { method, params };
sendMessageToParent({ method: "__dispatch__", params: response });
}
}
let gracefullyCloseCalled = false;
let forceExitInitiated = false;
sendMessageToParent({ method: "ready" });
process.on("disconnect", () => gracefullyCloseAndExit(true));
process.on("SIGINT", () => {
});
process.on("SIGTERM", () => {
});
let processRunner;
let processName;
const startingEnv = { ...process.env };
process.on("message", async (message) => {
if (message.method === "__init__") {
const { processParams, runnerParams, runnerScript } = message.params;
void (0, import_utils.startProfiling)();
(0, import_utils.setTimeOrigin)(processParams.timeOrigin);
const { create } = require(runnerScript);
processRunner = create(runnerParams);
processName = processParams.processName;
return;
}
if (message.method === "__stop__") {
const keys = /* @__PURE__ */ new Set([...Object.keys(process.env), ...Object.keys(startingEnv)]);
const producedEnv = [...keys].filter((key) => startingEnv[key] !== process.env[key]).map((key) => [key, process.env[key] ?? null]);
sendMessageToParent({ method: "__env_produced__", params: producedEnv });
await gracefullyCloseAndExit(false);
return;
}
if (message.method === "__dispatch__") {
const { id, method, params } = message.params;
try {
const result = await processRunner[method](params);
const response = { id, result };
sendMessageToParent({ method: "__dispatch__", params: response });
} catch (e) {
const response = { id, error: (0, import_util.serializeError)(e) };
sendMessageToParent({ method: "__dispatch__", params: response });
}
}
});
const kForceExitTimeout = +(process.env.PWTEST_FORCE_EXIT_TIMEOUT || 3e4);
async function gracefullyCloseAndExit(forceExit) {
if (forceExit && !forceExitInitiated) {
forceExitInitiated = true;
setTimeout(() => process.exit(0), kForceExitTimeout);
}
if (!gracefullyCloseCalled) {
gracefullyCloseCalled = true;
await processRunner?.gracefullyClose().catch(() => {
});
if (processName)
await (0, import_utils.stopProfiling)(processName).catch(() => {
});
process.exit(0);
}
}
function sendMessageToParent(message) {
try {
process.send(message);
} catch (e) {
try {
JSON.stringify(message);
} catch {
throw e;
}
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ProcessRunner
});

140
node_modules/playwright/lib/common/suiteUtils.js generated vendored Normal file
View File

@@ -0,0 +1,140 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var suiteUtils_exports = {};
__export(suiteUtils_exports, {
applyRepeatEachIndex: () => applyRepeatEachIndex,
bindFileSuiteToProject: () => bindFileSuiteToProject,
filterByFocusedLine: () => filterByFocusedLine,
filterOnly: () => filterOnly,
filterSuite: () => filterSuite,
filterTestsRemoveEmptySuites: () => filterTestsRemoveEmptySuites
});
module.exports = __toCommonJS(suiteUtils_exports);
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_util = require("../util");
function filterSuite(suite, suiteFilter, testFilter) {
for (const child of suite.suites) {
if (!suiteFilter(child))
filterSuite(child, suiteFilter, testFilter);
}
const filteredTests = suite.tests.filter(testFilter);
const entries = /* @__PURE__ */ new Set([...suite.suites, ...filteredTests]);
suite._entries = suite._entries.filter((e) => entries.has(e));
}
function filterTestsRemoveEmptySuites(suite, filter) {
const filteredSuites = suite.suites.filter((child) => filterTestsRemoveEmptySuites(child, filter));
const filteredTests = suite.tests.filter(filter);
const entries = /* @__PURE__ */ new Set([...filteredSuites, ...filteredTests]);
suite._entries = suite._entries.filter((e) => entries.has(e));
return !!suite._entries.length;
}
function bindFileSuiteToProject(project, suite) {
const relativeFile = import_path.default.relative(project.project.testDir, suite.location.file);
const fileId = (0, import_utils.calculateSha1)((0, import_utils.toPosixPath)(relativeFile)).slice(0, 20);
const result = suite._deepClone();
result._fileId = fileId;
result.forEachTest((test, suite2) => {
suite2._fileId = fileId;
const [file, ...titles] = test.titlePath();
const testIdExpression = `[project=${project.id}]${(0, import_utils.toPosixPath)(file)}${titles.join("")}`;
const testId = fileId + "-" + (0, import_utils.calculateSha1)(testIdExpression).slice(0, 20);
test.id = testId;
test._projectId = project.id;
let inheritedRetries;
let inheritedTimeout;
for (let parentSuite = suite2; parentSuite; parentSuite = parentSuite.parent) {
if (parentSuite._staticAnnotations.length)
test.annotations.unshift(...parentSuite._staticAnnotations);
if (inheritedRetries === void 0 && parentSuite._retries !== void 0)
inheritedRetries = parentSuite._retries;
if (inheritedTimeout === void 0 && parentSuite._timeout !== void 0)
inheritedTimeout = parentSuite._timeout;
}
test.retries = inheritedRetries ?? project.project.retries;
test.timeout = inheritedTimeout ?? project.project.timeout;
if (test.annotations.some((a) => a.type === "skip" || a.type === "fixme"))
test.expectedStatus = "skipped";
if (test._poolDigest)
test._workerHash = `${project.id}-${test._poolDigest}-0`;
});
return result;
}
function applyRepeatEachIndex(project, fileSuite, repeatEachIndex) {
fileSuite.forEachTest((test, suite) => {
if (repeatEachIndex) {
const [file, ...titles] = test.titlePath();
const testIdExpression = `[project=${project.id}]${(0, import_utils.toPosixPath)(file)}${titles.join("")} (repeat:${repeatEachIndex})`;
const testId = suite._fileId + "-" + (0, import_utils.calculateSha1)(testIdExpression).slice(0, 20);
test.id = testId;
test.repeatEachIndex = repeatEachIndex;
if (test._poolDigest)
test._workerHash = `${project.id}-${test._poolDigest}-${repeatEachIndex}`;
}
});
}
function filterOnly(suite) {
if (!suite._getOnlyItems().length)
return;
const suiteFilter = (suite2) => suite2._only;
const testFilter = (test) => test._only;
return filterSuiteWithOnlySemantics(suite, suiteFilter, testFilter);
}
function filterSuiteWithOnlySemantics(suite, suiteFilter, testFilter) {
const onlySuites = suite.suites.filter((child) => filterSuiteWithOnlySemantics(child, suiteFilter, testFilter) || suiteFilter(child));
const onlyTests = suite.tests.filter(testFilter);
const onlyEntries = /* @__PURE__ */ new Set([...onlySuites, ...onlyTests]);
if (onlyEntries.size) {
suite._entries = suite._entries.filter((e) => onlyEntries.has(e));
return true;
}
return false;
}
function filterByFocusedLine(suite, focusedTestFileLines) {
if (!focusedTestFileLines.length)
return;
const matchers = focusedTestFileLines.map(createFileMatcherFromFilter);
const testFileLineMatches = (testFileName, testLine, testColumn) => matchers.some((m) => m(testFileName, testLine, testColumn));
const suiteFilter = (suite2) => !!suite2.location && testFileLineMatches(suite2.location.file, suite2.location.line, suite2.location.column);
const testFilter = (test) => testFileLineMatches(test.location.file, test.location.line, test.location.column);
return filterSuite(suite, suiteFilter, testFilter);
}
function createFileMatcherFromFilter(filter) {
const fileMatcher = (0, import_util.createFileMatcher)(filter.re || filter.exact || "");
return (testFileName, testLine, testColumn) => fileMatcher(testFileName) && (filter.line === testLine || filter.line === null) && (filter.column === testColumn || filter.column === null);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
applyRepeatEachIndex,
bindFileSuiteToProject,
filterByFocusedLine,
filterOnly,
filterSuite,
filterTestsRemoveEmptySuites
});

321
node_modules/playwright/lib/common/test.js generated vendored Normal file
View File

@@ -0,0 +1,321 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var test_exports = {};
__export(test_exports, {
Suite: () => Suite,
TestCase: () => TestCase
});
module.exports = __toCommonJS(test_exports);
var import_testType = require("./testType");
var import_teleReceiver = require("../isomorphic/teleReceiver");
class Base {
constructor(title) {
this._only = false;
this._requireFile = "";
this.title = title;
}
}
class Suite extends Base {
constructor(title, type) {
super(title);
this._use = [];
this._entries = [];
this._hooks = [];
// Annotations known statically before running the test, e.g. `test.describe.skip()` or `test.describe({ annotation }, body)`.
this._staticAnnotations = [];
// Explicitly declared tags that are not a part of the title.
this._tags = [];
this._modifiers = [];
this._parallelMode = "none";
this._type = type;
}
get type() {
return this._type;
}
entries() {
return this._entries;
}
get suites() {
return this._entries.filter((entry) => entry instanceof Suite);
}
get tests() {
return this._entries.filter((entry) => entry instanceof TestCase);
}
_addTest(test) {
test.parent = this;
this._entries.push(test);
}
_addSuite(suite) {
suite.parent = this;
this._entries.push(suite);
}
_prependSuite(suite) {
suite.parent = this;
this._entries.unshift(suite);
}
allTests() {
const result = [];
const visit = (suite) => {
for (const entry of suite._entries) {
if (entry instanceof Suite)
visit(entry);
else
result.push(entry);
}
};
visit(this);
return result;
}
_hasTests() {
let result = false;
const visit = (suite) => {
for (const entry of suite._entries) {
if (result)
return;
if (entry instanceof Suite)
visit(entry);
else
result = true;
}
};
visit(this);
return result;
}
titlePath() {
const titlePath = this.parent ? this.parent.titlePath() : [];
if (this.title || this._type !== "describe")
titlePath.push(this.title);
return titlePath;
}
_collectGrepTitlePath(path) {
if (this.parent)
this.parent._collectGrepTitlePath(path);
if (this.title || this._type !== "describe")
path.push(this.title);
path.push(...this._tags);
}
_getOnlyItems() {
const items = [];
if (this._only)
items.push(this);
for (const suite of this.suites)
items.push(...suite._getOnlyItems());
items.push(...this.tests.filter((test) => test._only));
return items;
}
_deepClone() {
const suite = this._clone();
for (const entry of this._entries) {
if (entry instanceof Suite)
suite._addSuite(entry._deepClone());
else
suite._addTest(entry._clone());
}
return suite;
}
_deepSerialize() {
const suite = this._serialize();
suite.entries = [];
for (const entry of this._entries) {
if (entry instanceof Suite)
suite.entries.push(entry._deepSerialize());
else
suite.entries.push(entry._serialize());
}
return suite;
}
static _deepParse(data) {
const suite = Suite._parse(data);
for (const entry of data.entries) {
if (entry.kind === "suite")
suite._addSuite(Suite._deepParse(entry));
else
suite._addTest(TestCase._parse(entry));
}
return suite;
}
forEachTest(visitor) {
for (const entry of this._entries) {
if (entry instanceof Suite)
entry.forEachTest(visitor);
else
visitor(entry, this);
}
}
_serialize() {
return {
kind: "suite",
title: this.title,
type: this._type,
location: this.location,
only: this._only,
requireFile: this._requireFile,
timeout: this._timeout,
retries: this._retries,
staticAnnotations: this._staticAnnotations.slice(),
tags: this._tags.slice(),
modifiers: this._modifiers.slice(),
parallelMode: this._parallelMode,
hooks: this._hooks.map((h) => ({ type: h.type, location: h.location, title: h.title })),
fileId: this._fileId
};
}
static _parse(data) {
const suite = new Suite(data.title, data.type);
suite.location = data.location;
suite._only = data.only;
suite._requireFile = data.requireFile;
suite._timeout = data.timeout;
suite._retries = data.retries;
suite._staticAnnotations = data.staticAnnotations;
suite._tags = data.tags;
suite._modifiers = data.modifiers;
suite._parallelMode = data.parallelMode;
suite._hooks = data.hooks.map((h) => ({ type: h.type, location: h.location, title: h.title, fn: () => {
} }));
suite._fileId = data.fileId;
return suite;
}
_clone() {
const data = this._serialize();
const suite = Suite._parse(data);
suite._use = this._use.slice();
suite._hooks = this._hooks.slice();
suite._fullProject = this._fullProject;
return suite;
}
project() {
return this._fullProject?.project || this.parent?.project();
}
}
class TestCase extends Base {
constructor(title, fn, testType, location) {
super(title);
this.results = [];
this.type = "test";
this.expectedStatus = "passed";
this.timeout = 0;
this.annotations = [];
this.retries = 0;
this.repeatEachIndex = 0;
this.id = "";
this._poolDigest = "";
this._workerHash = "";
this._projectId = "";
// Explicitly declared tags that are not a part of the title.
this._tags = [];
this.fn = fn;
this._testType = testType;
this.location = location;
}
titlePath() {
const titlePath = this.parent ? this.parent.titlePath() : [];
titlePath.push(this.title);
return titlePath;
}
outcome() {
return (0, import_teleReceiver.computeTestCaseOutcome)(this);
}
ok() {
const status = this.outcome();
return status === "expected" || status === "flaky" || status === "skipped";
}
get tags() {
const titleTags = this._grepBaseTitlePath().join(" ").match(/@[\S]+/g) || [];
return [
...titleTags,
...this._tags
];
}
_serialize() {
return {
kind: "test",
id: this.id,
title: this.title,
retries: this.retries,
timeout: this.timeout,
expectedStatus: this.expectedStatus,
location: this.location,
only: this._only,
requireFile: this._requireFile,
poolDigest: this._poolDigest,
workerHash: this._workerHash,
annotations: this.annotations.slice(),
tags: this._tags.slice(),
projectId: this._projectId
};
}
static _parse(data) {
const test = new TestCase(data.title, () => {
}, import_testType.rootTestType, data.location);
test.id = data.id;
test.retries = data.retries;
test.timeout = data.timeout;
test.expectedStatus = data.expectedStatus;
test._only = data.only;
test._requireFile = data.requireFile;
test._poolDigest = data.poolDigest;
test._workerHash = data.workerHash;
test.annotations = data.annotations;
test._tags = data.tags;
test._projectId = data.projectId;
return test;
}
_clone() {
const data = this._serialize();
const test = TestCase._parse(data);
test._testType = this._testType;
test.fn = this.fn;
return test;
}
_appendTestResult() {
const result = {
retry: this.results.length,
parallelIndex: -1,
workerIndex: -1,
duration: 0,
startTime: /* @__PURE__ */ new Date(),
stdout: [],
stderr: [],
attachments: [],
status: "skipped",
steps: [],
errors: [],
annotations: []
};
this.results.push(result);
return result;
}
_grepBaseTitlePath() {
const path = [];
this.parent._collectGrepTitlePath(path);
path.push(this.title);
return path;
}
_grepTitleWithTags() {
const path = this._grepBaseTitlePath();
path.push(...this._tags);
return path.join(" ");
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Suite,
TestCase
});

100
node_modules/playwright/lib/common/testLoader.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testLoader_exports = {};
__export(testLoader_exports, {
defaultTimeout: () => defaultTimeout,
loadTestFile: () => loadTestFile
});
module.exports = __toCommonJS(testLoader_exports);
var import_path = __toESM(require("path"));
var import_util = __toESM(require("util"));
var esmLoaderHost = __toESM(require("./esmLoaderHost"));
var import_globals = require("./globals");
var import_test = require("./test");
var import_compilationCache = require("../transform/compilationCache");
var import_transform = require("../transform/transform");
var import_util2 = require("../util");
const defaultTimeout = 3e4;
const cachedFileSuites = /* @__PURE__ */ new Map();
async function loadTestFile(file, rootDir, testErrors) {
if (cachedFileSuites.has(file))
return cachedFileSuites.get(file);
const suite = new import_test.Suite(import_path.default.relative(rootDir, file) || import_path.default.basename(file), "file");
suite._requireFile = file;
suite.location = { file, line: 0, column: 0 };
(0, import_globals.setCurrentlyLoadingFileSuite)(suite);
if (!(0, import_globals.isWorkerProcess)()) {
(0, import_compilationCache.startCollectingFileDeps)();
await esmLoaderHost.startCollectingFileDeps();
}
try {
await (0, import_transform.requireOrImport)(file);
cachedFileSuites.set(file, suite);
} catch (e) {
if (!testErrors)
throw e;
testErrors.push(serializeLoadError(file, e));
} finally {
(0, import_globals.setCurrentlyLoadingFileSuite)(void 0);
if (!(0, import_globals.isWorkerProcess)()) {
(0, import_compilationCache.stopCollectingFileDeps)(file);
await esmLoaderHost.stopCollectingFileDeps(file);
}
}
{
const files = /* @__PURE__ */ new Set();
suite.allTests().map((t) => files.add(t.location.file));
if (files.size === 1) {
const mappedFile = files.values().next().value;
if (suite.location.file !== mappedFile) {
if (import_path.default.extname(mappedFile) !== import_path.default.extname(suite.location.file))
suite.location.file = mappedFile;
}
}
}
return suite;
}
function serializeLoadError(file, error) {
if (error instanceof Error) {
const result = (0, import_util2.filterStackTrace)(error);
const loc = error.loc;
result.location = loc ? {
file,
line: loc.line || 0,
column: loc.column || 0
} : void 0;
return result;
}
return { value: import_util.default.inspect(error) };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
defaultTimeout,
loadTestFile
});

307
node_modules/playwright/lib/common/testType.js generated vendored Normal file
View File

@@ -0,0 +1,307 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testType_exports = {};
__export(testType_exports, {
TestTypeImpl: () => TestTypeImpl,
mergeTests: () => mergeTests,
rootTestType: () => rootTestType
});
module.exports = __toCommonJS(testType_exports);
var import_playwright_core = require("playwright-core");
var import_utils = require("playwright-core/lib/utils");
var import_globals = require("./globals");
var import_test = require("./test");
var import_expect = require("../matchers/expect");
var import_transform = require("../transform/transform");
const testTypeSymbol = Symbol("testType");
class TestTypeImpl {
constructor(fixtures) {
this.fixtures = fixtures;
const test = (0, import_transform.wrapFunctionWithLocation)(this._createTest.bind(this, "default"));
test[testTypeSymbol] = this;
test.expect = import_expect.expect;
test.only = (0, import_transform.wrapFunctionWithLocation)(this._createTest.bind(this, "only"));
test.describe = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "default"));
test.describe.only = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "only"));
test.describe.configure = (0, import_transform.wrapFunctionWithLocation)(this._configure.bind(this));
test.describe.fixme = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "fixme"));
test.describe.parallel = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "parallel"));
test.describe.parallel.only = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "parallel.only"));
test.describe.serial = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "serial"));
test.describe.serial.only = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "serial.only"));
test.describe.skip = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "skip"));
test.beforeEach = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "beforeEach"));
test.afterEach = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "afterEach"));
test.beforeAll = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "beforeAll"));
test.afterAll = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "afterAll"));
test.skip = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "skip"));
test.fixme = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "fixme"));
test.fail = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "fail"));
test.fail.only = (0, import_transform.wrapFunctionWithLocation)(this._createTest.bind(this, "fail.only"));
test.slow = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "slow"));
test.setTimeout = (0, import_transform.wrapFunctionWithLocation)(this._setTimeout.bind(this));
test.step = this._step.bind(this, "pass");
test.step.skip = this._step.bind(this, "skip");
test.use = (0, import_transform.wrapFunctionWithLocation)(this._use.bind(this));
test.extend = (0, import_transform.wrapFunctionWithLocation)(this._extend.bind(this));
test.info = () => {
const result = (0, import_globals.currentTestInfo)();
if (!result)
throw new Error("test.info() can only be called while test is running");
return result;
};
this.test = test;
}
_currentSuite(location, title) {
const suite = (0, import_globals.currentlyLoadingFileSuite)();
if (!suite) {
throw new Error([
`Playwright Test did not expect ${title} to be called here.`,
`Most common reasons include:`,
`- You are calling ${title} in a configuration file.`,
`- You are calling ${title} in a file that is imported by the configuration file.`,
`- You have two different versions of @playwright/test. This usually happens`,
` when one of the dependencies in your package.json depends on @playwright/test.`
].join("\n"));
}
return suite;
}
_createTest(type, location, title, fnOrDetails, fn) {
throwIfRunningInsideJest();
const suite = this._currentSuite(location, "test()");
if (!suite)
return;
let details;
let body;
if (typeof fnOrDetails === "function") {
body = fnOrDetails;
details = {};
} else {
body = fn;
details = fnOrDetails;
}
const validatedDetails = validateTestDetails(details, location);
const test = new import_test.TestCase(title, body, this, location);
test._requireFile = suite._requireFile;
test.annotations.push(...validatedDetails.annotations);
test._tags.push(...validatedDetails.tags);
suite._addTest(test);
if (type === "only" || type === "fail.only")
test._only = true;
if (type === "skip" || type === "fixme" || type === "fail")
test.annotations.push({ type, location });
else if (type === "fail.only")
test.annotations.push({ type: "fail", location });
}
_describe(type, location, titleOrFn, fnOrDetails, fn) {
throwIfRunningInsideJest();
const suite = this._currentSuite(location, "test.describe()");
if (!suite)
return;
let title;
let body;
let details;
if (typeof titleOrFn === "function") {
title = "";
details = {};
body = titleOrFn;
} else if (typeof fnOrDetails === "function") {
title = titleOrFn;
details = {};
body = fnOrDetails;
} else {
title = titleOrFn;
details = fnOrDetails;
body = fn;
}
const validatedDetails = validateTestDetails(details, location);
const child = new import_test.Suite(title, "describe");
child._requireFile = suite._requireFile;
child.location = location;
child._staticAnnotations.push(...validatedDetails.annotations);
child._tags.push(...validatedDetails.tags);
suite._addSuite(child);
if (type === "only" || type === "serial.only" || type === "parallel.only")
child._only = true;
if (type === "serial" || type === "serial.only")
child._parallelMode = "serial";
if (type === "parallel" || type === "parallel.only")
child._parallelMode = "parallel";
if (type === "skip" || type === "fixme")
child._staticAnnotations.push({ type, location });
for (let parent = suite; parent; parent = parent.parent) {
if (parent._parallelMode === "serial" && child._parallelMode === "parallel")
throw new Error("describe.parallel cannot be nested inside describe.serial");
if (parent._parallelMode === "default" && child._parallelMode === "parallel")
throw new Error("describe.parallel cannot be nested inside describe with default mode");
}
(0, import_globals.setCurrentlyLoadingFileSuite)(child);
body();
(0, import_globals.setCurrentlyLoadingFileSuite)(suite);
}
_hook(name, location, title, fn) {
const suite = this._currentSuite(location, `test.${name}()`);
if (!suite)
return;
if (typeof title === "function") {
fn = title;
title = `${name} hook`;
}
suite._hooks.push({ type: name, fn, title, location });
}
_configure(location, options) {
throwIfRunningInsideJest();
const suite = this._currentSuite(location, `test.describe.configure()`);
if (!suite)
return;
if (options.timeout !== void 0)
suite._timeout = options.timeout;
if (options.retries !== void 0)
suite._retries = options.retries;
if (options.mode !== void 0) {
if (suite._parallelMode !== "none")
throw new Error(`"${suite._parallelMode}" mode is already assigned for the enclosing scope.`);
suite._parallelMode = options.mode;
for (let parent = suite.parent; parent; parent = parent.parent) {
if (parent._parallelMode === "serial" && suite._parallelMode === "parallel")
throw new Error("describe with parallel mode cannot be nested inside describe with serial mode");
if (parent._parallelMode === "default" && suite._parallelMode === "parallel")
throw new Error("describe with parallel mode cannot be nested inside describe with default mode");
}
}
}
_modifier(type, location, ...modifierArgs) {
const suite = (0, import_globals.currentlyLoadingFileSuite)();
if (suite) {
if (typeof modifierArgs[0] === "string" && typeof modifierArgs[1] === "function" && (type === "skip" || type === "fixme" || type === "fail")) {
this._createTest(type, location, modifierArgs[0], modifierArgs[1]);
return;
}
if (typeof modifierArgs[0] === "string" && typeof modifierArgs[1] === "object" && typeof modifierArgs[2] === "function" && (type === "skip" || type === "fixme" || type === "fail")) {
this._createTest(type, location, modifierArgs[0], modifierArgs[1], modifierArgs[2]);
return;
}
if (typeof modifierArgs[0] === "function") {
suite._modifiers.push({ type, fn: modifierArgs[0], location, description: modifierArgs[1] });
} else {
if (modifierArgs.length >= 1 && !modifierArgs[0])
return;
const description = modifierArgs[1];
suite._staticAnnotations.push({ type, description, location });
}
return;
}
const testInfo = (0, import_globals.currentTestInfo)();
if (!testInfo)
throw new Error(`test.${type}() can only be called inside test, describe block or fixture`);
if (typeof modifierArgs[0] === "function")
throw new Error(`test.${type}() with a function can only be called inside describe block`);
testInfo._modifier(type, location, modifierArgs);
}
_setTimeout(location, timeout) {
const suite = (0, import_globals.currentlyLoadingFileSuite)();
if (suite) {
suite._timeout = timeout;
return;
}
const testInfo = (0, import_globals.currentTestInfo)();
if (!testInfo)
throw new Error(`test.setTimeout() can only be called from a test`);
testInfo.setTimeout(timeout);
}
_use(location, fixtures) {
const suite = this._currentSuite(location, `test.use()`);
if (!suite)
return;
suite._use.push({ fixtures, location });
}
async _step(expectation, title, body, options = {}) {
const testInfo = (0, import_globals.currentTestInfo)();
if (!testInfo)
throw new Error(`test.step() can only be called from a test`);
const step = testInfo._addStep({ category: "test.step", title, location: options.location, box: options.box });
return await (0, import_utils.currentZone)().with("stepZone", step).run(async () => {
try {
let result = void 0;
result = await (0, import_utils.raceAgainstDeadline)(async () => {
try {
return await step.info._runStepBody(expectation === "skip", body, step.location);
} catch (e) {
if (result?.timedOut)
testInfo._failWithError(e);
throw e;
}
}, options.timeout ? (0, import_utils.monotonicTime)() + options.timeout : 0);
if (result.timedOut)
throw new import_playwright_core.errors.TimeoutError(`Step timeout of ${options.timeout}ms exceeded.`);
step.complete({});
return result.result;
} catch (error) {
step.complete({ error });
throw error;
}
});
}
_extend(location, fixtures) {
if (fixtures[testTypeSymbol])
throw new Error(`test.extend() accepts fixtures object, not a test object.
Did you mean to call mergeTests()?`);
const fixturesWithLocation = { fixtures, location };
return new TestTypeImpl([...this.fixtures, fixturesWithLocation]).test;
}
}
function throwIfRunningInsideJest() {
if (process.env.JEST_WORKER_ID) {
const packageManagerCommand = (0, import_utils.getPackageManagerExecCommand)();
throw new Error(
`Playwright Test needs to be invoked via '${packageManagerCommand} playwright test' and excluded from Jest test runs.
Creating one directory for Playwright tests and one for Jest is the recommended way of doing it.
See https://playwright.dev/docs/intro for more information about Playwright Test.`
);
}
}
function validateTestDetails(details, location) {
const originalAnnotations = Array.isArray(details.annotation) ? details.annotation : details.annotation ? [details.annotation] : [];
const annotations = originalAnnotations.map((annotation) => ({ ...annotation, location }));
const tags = Array.isArray(details.tag) ? details.tag : details.tag ? [details.tag] : [];
for (const tag of tags) {
if (tag[0] !== "@")
throw new Error(`Tag must start with "@" symbol, got "${tag}" instead.`);
}
return { annotations, tags };
}
const rootTestType = new TestTypeImpl([]);
function mergeTests(...tests) {
let result = rootTestType;
for (const t of tests) {
const testTypeImpl = t[testTypeSymbol];
if (!testTypeImpl)
throw new Error(`mergeTests() accepts "test" functions as parameters.
Did you mean to call test.extend() with fixtures instead?`);
const newFixtures = testTypeImpl.fixtures.filter((theirs) => !result.fixtures.find((ours) => ours.fixtures === theirs.fixtures));
result = new TestTypeImpl([...result.fixtures, ...newFixtures]);
}
return result.test;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TestTypeImpl,
mergeTests,
rootTestType
});

67
node_modules/playwright/lib/fsWatcher.js generated vendored Normal file
View File

@@ -0,0 +1,67 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var fsWatcher_exports = {};
__export(fsWatcher_exports, {
Watcher: () => Watcher
});
module.exports = __toCommonJS(fsWatcher_exports);
var import_utilsBundle = require("./utilsBundle");
class Watcher {
constructor(onChange) {
this._watchedPaths = [];
this._ignoredFolders = [];
this._collector = [];
this._onChange = onChange;
}
async update(watchedPaths, ignoredFolders, reportPending) {
if (JSON.stringify([this._watchedPaths, this._ignoredFolders]) === JSON.stringify([watchedPaths, ignoredFolders]))
return;
if (reportPending)
this._reportEventsIfAny();
this._watchedPaths = watchedPaths;
this._ignoredFolders = ignoredFolders;
void this._fsWatcher?.close();
this._fsWatcher = void 0;
this._collector.length = 0;
clearTimeout(this._throttleTimer);
this._throttleTimer = void 0;
if (!this._watchedPaths.length)
return;
const ignored = [...this._ignoredFolders, "**/node_modules/**"];
this._fsWatcher = import_utilsBundle.chokidar.watch(watchedPaths, { ignoreInitial: true, ignored }).on("all", async (event, file) => {
if (this._throttleTimer)
clearTimeout(this._throttleTimer);
this._collector.push({ event, file });
this._throttleTimer = setTimeout(() => this._reportEventsIfAny(), 250);
});
await new Promise((resolve, reject) => this._fsWatcher.once("ready", resolve).once("error", reject));
}
async close() {
await this._fsWatcher?.close();
}
_reportEventsIfAny() {
if (this._collector.length)
this._onChange(this._collector.slice());
this._collector.length = 0;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Watcher
});

683
node_modules/playwright/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,683 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export(index_exports, {
_baseTest: () => _baseTest,
defineConfig: () => import_configLoader.defineConfig,
expect: () => import_expect.expect,
mergeExpects: () => import_expect2.mergeExpects,
mergeTests: () => import_testType2.mergeTests,
test: () => test
});
module.exports = __toCommonJS(index_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var playwrightLibrary = __toESM(require("playwright-core"));
var import_utils = require("playwright-core/lib/utils");
var import_globals = require("./common/globals");
var import_testType = require("./common/testType");
var import_expect = require("./matchers/expect");
var import_configLoader = require("./common/configLoader");
var import_testType2 = require("./common/testType");
var import_expect2 = require("./matchers/expect");
const _baseTest = import_testType.rootTestType.test;
(0, import_utils.setBoxedStackPrefixes)([import_path.default.dirname(require.resolve("../package.json"))]);
if (process["__pw_initiator__"]) {
const originalStackTraceLimit = Error.stackTraceLimit;
Error.stackTraceLimit = 200;
try {
throw new Error("Requiring @playwright/test second time, \nFirst:\n" + process["__pw_initiator__"] + "\n\nSecond: ");
} finally {
Error.stackTraceLimit = originalStackTraceLimit;
}
} else {
process["__pw_initiator__"] = new Error().stack;
}
const playwrightFixtures = {
defaultBrowserType: ["chromium", { scope: "worker", option: true, box: true }],
browserName: [({ defaultBrowserType }, use) => use(defaultBrowserType), { scope: "worker", option: true, box: true }],
playwright: [async ({}, use) => {
await use(require("playwright-core"));
}, { scope: "worker", box: true }],
headless: [({ launchOptions }, use) => use(launchOptions.headless ?? true), { scope: "worker", option: true, box: true }],
channel: [({ launchOptions }, use) => use(launchOptions.channel), { scope: "worker", option: true, box: true }],
launchOptions: [{}, { scope: "worker", option: true, box: true }],
connectOptions: [async ({ _optionConnectOptions }, use) => {
await use(connectOptionsFromEnv() || _optionConnectOptions);
}, { scope: "worker", option: true, box: true }],
screenshot: ["off", { scope: "worker", option: true, box: true }],
video: ["off", { scope: "worker", option: true, box: true }],
trace: ["off", { scope: "worker", option: true, box: true }],
_browserOptions: [async ({ playwright, headless, channel, launchOptions }, use) => {
const options = {
handleSIGINT: false,
...launchOptions,
tracesDir: tracing().tracesDir()
};
if (headless !== void 0)
options.headless = headless;
if (channel !== void 0)
options.channel = channel;
playwright._defaultLaunchOptions = options;
await use(options);
playwright._defaultLaunchOptions = void 0;
}, { scope: "worker", auto: true, box: true }],
browser: [async ({ playwright, browserName, _browserOptions, connectOptions }, use, testInfo) => {
if (!["chromium", "firefox", "webkit", "_bidiChromium", "_bidiFirefox"].includes(browserName))
throw new Error(`Unexpected browserName "${browserName}", must be one of "chromium", "firefox" or "webkit"`);
if (connectOptions) {
const browser2 = await playwright[browserName].connect({
...connectOptions,
exposeNetwork: connectOptions.exposeNetwork ?? connectOptions._exposeNetwork,
headers: {
// HTTP headers are ASCII only (not UTF-8).
"x-playwright-launch-options": (0, import_utils.jsonStringifyForceASCII)(_browserOptions),
...connectOptions.headers
}
});
await use(browser2);
await browser2.close({ reason: "Test ended." });
return;
}
const browser = await playwright[browserName].launch();
await use(browser);
await browser.close({ reason: "Test ended." });
}, { scope: "worker", timeout: 0 }],
acceptDownloads: [({ contextOptions }, use) => use(contextOptions.acceptDownloads ?? true), { option: true, box: true }],
bypassCSP: [({ contextOptions }, use) => use(contextOptions.bypassCSP ?? false), { option: true, box: true }],
colorScheme: [({ contextOptions }, use) => use(contextOptions.colorScheme === void 0 ? "light" : contextOptions.colorScheme), { option: true, box: true }],
deviceScaleFactor: [({ contextOptions }, use) => use(contextOptions.deviceScaleFactor), { option: true, box: true }],
extraHTTPHeaders: [({ contextOptions }, use) => use(contextOptions.extraHTTPHeaders), { option: true, box: true }],
geolocation: [({ contextOptions }, use) => use(contextOptions.geolocation), { option: true, box: true }],
hasTouch: [({ contextOptions }, use) => use(contextOptions.hasTouch ?? false), { option: true, box: true }],
httpCredentials: [({ contextOptions }, use) => use(contextOptions.httpCredentials), { option: true, box: true }],
ignoreHTTPSErrors: [({ contextOptions }, use) => use(contextOptions.ignoreHTTPSErrors ?? false), { option: true, box: true }],
isMobile: [({ contextOptions }, use) => use(contextOptions.isMobile ?? false), { option: true, box: true }],
javaScriptEnabled: [({ contextOptions }, use) => use(contextOptions.javaScriptEnabled ?? true), { option: true, box: true }],
locale: [({ contextOptions }, use) => use(contextOptions.locale ?? "en-US"), { option: true, box: true }],
offline: [({ contextOptions }, use) => use(contextOptions.offline ?? false), { option: true, box: true }],
permissions: [({ contextOptions }, use) => use(contextOptions.permissions), { option: true, box: true }],
proxy: [({ contextOptions }, use) => use(contextOptions.proxy), { option: true, box: true }],
storageState: [({ contextOptions }, use) => use(contextOptions.storageState), { option: true, box: true }],
clientCertificates: [({ contextOptions }, use) => use(contextOptions.clientCertificates), { option: true, box: true }],
timezoneId: [({ contextOptions }, use) => use(contextOptions.timezoneId), { option: true, box: true }],
userAgent: [({ contextOptions }, use) => use(contextOptions.userAgent), { option: true, box: true }],
viewport: [({ contextOptions }, use) => use(contextOptions.viewport === void 0 ? { width: 1280, height: 720 } : contextOptions.viewport), { option: true, box: true }],
actionTimeout: [0, { option: true, box: true }],
testIdAttribute: ["data-testid", { option: true, box: true }],
navigationTimeout: [0, { option: true, box: true }],
baseURL: [async ({}, use) => {
await use(process.env.PLAYWRIGHT_TEST_BASE_URL);
}, { option: true, box: true }],
serviceWorkers: [({ contextOptions }, use) => use(contextOptions.serviceWorkers ?? "allow"), { option: true, box: true }],
contextOptions: [{}, { option: true, box: true }],
_combinedContextOptions: [async ({
acceptDownloads,
bypassCSP,
clientCertificates,
colorScheme,
deviceScaleFactor,
extraHTTPHeaders,
hasTouch,
geolocation,
httpCredentials,
ignoreHTTPSErrors,
isMobile,
javaScriptEnabled,
locale,
offline,
permissions,
proxy,
storageState,
viewport,
timezoneId,
userAgent,
baseURL,
contextOptions,
serviceWorkers
}, use) => {
const options = {};
if (acceptDownloads !== void 0)
options.acceptDownloads = acceptDownloads;
if (bypassCSP !== void 0)
options.bypassCSP = bypassCSP;
if (colorScheme !== void 0)
options.colorScheme = colorScheme;
if (deviceScaleFactor !== void 0)
options.deviceScaleFactor = deviceScaleFactor;
if (extraHTTPHeaders !== void 0)
options.extraHTTPHeaders = extraHTTPHeaders;
if (geolocation !== void 0)
options.geolocation = geolocation;
if (hasTouch !== void 0)
options.hasTouch = hasTouch;
if (httpCredentials !== void 0)
options.httpCredentials = httpCredentials;
if (ignoreHTTPSErrors !== void 0)
options.ignoreHTTPSErrors = ignoreHTTPSErrors;
if (isMobile !== void 0)
options.isMobile = isMobile;
if (javaScriptEnabled !== void 0)
options.javaScriptEnabled = javaScriptEnabled;
if (locale !== void 0)
options.locale = locale;
if (offline !== void 0)
options.offline = offline;
if (permissions !== void 0)
options.permissions = permissions;
if (proxy !== void 0)
options.proxy = proxy;
if (storageState !== void 0)
options.storageState = storageState;
if (clientCertificates?.length)
options.clientCertificates = resolveClientCerticates(clientCertificates);
if (timezoneId !== void 0)
options.timezoneId = timezoneId;
if (userAgent !== void 0)
options.userAgent = userAgent;
if (viewport !== void 0)
options.viewport = viewport;
if (baseURL !== void 0)
options.baseURL = baseURL;
if (serviceWorkers !== void 0)
options.serviceWorkers = serviceWorkers;
await use({
...contextOptions,
...options
});
}, { box: true }],
_setupContextOptions: [async ({ playwright, _combinedContextOptions, actionTimeout, navigationTimeout, testIdAttribute }, use, testInfo) => {
if (testIdAttribute)
playwrightLibrary.selectors.setTestIdAttribute(testIdAttribute);
testInfo.snapshotSuffix = process.platform;
if ((0, import_utils.debugMode)() === "inspector")
testInfo._setDebugMode();
playwright._defaultContextOptions = _combinedContextOptions;
playwright._defaultContextTimeout = actionTimeout || 0;
playwright._defaultContextNavigationTimeout = navigationTimeout || 0;
await use();
playwright._defaultContextOptions = void 0;
playwright._defaultContextTimeout = void 0;
playwright._defaultContextNavigationTimeout = void 0;
}, { auto: "all-hooks-included", title: "context configuration", box: true }],
_setupArtifacts: [async ({ playwright, screenshot }, use, testInfo) => {
testInfo.setTimeout(testInfo.project.timeout);
const artifactsRecorder = new ArtifactsRecorder(playwright, tracing().artifactsDir(), screenshot);
await artifactsRecorder.willStartTest(testInfo);
const tracingGroupSteps = [];
const csiListener = {
onApiCallBegin: (data, channel) => {
const testInfo2 = (0, import_globals.currentTestInfo)();
if (!testInfo2 || data.apiName.includes("setTestIdAttribute") || data.apiName === "tracing.groupEnd")
return;
const zone = (0, import_utils.currentZone)().data("stepZone");
if (zone && zone.category === "expect") {
if (zone.apiName)
data.apiName = zone.apiName;
if (zone.title)
data.title = zone.title;
data.stepId = zone.stepId;
return;
}
const step = testInfo2._addStep({
location: data.frames[0],
category: "pw:api",
title: renderTitle(channel.type, channel.method, channel.params, data.title),
apiName: data.apiName,
params: channel.params,
group: (0, import_utils.getActionGroup)({ type: channel.type, method: channel.method })
}, tracingGroupSteps[tracingGroupSteps.length - 1]);
data.userData = step;
data.stepId = step.stepId;
if (data.apiName === "tracing.group")
tracingGroupSteps.push(step);
},
onApiCallRecovery: (data, error, recoveryHandlers) => {
const step = data.userData;
if (step)
recoveryHandlers.push(() => step.recoverFromStepError(error));
},
onApiCallEnd: (data) => {
if (data.apiName === "tracing.group")
return;
if (data.apiName === "tracing.groupEnd") {
const step2 = tracingGroupSteps.pop();
step2?.complete({ error: data.error });
return;
}
const step = data.userData;
step?.complete({ error: data.error });
},
onWillPause: ({ keepTestTimeout }) => {
if (!keepTestTimeout)
(0, import_globals.currentTestInfo)()?._setDebugMode();
},
runAfterCreateBrowserContext: async (context) => {
await artifactsRecorder?.didCreateBrowserContext(context);
const testInfo2 = (0, import_globals.currentTestInfo)();
if (testInfo2)
attachConnectedHeaderIfNeeded(testInfo2, context.browser());
},
runAfterCreateRequestContext: async (context) => {
await artifactsRecorder?.didCreateRequestContext(context);
},
runBeforeCloseBrowserContext: async (context) => {
await artifactsRecorder?.willCloseBrowserContext(context);
},
runBeforeCloseRequestContext: async (context) => {
await artifactsRecorder?.willCloseRequestContext(context);
}
};
const clientInstrumentation = playwright._instrumentation;
clientInstrumentation.addListener(csiListener);
await use();
clientInstrumentation.removeListener(csiListener);
await artifactsRecorder.didFinishTest();
}, { auto: "all-hooks-included", title: "trace recording", box: true, timeout: 0 }],
_contextFactory: [async ({
browser,
video,
_reuseContext,
_combinedContextOptions
/** mitigate dep-via-auto lack of traceability */
}, use, testInfo) => {
const testInfoImpl = testInfo;
const videoMode = normalizeVideoMode(video);
const captureVideo = shouldCaptureVideo(videoMode, testInfo) && !_reuseContext;
const contexts = /* @__PURE__ */ new Map();
let counter = 0;
await use(async (options) => {
const hook = testInfoImpl._currentHookType();
if (hook === "beforeAll" || hook === "afterAll") {
throw new Error([
`"context" and "page" fixtures are not supported in "${hook}" since they are created on a per-test basis.`,
`If you would like to reuse a single page between tests, create context manually with browser.newContext(). See https://aka.ms/playwright/reuse-page for details.`,
`If you would like to configure your page before each test, do that in beforeEach hook instead.`
].join("\n"));
}
const videoOptions = captureVideo ? {
recordVideo: {
dir: tracing().artifactsDir(),
size: typeof video === "string" ? void 0 : video.size
}
} : {};
const context = await browser.newContext({ ...videoOptions, ...options });
if (process.env.PW_CLOCK === "frozen") {
await context._wrapApiCall(async () => {
await context.clock.install({ time: 0 });
await context.clock.pauseAt(1e3);
}, { internal: true });
} else if (process.env.PW_CLOCK === "realtime") {
await context._wrapApiCall(async () => {
await context.clock.install({ time: 0 });
}, { internal: true });
}
let closed = false;
const close = async () => {
if (closed)
return;
closed = true;
const closeReason = testInfo.status === "timedOut" ? "Test timeout of " + testInfo.timeout + "ms exceeded." : "Test ended.";
await context.close({ reason: closeReason });
const testFailed = testInfo.status !== testInfo.expectedStatus;
const preserveVideo = captureVideo && (videoMode === "on" || testFailed && videoMode === "retain-on-failure" || videoMode === "on-first-retry" && testInfo.retry === 1);
if (preserveVideo) {
const { pagesWithVideo: pagesForVideo } = contexts.get(context);
const videos = pagesForVideo.map((p) => p.video()).filter((video2) => !!video2);
await Promise.all(videos.map(async (v) => {
try {
const savedPath = testInfo.outputPath(`video${counter ? "-" + counter : ""}.webm`);
++counter;
await v.saveAs(savedPath);
testInfo.attachments.push({ name: "video", path: savedPath, contentType: "video/webm" });
} catch (e) {
}
}));
}
};
const contextData = { close, pagesWithVideo: [] };
if (captureVideo)
context.on("page", (page) => contextData.pagesWithVideo.push(page));
contexts.set(context, contextData);
return { context, close };
});
await Promise.all([...contexts.values()].map((data) => data.close()));
}, { scope: "test", title: "context", box: true }],
_optionContextReuseMode: ["none", { scope: "worker", option: true, box: true }],
_optionConnectOptions: [void 0, { scope: "worker", option: true, box: true }],
_reuseContext: [async ({ video, _optionContextReuseMode }, use) => {
let mode = _optionContextReuseMode;
if (process.env.PW_TEST_REUSE_CONTEXT)
mode = "when-possible";
const reuse = mode === "when-possible" && normalizeVideoMode(video) === "off";
await use(reuse);
}, { scope: "worker", title: "context", box: true }],
context: async ({ browser, _reuseContext, _contextFactory }, use, testInfo) => {
const browserImpl = browser;
attachConnectedHeaderIfNeeded(testInfo, browserImpl);
if (!_reuseContext) {
const { context: context2, close } = await _contextFactory();
await use(context2);
await close();
return;
}
const context = await browserImpl._wrapApiCall(() => browserImpl._newContextForReuse(), { internal: true });
await use(context);
const closeReason = testInfo.status === "timedOut" ? "Test timeout of " + testInfo.timeout + "ms exceeded." : "Test ended.";
await browserImpl._wrapApiCall(() => browserImpl._disconnectFromReusedContext(closeReason), { internal: true });
},
page: async ({ context, _reuseContext }, use) => {
if (!_reuseContext) {
await use(await context.newPage());
return;
}
let [page] = context.pages();
if (!page)
page = await context.newPage();
await use(page);
},
request: async ({ playwright }, use) => {
const request = await playwright.request.newContext();
await use(request);
const hook = test.info()._currentHookType();
if (hook === "beforeAll") {
await request.dispose({ reason: [
`Fixture { request } from beforeAll cannot be reused in a test.`,
` - Recommended fix: use a separate { request } in the test.`,
` - Alternatively, manually create APIRequestContext in beforeAll and dispose it in afterAll.`,
`See https://playwright.dev/docs/api-testing#sending-api-requests-from-ui-tests for more details.`
].join("\n") });
} else {
await request.dispose();
}
}
};
function normalizeVideoMode(video) {
if (!video)
return "off";
let videoMode = typeof video === "string" ? video : video.mode;
if (videoMode === "retry-with-video")
videoMode = "on-first-retry";
return videoMode;
}
function shouldCaptureVideo(videoMode, testInfo) {
return videoMode === "on" || videoMode === "retain-on-failure" || videoMode === "on-first-retry" && testInfo.retry === 1;
}
function normalizeScreenshotMode(screenshot) {
if (!screenshot)
return "off";
return typeof screenshot === "string" ? screenshot : screenshot.mode;
}
function attachConnectedHeaderIfNeeded(testInfo, browser) {
const connectHeaders = browser?._connection.headers;
if (!connectHeaders)
return;
for (const header of connectHeaders) {
if (header.name !== "x-playwright-attachment")
continue;
const [name, value] = header.value.split("=");
if (!name || !value)
continue;
if (testInfo.attachments.some((attachment) => attachment.name === name))
continue;
testInfo.attachments.push({ name, contentType: "text/plain", body: Buffer.from(value) });
}
}
function resolveFileToConfig(file) {
const config = test.info().config.configFile;
if (!config || !file)
return file;
if (import_path.default.isAbsolute(file))
return file;
return import_path.default.resolve(import_path.default.dirname(config), file);
}
function resolveClientCerticates(clientCertificates) {
for (const cert of clientCertificates) {
cert.certPath = resolveFileToConfig(cert.certPath);
cert.keyPath = resolveFileToConfig(cert.keyPath);
cert.pfxPath = resolveFileToConfig(cert.pfxPath);
}
return clientCertificates;
}
const kTracingStarted = Symbol("kTracingStarted");
function connectOptionsFromEnv() {
const wsEndpoint = process.env.PW_TEST_CONNECT_WS_ENDPOINT;
if (!wsEndpoint)
return void 0;
const headers = process.env.PW_TEST_CONNECT_HEADERS ? JSON.parse(process.env.PW_TEST_CONNECT_HEADERS) : void 0;
return {
wsEndpoint,
headers,
exposeNetwork: process.env.PW_TEST_CONNECT_EXPOSE_NETWORK
};
}
class SnapshotRecorder {
constructor(_artifactsRecorder, _mode, _name, _contentType, _extension, _doSnapshot) {
this._artifactsRecorder = _artifactsRecorder;
this._mode = _mode;
this._name = _name;
this._contentType = _contentType;
this._extension = _extension;
this._doSnapshot = _doSnapshot;
this._ordinal = 0;
this._temporary = [];
}
fixOrdinal() {
this._ordinal = this.testInfo.attachments.filter((a) => a.name === this._name).length;
}
shouldCaptureUponFinish() {
return this._mode === "on" || this._mode === "only-on-failure" && this.testInfo._isFailure() || this._mode === "on-first-failure" && this.testInfo._isFailure() && this.testInfo.retry === 0;
}
async maybeCapture() {
if (!this.shouldCaptureUponFinish())
return;
await Promise.all(this._artifactsRecorder._playwright._allPages().map((page) => this._snapshotPage(page, false)));
}
async persistTemporary() {
if (this.shouldCaptureUponFinish()) {
await Promise.all(this._temporary.map(async (file) => {
try {
const path2 = this._createAttachmentPath();
await import_fs.default.promises.rename(file, path2);
this._attach(path2);
} catch {
}
}));
}
}
async captureTemporary(context) {
if (this._mode === "on" || this._mode === "only-on-failure" || this._mode === "on-first-failure" && this.testInfo.retry === 0)
await Promise.all(context.pages().map((page) => this._snapshotPage(page, true)));
}
_attach(screenshotPath) {
this.testInfo.attachments.push({ name: this._name, path: screenshotPath, contentType: this._contentType });
}
_createAttachmentPath() {
const testFailed = this.testInfo._isFailure();
const index = this._ordinal + 1;
++this._ordinal;
const path2 = this.testInfo.outputPath(`test-${testFailed ? "failed" : "finished"}-${index}${this._extension}`);
return path2;
}
_createTemporaryArtifact(...name) {
const file = import_path.default.join(this._artifactsRecorder._artifactsDir, ...name);
return file;
}
async _snapshotPage(page, temporary) {
if (page[this.testInfo._uniqueSymbol])
return;
page[this.testInfo._uniqueSymbol] = true;
try {
const path2 = temporary ? this._createTemporaryArtifact((0, import_utils.createGuid)() + this._extension) : this._createAttachmentPath();
await this._doSnapshot(page, path2);
if (temporary)
this._temporary.push(path2);
else
this._attach(path2);
} catch {
}
}
get testInfo() {
return this._artifactsRecorder._testInfo;
}
}
class ArtifactsRecorder {
constructor(playwright, artifactsDir, screenshot) {
this._playwright = playwright;
this._artifactsDir = artifactsDir;
const screenshotOptions = typeof screenshot === "string" ? void 0 : screenshot;
this._startedCollectingArtifacts = Symbol("startedCollectingArtifacts");
this._screenshotRecorder = new SnapshotRecorder(this, normalizeScreenshotMode(screenshot), "screenshot", "image/png", ".png", async (page, path2) => {
await page._wrapApiCall(async () => {
await page.screenshot({ ...screenshotOptions, timeout: 5e3, path: path2, caret: "initial" });
}, { internal: true });
});
}
async willStartTest(testInfo) {
this._testInfo = testInfo;
testInfo._onDidFinishTestFunction = () => this.didFinishTestFunction();
this._screenshotRecorder.fixOrdinal();
await Promise.all(this._playwright._allContexts().map((context) => this.didCreateBrowserContext(context)));
const existingApiRequests = Array.from(this._playwright.request._contexts);
await Promise.all(existingApiRequests.map((c) => this.didCreateRequestContext(c)));
}
async didCreateBrowserContext(context) {
await this._startTraceChunkOnContextCreation(context, context.tracing);
}
async willCloseBrowserContext(context) {
await this._stopTracing(context, context.tracing);
await this._screenshotRecorder.captureTemporary(context);
await this._takePageSnapshot(context);
}
async _takePageSnapshot(context) {
if (process.env.PLAYWRIGHT_NO_COPY_PROMPT)
return;
if (this._testInfo.errors.length === 0)
return;
if (this._pageSnapshot)
return;
const page = context.pages()[0];
if (!page)
return;
try {
await page._wrapApiCall(async () => {
this._pageSnapshot = await page._snapshotForAI({ timeout: 5e3 });
}, { internal: true });
} catch {
}
}
async didCreateRequestContext(context) {
await this._startTraceChunkOnContextCreation(context, context._tracing);
}
async willCloseRequestContext(context) {
await this._stopTracing(context, context._tracing);
}
async didFinishTestFunction() {
await this._screenshotRecorder.maybeCapture();
}
async didFinishTest() {
await this.didFinishTestFunction();
const leftoverContexts = this._playwright._allContexts();
const leftoverApiRequests = Array.from(this._playwright.request._contexts);
await Promise.all(leftoverContexts.map(async (context2) => {
await this._stopTracing(context2, context2.tracing);
}).concat(leftoverApiRequests.map(async (context2) => {
await this._stopTracing(context2, context2._tracing);
})));
await this._screenshotRecorder.persistTemporary();
const context = leftoverContexts[0];
if (context)
await this._takePageSnapshot(context);
if (this._pageSnapshot && this._testInfo.errors.length > 0 && !this._testInfo.attachments.some((a) => a.name === "error-context")) {
const lines = [
"# Page snapshot",
"",
"```yaml",
this._pageSnapshot,
"```"
];
const filePath = this._testInfo.outputPath("error-context.md");
await import_fs.default.promises.writeFile(filePath, lines.join("\n"), "utf8");
this._testInfo._attach({
name: "error-context",
contentType: "text/markdown",
path: filePath
}, void 0);
}
}
async _startTraceChunkOnContextCreation(channelOwner, tracing2) {
await channelOwner._wrapApiCall(async () => {
const options = this._testInfo._tracing.traceOptions();
if (options) {
const title = this._testInfo._tracing.traceTitle();
const name = this._testInfo._tracing.generateNextTraceRecordingName();
if (!tracing2[kTracingStarted]) {
await tracing2.start({ ...options, title, name });
tracing2[kTracingStarted] = true;
} else {
await tracing2.startChunk({ title, name });
}
} else {
if (tracing2[kTracingStarted]) {
tracing2[kTracingStarted] = false;
await tracing2.stop();
}
}
}, { internal: true });
}
async _stopTracing(channelOwner, tracing2) {
await channelOwner._wrapApiCall(async () => {
if (tracing2[this._startedCollectingArtifacts])
return;
tracing2[this._startedCollectingArtifacts] = true;
if (this._testInfo._tracing.traceOptions() && tracing2[kTracingStarted])
await tracing2.stopChunk({ path: this._testInfo._tracing.maybeGenerateNextTraceRecordingPath() });
}, { internal: true });
}
}
function renderTitle(type, method, params, title) {
const prefix = (0, import_utils.renderTitleForCall)({ title, type, method, params });
let selector;
if (params?.["selector"] && typeof params.selector === "string")
selector = (0, import_utils.asLocatorDescription)("javascript", params.selector);
return prefix + (selector ? ` ${selector}` : "");
}
function tracing() {
return test.info()._tracing;
}
const test = _baseTest.extend(playwrightFixtures);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
_baseTest,
defineConfig,
expect,
mergeExpects,
mergeTests,
test
});

42
node_modules/playwright/lib/internalsForTest.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var internalsForTest_exports = {};
__export(internalsForTest_exports, {
fileDependencies: () => fileDependencies
});
module.exports = __toCommonJS(internalsForTest_exports);
var import_path = __toESM(require("path"));
var import_compilationCache = require("./transform/compilationCache");
function fileDependencies() {
return Object.fromEntries([...(0, import_compilationCache.fileDependenciesForTest)().entries()].map((entry) => [import_path.default.basename(entry[0]), [...entry[1]].map((f) => import_path.default.basename(f)).sort()]));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
fileDependencies
});

77
node_modules/playwright/lib/isomorphic/events.js generated vendored Normal file
View File

@@ -0,0 +1,77 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var events_exports = {};
__export(events_exports, {
Disposable: () => Disposable,
EventEmitter: () => EventEmitter
});
module.exports = __toCommonJS(events_exports);
var Disposable;
((Disposable2) => {
function disposeAll(disposables) {
for (const disposable of disposables.splice(0))
disposable.dispose();
}
Disposable2.disposeAll = disposeAll;
})(Disposable || (Disposable = {}));
class EventEmitter {
constructor() {
this._listeners = /* @__PURE__ */ new Set();
this.event = (listener, disposables) => {
this._listeners.add(listener);
let disposed = false;
const self = this;
const result = {
dispose() {
if (!disposed) {
disposed = true;
self._listeners.delete(listener);
}
}
};
if (disposables)
disposables.push(result);
return result;
};
}
fire(event) {
const dispatch = !this._deliveryQueue;
if (!this._deliveryQueue)
this._deliveryQueue = [];
for (const listener of this._listeners)
this._deliveryQueue.push({ listener, event });
if (!dispatch)
return;
for (let index = 0; index < this._deliveryQueue.length; index++) {
const { listener, event: event2 } = this._deliveryQueue[index];
listener.call(null, event2);
}
this._deliveryQueue = void 0;
}
dispose() {
this._listeners.clear();
if (this._deliveryQueue)
this._deliveryQueue = [];
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Disposable,
EventEmitter
});

30
node_modules/playwright/lib/isomorphic/folders.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var folders_exports = {};
__export(folders_exports, {
artifactsFolderName: () => artifactsFolderName
});
module.exports = __toCommonJS(folders_exports);
function artifactsFolderName(workerIndex) {
return `.playwright-artifacts-${workerIndex}`;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
artifactsFolderName
});

View File

@@ -0,0 +1,69 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stringInternPool_exports = {};
__export(stringInternPool_exports, {
JsonStringInternalizer: () => JsonStringInternalizer,
StringInternPool: () => StringInternPool
});
module.exports = __toCommonJS(stringInternPool_exports);
class StringInternPool {
constructor() {
this._stringCache = /* @__PURE__ */ new Map();
}
internString(s) {
let result = this._stringCache.get(s);
if (!result) {
this._stringCache.set(s, s);
result = s;
}
return result;
}
}
class JsonStringInternalizer {
constructor(pool) {
this._pool = pool;
}
traverse(value) {
if (typeof value !== "object")
return;
if (Array.isArray(value)) {
for (let i = 0; i < value.length; i++) {
if (typeof value[i] === "string")
value[i] = this.intern(value[i]);
else
this.traverse(value[i]);
}
} else {
for (const name in value) {
if (typeof value[name] === "string")
value[name] = this.intern(value[name]);
else
this.traverse(value[name]);
}
}
}
intern(value) {
return this._pool.internString(value);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
JsonStringInternalizer,
StringInternPool
});

507
node_modules/playwright/lib/isomorphic/teleReceiver.js generated vendored Normal file
View File

@@ -0,0 +1,507 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var teleReceiver_exports = {};
__export(teleReceiver_exports, {
TeleReporterReceiver: () => TeleReporterReceiver,
TeleSuite: () => TeleSuite,
TeleTestCase: () => TeleTestCase,
TeleTestResult: () => TeleTestResult,
baseFullConfig: () => baseFullConfig,
computeTestCaseOutcome: () => computeTestCaseOutcome,
parseRegexPatterns: () => parseRegexPatterns,
serializeRegexPatterns: () => serializeRegexPatterns
});
module.exports = __toCommonJS(teleReceiver_exports);
class TeleReporterReceiver {
constructor(reporter, options = {}) {
this.isListing = false;
this._tests = /* @__PURE__ */ new Map();
this._rootSuite = new TeleSuite("", "root");
this._options = options;
this._reporter = reporter;
}
reset() {
this._rootSuite._entries = [];
this._tests.clear();
}
dispatch(message) {
const { method, params } = message;
if (method === "onConfigure") {
this._onConfigure(params.config);
return;
}
if (method === "onProject") {
this._onProject(params.project);
return;
}
if (method === "onBegin") {
this._onBegin();
return;
}
if (method === "onTestBegin") {
this._onTestBegin(params.testId, params.result);
return;
}
if (method === "onTestEnd") {
this._onTestEnd(params.test, params.result);
return;
}
if (method === "onStepBegin") {
this._onStepBegin(params.testId, params.resultId, params.step);
return;
}
if (method === "onAttach") {
this._onAttach(params.testId, params.resultId, params.attachments);
return;
}
if (method === "onStepEnd") {
this._onStepEnd(params.testId, params.resultId, params.step);
return;
}
if (method === "onError") {
this._onError(params.error);
return;
}
if (method === "onStdIO") {
this._onStdIO(params.type, params.testId, params.resultId, params.data, params.isBase64);
return;
}
if (method === "onEnd")
return this._onEnd(params.result);
if (method === "onExit")
return this._onExit();
}
_onConfigure(config) {
this._rootDir = config.rootDir;
this._config = this._parseConfig(config);
this._reporter.onConfigure?.(this._config);
}
_onProject(project) {
let projectSuite = this._options.mergeProjects ? this._rootSuite.suites.find((suite) => suite.project().name === project.name) : void 0;
if (!projectSuite) {
projectSuite = new TeleSuite(project.name, "project");
this._rootSuite._addSuite(projectSuite);
}
projectSuite._project = this._parseProject(project);
for (const suite of project.suites)
this._mergeSuiteInto(suite, projectSuite);
}
_onBegin() {
this._reporter.onBegin?.(this._rootSuite);
}
_onTestBegin(testId, payload) {
const test = this._tests.get(testId);
if (this._options.clearPreviousResultsWhenTestBegins)
test.results = [];
const testResult = test._createTestResult(payload.id);
testResult.retry = payload.retry;
testResult.workerIndex = payload.workerIndex;
testResult.parallelIndex = payload.parallelIndex;
testResult.setStartTimeNumber(payload.startTime);
this._reporter.onTestBegin?.(test, testResult);
}
_onTestEnd(testEndPayload, payload) {
const test = this._tests.get(testEndPayload.testId);
test.timeout = testEndPayload.timeout;
test.expectedStatus = testEndPayload.expectedStatus;
const result = test.results.find((r) => r._id === payload.id);
result.duration = payload.duration;
result.status = payload.status;
result.errors = payload.errors;
result.error = result.errors?.[0];
if (!!payload.attachments)
result.attachments = this._parseAttachments(payload.attachments);
if (payload.annotations) {
this._absoluteAnnotationLocationsInplace(payload.annotations);
result.annotations = payload.annotations;
test.annotations = payload.annotations;
}
this._reporter.onTestEnd?.(test, result);
result._stepMap = /* @__PURE__ */ new Map();
}
_onStepBegin(testId, resultId, payload) {
const test = this._tests.get(testId);
const result = test.results.find((r) => r._id === resultId);
const parentStep = payload.parentStepId ? result._stepMap.get(payload.parentStepId) : void 0;
const location = this._absoluteLocation(payload.location);
const step = new TeleTestStep(payload, parentStep, location, result);
if (parentStep)
parentStep.steps.push(step);
else
result.steps.push(step);
result._stepMap.set(payload.id, step);
this._reporter.onStepBegin?.(test, result, step);
}
_onStepEnd(testId, resultId, payload) {
const test = this._tests.get(testId);
const result = test.results.find((r) => r._id === resultId);
const step = result._stepMap.get(payload.id);
step._endPayload = payload;
step.duration = payload.duration;
step.error = payload.error;
this._reporter.onStepEnd?.(test, result, step);
}
_onAttach(testId, resultId, attachments) {
const test = this._tests.get(testId);
const result = test.results.find((r) => r._id === resultId);
result.attachments.push(...attachments.map((a) => ({
name: a.name,
contentType: a.contentType,
path: a.path,
body: a.base64 && globalThis.Buffer ? Buffer.from(a.base64, "base64") : void 0
})));
}
_onError(error) {
this._reporter.onError?.(error);
}
_onStdIO(type, testId, resultId, data, isBase64) {
const chunk = isBase64 ? globalThis.Buffer ? Buffer.from(data, "base64") : atob(data) : data;
const test = testId ? this._tests.get(testId) : void 0;
const result = test && resultId ? test.results.find((r) => r._id === resultId) : void 0;
if (type === "stdout") {
result?.stdout.push(chunk);
this._reporter.onStdOut?.(chunk, test, result);
} else {
result?.stderr.push(chunk);
this._reporter.onStdErr?.(chunk, test, result);
}
}
async _onEnd(result) {
await this._reporter.onEnd?.({
status: result.status,
startTime: new Date(result.startTime),
duration: result.duration
});
}
_onExit() {
return this._reporter.onExit?.();
}
_parseConfig(config) {
const result = { ...baseFullConfig, ...config };
if (this._options.configOverrides) {
result.configFile = this._options.configOverrides.configFile;
result.reportSlowTests = this._options.configOverrides.reportSlowTests;
result.quiet = this._options.configOverrides.quiet;
result.reporter = [...this._options.configOverrides.reporter];
}
return result;
}
_parseProject(project) {
return {
metadata: project.metadata,
name: project.name,
outputDir: this._absolutePath(project.outputDir),
repeatEach: project.repeatEach,
retries: project.retries,
testDir: this._absolutePath(project.testDir),
testIgnore: parseRegexPatterns(project.testIgnore),
testMatch: parseRegexPatterns(project.testMatch),
timeout: project.timeout,
grep: parseRegexPatterns(project.grep),
grepInvert: parseRegexPatterns(project.grepInvert),
dependencies: project.dependencies,
teardown: project.teardown,
snapshotDir: this._absolutePath(project.snapshotDir),
use: project.use
};
}
_parseAttachments(attachments) {
return attachments.map((a) => {
return {
...a,
body: a.base64 && globalThis.Buffer ? Buffer.from(a.base64, "base64") : void 0
};
});
}
_mergeSuiteInto(jsonSuite, parent) {
let targetSuite = parent.suites.find((s) => s.title === jsonSuite.title);
if (!targetSuite) {
targetSuite = new TeleSuite(jsonSuite.title, parent.type === "project" ? "file" : "describe");
parent._addSuite(targetSuite);
}
targetSuite.location = this._absoluteLocation(jsonSuite.location);
jsonSuite.entries.forEach((e) => {
if ("testId" in e)
this._mergeTestInto(e, targetSuite);
else
this._mergeSuiteInto(e, targetSuite);
});
}
_mergeTestInto(jsonTest, parent) {
let targetTest = this._options.mergeTestCases ? parent.tests.find((s) => s.title === jsonTest.title && s.repeatEachIndex === jsonTest.repeatEachIndex) : void 0;
if (!targetTest) {
targetTest = new TeleTestCase(jsonTest.testId, jsonTest.title, this._absoluteLocation(jsonTest.location), jsonTest.repeatEachIndex);
parent._addTest(targetTest);
this._tests.set(targetTest.id, targetTest);
}
this._updateTest(jsonTest, targetTest);
}
_updateTest(payload, test) {
test.id = payload.testId;
test.location = this._absoluteLocation(payload.location);
test.retries = payload.retries;
test.tags = payload.tags ?? [];
test.annotations = payload.annotations ?? [];
this._absoluteAnnotationLocationsInplace(test.annotations);
return test;
}
_absoluteAnnotationLocationsInplace(annotations) {
for (const annotation of annotations) {
if (annotation.location)
annotation.location = this._absoluteLocation(annotation.location);
}
}
_absoluteLocation(location) {
if (!location)
return location;
return {
...location,
file: this._absolutePath(location.file)
};
}
_absolutePath(relativePath) {
if (relativePath === void 0)
return;
return this._options.resolvePath ? this._options.resolvePath(this._rootDir, relativePath) : this._rootDir + "/" + relativePath;
}
}
class TeleSuite {
constructor(title, type) {
this._entries = [];
this._requireFile = "";
this._parallelMode = "none";
this.title = title;
this._type = type;
}
get type() {
return this._type;
}
get suites() {
return this._entries.filter((e) => e.type !== "test");
}
get tests() {
return this._entries.filter((e) => e.type === "test");
}
entries() {
return this._entries;
}
allTests() {
const result = [];
const visit = (suite) => {
for (const entry of suite.entries()) {
if (entry.type === "test")
result.push(entry);
else
visit(entry);
}
};
visit(this);
return result;
}
titlePath() {
const titlePath = this.parent ? this.parent.titlePath() : [];
if (this.title || this._type !== "describe")
titlePath.push(this.title);
return titlePath;
}
project() {
return this._project ?? this.parent?.project();
}
_addTest(test) {
test.parent = this;
this._entries.push(test);
}
_addSuite(suite) {
suite.parent = this;
this._entries.push(suite);
}
}
class TeleTestCase {
constructor(id, title, location, repeatEachIndex) {
this.fn = () => {
};
this.results = [];
this.type = "test";
this.expectedStatus = "passed";
this.timeout = 0;
this.annotations = [];
this.retries = 0;
this.tags = [];
this.repeatEachIndex = 0;
this.id = id;
this.title = title;
this.location = location;
this.repeatEachIndex = repeatEachIndex;
}
titlePath() {
const titlePath = this.parent ? this.parent.titlePath() : [];
titlePath.push(this.title);
return titlePath;
}
outcome() {
return computeTestCaseOutcome(this);
}
ok() {
const status = this.outcome();
return status === "expected" || status === "flaky" || status === "skipped";
}
_createTestResult(id) {
const result = new TeleTestResult(this.results.length, id);
this.results.push(result);
return result;
}
}
class TeleTestStep {
constructor(payload, parentStep, location, result) {
this.duration = -1;
this.steps = [];
this._startTime = 0;
this.title = payload.title;
this.category = payload.category;
this.location = location;
this.parent = parentStep;
this._startTime = payload.startTime;
this._result = result;
}
titlePath() {
const parentPath = this.parent?.titlePath() || [];
return [...parentPath, this.title];
}
get startTime() {
return new Date(this._startTime);
}
set startTime(value) {
this._startTime = +value;
}
get attachments() {
return this._endPayload?.attachments?.map((index) => this._result.attachments[index]) ?? [];
}
get annotations() {
return this._endPayload?.annotations ?? [];
}
}
class TeleTestResult {
constructor(retry, id) {
this.parallelIndex = -1;
this.workerIndex = -1;
this.duration = -1;
this.stdout = [];
this.stderr = [];
this.attachments = [];
this.annotations = [];
this.status = "skipped";
this.steps = [];
this.errors = [];
this._stepMap = /* @__PURE__ */ new Map();
this._startTime = 0;
this.retry = retry;
this._id = id;
}
setStartTimeNumber(startTime) {
this._startTime = startTime;
}
get startTime() {
return new Date(this._startTime);
}
set startTime(value) {
this._startTime = +value;
}
}
const baseFullConfig = {
forbidOnly: false,
fullyParallel: false,
globalSetup: null,
globalTeardown: null,
globalTimeout: 0,
grep: /.*/,
grepInvert: null,
maxFailures: 0,
metadata: {},
preserveOutput: "always",
projects: [],
reporter: [[process.env.CI ? "dot" : "list"]],
reportSlowTests: {
max: 5,
threshold: 3e5
/* 5 minutes */
},
configFile: "",
rootDir: "",
quiet: false,
shard: null,
updateSnapshots: "missing",
updateSourceMethod: "patch",
version: "",
workers: 0,
webServer: null
};
function serializeRegexPatterns(patterns) {
if (!Array.isArray(patterns))
patterns = [patterns];
return patterns.map((s) => {
if (typeof s === "string")
return { s };
return { r: { source: s.source, flags: s.flags } };
});
}
function parseRegexPatterns(patterns) {
return patterns.map((p) => {
if (p.s !== void 0)
return p.s;
return new RegExp(p.r.source, p.r.flags);
});
}
function computeTestCaseOutcome(test) {
let skipped = 0;
let didNotRun = 0;
let expected = 0;
let interrupted = 0;
let unexpected = 0;
for (const result of test.results) {
if (result.status === "interrupted") {
++interrupted;
} else if (result.status === "skipped" && test.expectedStatus === "skipped") {
++skipped;
} else if (result.status === "skipped") {
++didNotRun;
} else if (result.status === test.expectedStatus) {
++expected;
} else {
++unexpected;
}
}
if (expected === 0 && unexpected === 0)
return "skipped";
if (unexpected === 0)
return "expected";
if (expected === 0 && skipped === 0)
return "unexpected";
return "flaky";
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TeleReporterReceiver,
TeleSuite,
TeleTestCase,
TeleTestResult,
baseFullConfig,
computeTestCaseOutcome,
parseRegexPatterns,
serializeRegexPatterns
});

View File

@@ -0,0 +1,137 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var teleSuiteUpdater_exports = {};
__export(teleSuiteUpdater_exports, {
TeleSuiteUpdater: () => TeleSuiteUpdater
});
module.exports = __toCommonJS(teleSuiteUpdater_exports);
var import_teleReceiver = require("./teleReceiver");
var import_testTree = require("./testTree");
class TeleSuiteUpdater {
constructor(options) {
this.loadErrors = [];
this.progress = {
total: 0,
passed: 0,
failed: 0,
skipped: 0
};
this._lastRunTestCount = 0;
this._receiver = new import_teleReceiver.TeleReporterReceiver(this._createReporter(), {
mergeProjects: true,
mergeTestCases: true,
resolvePath: (rootDir, relativePath) => rootDir + options.pathSeparator + relativePath,
clearPreviousResultsWhenTestBegins: true
});
this._options = options;
}
_createReporter() {
return {
version: () => "v2",
onConfigure: (c) => {
this.config = c;
this._lastRunReceiver = new import_teleReceiver.TeleReporterReceiver({
version: () => "v2",
onBegin: (suite) => {
this._lastRunTestCount = suite.allTests().length;
this._lastRunReceiver = void 0;
}
}, {
mergeProjects: true,
mergeTestCases: false,
resolvePath: (rootDir, relativePath) => rootDir + this._options.pathSeparator + relativePath
});
},
onBegin: (suite) => {
if (!this.rootSuite)
this.rootSuite = suite;
if (this._testResultsSnapshot) {
for (const test of this.rootSuite.allTests())
test.results = this._testResultsSnapshot?.get(test.id) || test.results;
this._testResultsSnapshot = void 0;
}
this.progress.total = this._lastRunTestCount;
this.progress.passed = 0;
this.progress.failed = 0;
this.progress.skipped = 0;
this._options.onUpdate(true);
},
onEnd: () => {
this._options.onUpdate(true);
},
onTestBegin: (test, testResult) => {
testResult[import_testTree.statusEx] = "running";
this._options.onUpdate();
},
onTestEnd: (test, testResult) => {
if (test.outcome() === "skipped")
++this.progress.skipped;
else if (test.outcome() === "unexpected")
++this.progress.failed;
else
++this.progress.passed;
testResult[import_testTree.statusEx] = testResult.status;
this._options.onUpdate();
},
onError: (error) => this._handleOnError(error),
printsToStdio: () => false
};
}
processGlobalReport(report) {
const receiver = new import_teleReceiver.TeleReporterReceiver({
version: () => "v2",
onConfigure: (c) => {
this.config = c;
},
onError: (error) => this._handleOnError(error)
});
for (const message of report)
void receiver.dispatch(message);
}
processListReport(report) {
const tests = this.rootSuite?.allTests() || [];
this._testResultsSnapshot = new Map(tests.map((test) => [test.id, test.results]));
this._receiver.reset();
for (const message of report)
void this._receiver.dispatch(message);
}
processTestReportEvent(message) {
this._lastRunReceiver?.dispatch(message)?.catch(() => {
});
this._receiver.dispatch(message)?.catch(() => {
});
}
_handleOnError(error) {
this.loadErrors.push(error);
this._options.onError?.(error);
this._options.onUpdate();
}
asModel() {
return {
rootSuite: this.rootSuite || new import_teleReceiver.TeleSuite("", "root"),
config: this.config,
loadErrors: this.loadErrors,
progress: this.progress
};
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TeleSuiteUpdater
});

View File

@@ -0,0 +1,218 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testServerConnection_exports = {};
__export(testServerConnection_exports, {
TestServerConnection: () => TestServerConnection,
WebSocketTestServerTransport: () => WebSocketTestServerTransport
});
module.exports = __toCommonJS(testServerConnection_exports);
var events = __toESM(require("./events"));
class WebSocketTestServerTransport {
constructor(url) {
this._ws = new WebSocket(url);
}
onmessage(listener) {
this._ws.addEventListener("message", (event) => listener(event.data.toString()));
}
onopen(listener) {
this._ws.addEventListener("open", listener);
}
onerror(listener) {
this._ws.addEventListener("error", listener);
}
onclose(listener) {
this._ws.addEventListener("close", listener);
}
send(data) {
this._ws.send(data);
}
close() {
this._ws.close();
}
}
class TestServerConnection {
constructor(transport) {
this._onCloseEmitter = new events.EventEmitter();
this._onReportEmitter = new events.EventEmitter();
this._onStdioEmitter = new events.EventEmitter();
this._onTestFilesChangedEmitter = new events.EventEmitter();
this._onLoadTraceRequestedEmitter = new events.EventEmitter();
this._onRecoverFromStepErrorEmitter = new events.EventEmitter();
this._lastId = 0;
this._callbacks = /* @__PURE__ */ new Map();
this._isClosed = false;
this.onClose = this._onCloseEmitter.event;
this.onReport = this._onReportEmitter.event;
this.onStdio = this._onStdioEmitter.event;
this.onTestFilesChanged = this._onTestFilesChangedEmitter.event;
this.onLoadTraceRequested = this._onLoadTraceRequestedEmitter.event;
this.onRecoverFromStepError = this._onRecoverFromStepErrorEmitter.event;
this._transport = transport;
this._transport.onmessage((data) => {
const message = JSON.parse(data);
const { id, result, error, method, params } = message;
if (id) {
const callback = this._callbacks.get(id);
if (!callback)
return;
this._callbacks.delete(id);
if (error)
callback.reject(new Error(error));
else
callback.resolve(result);
} else {
this._dispatchEvent(method, params);
}
});
const pingInterval = setInterval(() => this._sendMessage("ping").catch(() => {
}), 3e4);
this._connectedPromise = new Promise((f, r) => {
this._transport.onopen(f);
this._transport.onerror(r);
});
this._transport.onclose(() => {
this._isClosed = true;
this._onCloseEmitter.fire();
clearInterval(pingInterval);
});
}
isClosed() {
return this._isClosed;
}
async _sendMessage(method, params) {
const logForTest = globalThis.__logForTest;
logForTest?.({ method, params });
await this._connectedPromise;
const id = ++this._lastId;
const message = { id, method, params };
this._transport.send(JSON.stringify(message));
return new Promise((resolve, reject) => {
this._callbacks.set(id, { resolve, reject });
});
}
_sendMessageNoReply(method, params) {
this._sendMessage(method, params).catch(() => {
});
}
_dispatchEvent(method, params) {
if (method === "report")
this._onReportEmitter.fire(params);
else if (method === "stdio")
this._onStdioEmitter.fire(params);
else if (method === "testFilesChanged")
this._onTestFilesChangedEmitter.fire(params);
else if (method === "loadTraceRequested")
this._onLoadTraceRequestedEmitter.fire(params);
else if (method === "recoverFromStepError")
this._onRecoverFromStepErrorEmitter.fire(params);
}
async initialize(params) {
await this._sendMessage("initialize", params);
}
async ping(params) {
await this._sendMessage("ping", params);
}
async pingNoReply(params) {
this._sendMessageNoReply("ping", params);
}
async watch(params) {
await this._sendMessage("watch", params);
}
watchNoReply(params) {
this._sendMessageNoReply("watch", params);
}
async open(params) {
await this._sendMessage("open", params);
}
openNoReply(params) {
this._sendMessageNoReply("open", params);
}
async resizeTerminal(params) {
await this._sendMessage("resizeTerminal", params);
}
resizeTerminalNoReply(params) {
this._sendMessageNoReply("resizeTerminal", params);
}
async checkBrowsers(params) {
return await this._sendMessage("checkBrowsers", params);
}
async installBrowsers(params) {
await this._sendMessage("installBrowsers", params);
}
async runGlobalSetup(params) {
return await this._sendMessage("runGlobalSetup", params);
}
async runGlobalTeardown(params) {
return await this._sendMessage("runGlobalTeardown", params);
}
async startDevServer(params) {
return await this._sendMessage("startDevServer", params);
}
async stopDevServer(params) {
return await this._sendMessage("stopDevServer", params);
}
async clearCache(params) {
return await this._sendMessage("clearCache", params);
}
async listFiles(params) {
return await this._sendMessage("listFiles", params);
}
async listTests(params) {
return await this._sendMessage("listTests", params);
}
async runTests(params) {
return await this._sendMessage("runTests", params);
}
async findRelatedTestFiles(params) {
return await this._sendMessage("findRelatedTestFiles", params);
}
async stopTests(params) {
await this._sendMessage("stopTests", params);
}
stopTestsNoReply(params) {
this._sendMessageNoReply("stopTests", params);
}
async closeGracefully(params) {
await this._sendMessage("closeGracefully", params);
}
async resumeAfterStepError(params) {
await this._sendMessage("resumeAfterStepError", params);
}
close() {
try {
this._transport.close();
} catch {
}
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TestServerConnection,
WebSocketTestServerTransport
});

View File

@@ -0,0 +1,16 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testServerInterface_exports = {};
module.exports = __toCommonJS(testServerInterface_exports);

307
node_modules/playwright/lib/isomorphic/testTree.js generated vendored Normal file
View File

@@ -0,0 +1,307 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testTree_exports = {};
__export(testTree_exports, {
TestTree: () => TestTree,
collectTestIds: () => collectTestIds,
sortAndPropagateStatus: () => sortAndPropagateStatus,
statusEx: () => statusEx
});
module.exports = __toCommonJS(testTree_exports);
class TestTree {
constructor(rootFolder, rootSuite, loadErrors, projectFilters, pathSeparator) {
this._treeItemById = /* @__PURE__ */ new Map();
this._treeItemByTestId = /* @__PURE__ */ new Map();
const filterProjects = projectFilters && [...projectFilters.values()].some(Boolean);
this.pathSeparator = pathSeparator;
this.rootItem = {
kind: "group",
subKind: "folder",
id: rootFolder,
title: "",
location: { file: "", line: 0, column: 0 },
duration: 0,
parent: void 0,
children: [],
status: "none",
hasLoadErrors: false
};
this._treeItemById.set(rootFolder, this.rootItem);
const visitSuite = (project, parentSuite, parentGroup) => {
for (const suite of parentSuite.suites) {
if (!suite.title) {
visitSuite(project, suite, parentGroup);
continue;
}
let group = parentGroup.children.find((item) => item.kind === "group" && item.title === suite.title);
if (!group) {
group = {
kind: "group",
subKind: "describe",
id: "suite:" + parentSuite.titlePath().join("") + "" + suite.title,
// account for anonymous suites
title: suite.title,
location: suite.location,
duration: 0,
parent: parentGroup,
children: [],
status: "none",
hasLoadErrors: false
};
this._addChild(parentGroup, group);
}
visitSuite(project, suite, group);
}
for (const test of parentSuite.tests) {
const title = test.title;
let testCaseItem = parentGroup.children.find((t) => t.kind !== "group" && t.title === title);
if (!testCaseItem) {
testCaseItem = {
kind: "case",
id: "test:" + test.titlePath().join(""),
title,
parent: parentGroup,
children: [],
tests: [],
location: test.location,
duration: 0,
status: "none",
project: void 0,
test: void 0,
tags: test.tags
};
this._addChild(parentGroup, testCaseItem);
}
const result = test.results[0];
let status = "none";
if (result?.[statusEx] === "scheduled")
status = "scheduled";
else if (result?.[statusEx] === "running")
status = "running";
else if (result?.status === "skipped")
status = "skipped";
else if (result?.status === "interrupted")
status = "none";
else if (result && test.outcome() !== "expected")
status = "failed";
else if (result && test.outcome() === "expected")
status = "passed";
testCaseItem.tests.push(test);
const testItem = {
kind: "test",
id: test.id,
title: project.name,
location: test.location,
test,
parent: testCaseItem,
children: [],
status,
duration: test.results.length ? Math.max(0, test.results[0].duration) : 0,
project
};
this._addChild(testCaseItem, testItem);
this._treeItemByTestId.set(test.id, testItem);
testCaseItem.duration = testCaseItem.children.reduce((a, b) => a + b.duration, 0);
}
};
for (const projectSuite of rootSuite?.suites || []) {
if (filterProjects && !projectFilters.get(projectSuite.title))
continue;
for (const fileSuite of projectSuite.suites) {
const fileItem = this._fileItem(fileSuite.location.file.split(pathSeparator), true);
visitSuite(projectSuite.project(), fileSuite, fileItem);
}
}
for (const loadError of loadErrors) {
if (!loadError.location)
continue;
const fileItem = this._fileItem(loadError.location.file.split(pathSeparator), true);
fileItem.hasLoadErrors = true;
}
}
_addChild(parent, child) {
parent.children.push(child);
child.parent = parent;
this._treeItemById.set(child.id, child);
}
filterTree(filterText, statusFilters, runningTestIds) {
const tokens = filterText.trim().toLowerCase().split(" ");
const filtersStatuses = [...statusFilters.values()].some(Boolean);
const filter = (testCase) => {
const titleWithTags = [...testCase.tests[0].titlePath(), ...testCase.tests[0].tags].join(" ").toLowerCase();
if (!tokens.every((token) => titleWithTags.includes(token)) && !testCase.tests.some((t) => runningTestIds?.has(t.id)))
return false;
testCase.children = testCase.children.filter((test) => {
return !filtersStatuses || runningTestIds?.has(test.test.id) || statusFilters.get(test.status);
});
testCase.tests = testCase.children.map((c) => c.test);
return !!testCase.children.length;
};
const visit = (treeItem) => {
const newChildren = [];
for (const child of treeItem.children) {
if (child.kind === "case") {
if (filter(child))
newChildren.push(child);
} else {
visit(child);
if (child.children.length || child.hasLoadErrors)
newChildren.push(child);
}
}
treeItem.children = newChildren;
};
visit(this.rootItem);
}
_fileItem(filePath, isFile) {
if (filePath.length === 0)
return this.rootItem;
const fileName = filePath.join(this.pathSeparator);
const existingFileItem = this._treeItemById.get(fileName);
if (existingFileItem)
return existingFileItem;
const parentFileItem = this._fileItem(filePath.slice(0, filePath.length - 1), false);
const fileItem = {
kind: "group",
subKind: isFile ? "file" : "folder",
id: fileName,
title: filePath[filePath.length - 1],
location: { file: fileName, line: 0, column: 0 },
duration: 0,
parent: parentFileItem,
children: [],
status: "none",
hasLoadErrors: false
};
this._addChild(parentFileItem, fileItem);
return fileItem;
}
sortAndPropagateStatus() {
sortAndPropagateStatus(this.rootItem);
}
flattenForSingleProject() {
const visit = (treeItem) => {
if (treeItem.kind === "case" && treeItem.children.length === 1) {
treeItem.project = treeItem.children[0].project;
treeItem.test = treeItem.children[0].test;
treeItem.children = [];
this._treeItemByTestId.set(treeItem.test.id, treeItem);
} else {
treeItem.children.forEach(visit);
}
};
visit(this.rootItem);
}
shortenRoot() {
let shortRoot = this.rootItem;
while (shortRoot.children.length === 1 && shortRoot.children[0].kind === "group" && shortRoot.children[0].subKind === "folder")
shortRoot = shortRoot.children[0];
shortRoot.location = this.rootItem.location;
this.rootItem = shortRoot;
}
testIds() {
const result = /* @__PURE__ */ new Set();
const visit = (treeItem) => {
if (treeItem.kind === "case")
treeItem.tests.forEach((t) => result.add(t.id));
treeItem.children.forEach(visit);
};
visit(this.rootItem);
return result;
}
fileNames() {
const result = /* @__PURE__ */ new Set();
const visit = (treeItem) => {
if (treeItem.kind === "group" && treeItem.subKind === "file")
result.add(treeItem.id);
else
treeItem.children.forEach(visit);
};
visit(this.rootItem);
return [...result];
}
flatTreeItems() {
const result = [];
const visit = (treeItem) => {
result.push(treeItem);
treeItem.children.forEach(visit);
};
visit(this.rootItem);
return result;
}
treeItemById(id) {
return this._treeItemById.get(id);
}
collectTestIds(treeItem) {
return treeItem ? collectTestIds(treeItem) : /* @__PURE__ */ new Set();
}
}
function sortAndPropagateStatus(treeItem) {
for (const child of treeItem.children)
sortAndPropagateStatus(child);
if (treeItem.kind === "group") {
treeItem.children.sort((a, b) => {
const fc = a.location.file.localeCompare(b.location.file);
return fc || a.location.line - b.location.line;
});
}
let allPassed = treeItem.children.length > 0;
let allSkipped = treeItem.children.length > 0;
let hasFailed = false;
let hasRunning = false;
let hasScheduled = false;
for (const child of treeItem.children) {
allSkipped = allSkipped && child.status === "skipped";
allPassed = allPassed && (child.status === "passed" || child.status === "skipped");
hasFailed = hasFailed || child.status === "failed";
hasRunning = hasRunning || child.status === "running";
hasScheduled = hasScheduled || child.status === "scheduled";
}
if (hasRunning)
treeItem.status = "running";
else if (hasScheduled)
treeItem.status = "scheduled";
else if (hasFailed)
treeItem.status = "failed";
else if (allSkipped)
treeItem.status = "skipped";
else if (allPassed)
treeItem.status = "passed";
}
function collectTestIds(treeItem) {
const testIds = /* @__PURE__ */ new Set();
const visit = (treeItem2) => {
if (treeItem2.kind === "case")
treeItem2.tests.map((t) => t.id).forEach((id) => testIds.add(id));
else if (treeItem2.kind === "test")
testIds.add(treeItem2.id);
else
treeItem2.children?.forEach(visit);
};
visit(treeItem);
return testIds;
}
const statusEx = Symbol("statusEx");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TestTree,
collectTestIds,
sortAndPropagateStatus,
statusEx
});

16
node_modules/playwright/lib/isomorphic/types.d.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var types_d_exports = {};
module.exports = __toCommonJS(types_d_exports);

59
node_modules/playwright/lib/loader/loaderMain.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var loaderMain_exports = {};
__export(loaderMain_exports, {
LoaderMain: () => LoaderMain,
create: () => create
});
module.exports = __toCommonJS(loaderMain_exports);
var import_configLoader = require("../common/configLoader");
var import_esmLoaderHost = require("../common/esmLoaderHost");
var import_poolBuilder = require("../common/poolBuilder");
var import_process = require("../common/process");
var import_testLoader = require("../common/testLoader");
var import_compilationCache = require("../transform/compilationCache");
class LoaderMain extends import_process.ProcessRunner {
constructor(serializedConfig) {
super();
this._poolBuilder = import_poolBuilder.PoolBuilder.createForLoader();
this._serializedConfig = serializedConfig;
}
_config() {
if (!this._configPromise)
this._configPromise = (0, import_configLoader.deserializeConfig)(this._serializedConfig);
return this._configPromise;
}
async loadTestFile(params) {
const testErrors = [];
const config = await this._config();
const fileSuite = await (0, import_testLoader.loadTestFile)(params.file, config.config.rootDir, testErrors);
this._poolBuilder.buildPools(fileSuite);
return { fileSuite: fileSuite._deepSerialize(), testErrors };
}
async getCompilationCacheFromLoader() {
await (0, import_esmLoaderHost.incorporateCompilationCache)();
return (0, import_compilationCache.serializeCompilationCache)();
}
}
const create = (config) => new LoaderMain(config);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
LoaderMain,
create
});

338
node_modules/playwright/lib/matchers/expect.js generated vendored Normal file
View File

@@ -0,0 +1,338 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var expect_exports = {};
__export(expect_exports, {
expect: () => expect,
mergeExpects: () => mergeExpects,
printReceivedStringContainExpectedResult: () => printReceivedStringContainExpectedResult,
printReceivedStringContainExpectedSubstring: () => printReceivedStringContainExpectedSubstring
});
module.exports = __toCommonJS(expect_exports);
var import_utils = require("playwright-core/lib/utils");
var import_matcherHint = require("./matcherHint");
var import_matchers = require("./matchers");
var import_toMatchAriaSnapshot = require("./toMatchAriaSnapshot");
var import_toMatchSnapshot = require("./toMatchSnapshot");
var import_expectBundle = require("../common/expectBundle");
var import_globals = require("../common/globals");
var import_util = require("../util");
var import_testInfo = require("../worker/testInfo");
const printSubstring = (val) => val.replace(/"|\\/g, "\\$&");
const printReceivedStringContainExpectedSubstring = (received, start, length) => (0, import_expectBundle.RECEIVED_COLOR)(
'"' + printSubstring(received.slice(0, start)) + (0, import_expectBundle.INVERTED_COLOR)(printSubstring(received.slice(start, start + length))) + printSubstring(received.slice(start + length)) + '"'
);
const printReceivedStringContainExpectedResult = (received, result) => result === null ? (0, import_expectBundle.printReceived)(received) : printReceivedStringContainExpectedSubstring(
received,
result.index,
result[0].length
);
function createMatchers(actual, info, prefix) {
return new Proxy((0, import_expectBundle.expect)(actual), new ExpectMetaInfoProxyHandler(info, prefix));
}
const userMatchersSymbol = Symbol("userMatchers");
function qualifiedMatcherName(qualifier, matcherName) {
return qualifier.join(":") + "$" + matcherName;
}
function createExpect(info, prefix, userMatchers) {
const expectInstance = new Proxy(import_expectBundle.expect, {
apply: function(target, thisArg, argumentsList) {
const [actual, messageOrOptions] = argumentsList;
const message = (0, import_utils.isString)(messageOrOptions) ? messageOrOptions : messageOrOptions?.message || info.message;
const newInfo = { ...info, message };
if (newInfo.poll) {
if (typeof actual !== "function")
throw new Error("`expect.poll()` accepts only function as a first argument");
newInfo.poll.generator = actual;
}
return createMatchers(actual, newInfo, prefix);
},
get: function(target, property) {
if (property === "configure")
return configure;
if (property === "extend") {
return (matchers) => {
const qualifier = [...prefix, (0, import_utils.createGuid)()];
const wrappedMatchers = {};
for (const [name, matcher] of Object.entries(matchers)) {
wrappedMatchers[name] = wrapPlaywrightMatcherToPassNiceThis(matcher);
const key = qualifiedMatcherName(qualifier, name);
wrappedMatchers[key] = wrappedMatchers[name];
Object.defineProperty(wrappedMatchers[key], "name", { value: name });
}
import_expectBundle.expect.extend(wrappedMatchers);
return createExpect(info, qualifier, { ...userMatchers, ...matchers });
};
}
if (property === "soft") {
return (actual, messageOrOptions) => {
return configure({ soft: true })(actual, messageOrOptions);
};
}
if (property === userMatchersSymbol)
return userMatchers;
if (property === "poll") {
return (actual, messageOrOptions) => {
const poll = (0, import_utils.isString)(messageOrOptions) ? {} : messageOrOptions || {};
return configure({ _poll: poll })(actual, messageOrOptions);
};
}
return import_expectBundle.expect[property];
}
});
const configure = (configuration) => {
const newInfo = { ...info };
if ("message" in configuration)
newInfo.message = configuration.message;
if ("timeout" in configuration)
newInfo.timeout = configuration.timeout;
if ("soft" in configuration)
newInfo.isSoft = configuration.soft;
if ("_poll" in configuration) {
newInfo.poll = configuration._poll ? { ...info.poll, generator: () => {
} } : void 0;
if (typeof configuration._poll === "object") {
newInfo.poll.timeout = configuration._poll.timeout ?? newInfo.poll.timeout;
newInfo.poll.intervals = configuration._poll.intervals ?? newInfo.poll.intervals;
}
}
return createExpect(newInfo, prefix, userMatchers);
};
return expectInstance;
}
let matcherCallContext;
function setMatcherCallContext(context) {
matcherCallContext = context;
}
function takeMatcherCallContext() {
try {
return matcherCallContext;
} finally {
matcherCallContext = void 0;
}
}
const defaultExpectTimeout = 5e3;
function wrapPlaywrightMatcherToPassNiceThis(matcher) {
return function(...args) {
const { isNot, promise, utils } = this;
const context = takeMatcherCallContext();
const timeout = context?.expectInfo.timeout ?? context?.testInfo?._projectInternal?.expect?.timeout ?? defaultExpectTimeout;
const newThis = {
isNot,
promise,
utils,
timeout,
_stepInfo: context?.step
};
newThis.equals = throwUnsupportedExpectMatcherError;
return matcher.call(newThis, ...args);
};
}
function throwUnsupportedExpectMatcherError() {
throw new Error("It looks like you are using custom expect matchers that are not compatible with Playwright. See https://aka.ms/playwright/expect-compatibility");
}
import_expectBundle.expect.setState({ expand: false });
const customAsyncMatchers = {
toBeAttached: import_matchers.toBeAttached,
toBeChecked: import_matchers.toBeChecked,
toBeDisabled: import_matchers.toBeDisabled,
toBeEditable: import_matchers.toBeEditable,
toBeEmpty: import_matchers.toBeEmpty,
toBeEnabled: import_matchers.toBeEnabled,
toBeFocused: import_matchers.toBeFocused,
toBeHidden: import_matchers.toBeHidden,
toBeInViewport: import_matchers.toBeInViewport,
toBeOK: import_matchers.toBeOK,
toBeVisible: import_matchers.toBeVisible,
toContainText: import_matchers.toContainText,
toContainClass: import_matchers.toContainClass,
toHaveAccessibleDescription: import_matchers.toHaveAccessibleDescription,
toHaveAccessibleName: import_matchers.toHaveAccessibleName,
toHaveAccessibleErrorMessage: import_matchers.toHaveAccessibleErrorMessage,
toHaveAttribute: import_matchers.toHaveAttribute,
toHaveClass: import_matchers.toHaveClass,
toHaveCount: import_matchers.toHaveCount,
toHaveCSS: import_matchers.toHaveCSS,
toHaveId: import_matchers.toHaveId,
toHaveJSProperty: import_matchers.toHaveJSProperty,
toHaveRole: import_matchers.toHaveRole,
toHaveText: import_matchers.toHaveText,
toHaveTitle: import_matchers.toHaveTitle,
toHaveURL: import_matchers.toHaveURL,
toHaveValue: import_matchers.toHaveValue,
toHaveValues: import_matchers.toHaveValues,
toHaveScreenshot: import_toMatchSnapshot.toHaveScreenshot,
toMatchAriaSnapshot: import_toMatchAriaSnapshot.toMatchAriaSnapshot,
toPass: import_matchers.toPass
};
const customMatchers = {
...customAsyncMatchers,
toMatchSnapshot: import_toMatchSnapshot.toMatchSnapshot
};
class ExpectMetaInfoProxyHandler {
constructor(info, prefix) {
this._info = { ...info };
this._prefix = prefix;
}
get(target, matcherName, receiver) {
let matcher = Reflect.get(target, matcherName, receiver);
if (typeof matcherName !== "string")
return matcher;
let resolvedMatcherName = matcherName;
for (let i = this._prefix.length; i > 0; i--) {
const qualifiedName = qualifiedMatcherName(this._prefix.slice(0, i), matcherName);
if (Reflect.has(target, qualifiedName)) {
matcher = Reflect.get(target, qualifiedName, receiver);
resolvedMatcherName = qualifiedName;
break;
}
}
if (matcher === void 0)
throw new Error(`expect: Property '${matcherName}' not found.`);
if (typeof matcher !== "function") {
if (matcherName === "not")
this._info.isNot = !this._info.isNot;
return new Proxy(matcher, this);
}
if (this._info.poll) {
if (customAsyncMatchers[matcherName] || matcherName === "resolves" || matcherName === "rejects")
throw new Error(`\`expect.poll()\` does not support "${matcherName}" matcher.`);
matcher = (...args) => pollMatcher(resolvedMatcherName, this._info, this._prefix, ...args);
}
return (...args) => {
const testInfo = (0, import_globals.currentTestInfo)();
setMatcherCallContext({ expectInfo: this._info, testInfo });
if (!testInfo)
return matcher.call(target, ...args);
const customMessage = this._info.message || "";
const argsSuffix = computeArgsSuffix(matcherName, args);
const defaultTitle = `${this._info.poll ? "poll " : ""}${this._info.isSoft ? "soft " : ""}${this._info.isNot ? "not " : ""}${matcherName}${argsSuffix}`;
const title = customMessage || `Expect ${(0, import_utils.escapeWithQuotes)(defaultTitle, '"')}`;
const apiName = `expect${this._info.poll ? ".poll " : ""}${this._info.isSoft ? ".soft " : ""}${this._info.isNot ? ".not" : ""}.${matcherName}${argsSuffix}`;
const stackFrames = (0, import_util.filteredStackTrace)((0, import_utils.captureRawStack)());
const category = matcherName === "toPass" || this._info.poll ? "test.step" : "expect";
const stepInfo = {
category,
apiName,
title,
params: args[0] ? { expected: args[0] } : void 0,
infectParentStepsWithError: this._info.isSoft
};
const step = testInfo._addStep(stepInfo);
const reportStepError = (isAsync, e) => {
const jestError = (0, import_matcherHint.isJestError)(e) ? e : null;
const expectError = jestError ? new import_matcherHint.ExpectError(jestError, customMessage, stackFrames) : void 0;
if (jestError?.matcherResult.suggestedRebaseline) {
step.complete({ suggestedRebaseline: jestError?.matcherResult.suggestedRebaseline });
return;
}
const error = expectError ?? e;
step.complete({ error });
if (!isAsync || !expectError) {
if (this._info.isSoft)
testInfo._failWithError(error);
else
throw error;
return;
}
return (async () => {
const recoveryResult = await step.recoverFromStepError(expectError);
if (recoveryResult.status === "recovered")
return recoveryResult.value;
if (this._info.isSoft)
testInfo._failWithError(expectError);
else
throw expectError;
})();
};
const finalizer = () => {
step.complete({});
};
try {
setMatcherCallContext({ expectInfo: this._info, testInfo, step: step.info });
const callback = () => matcher.call(target, ...args);
const result = (0, import_utils.currentZone)().with("stepZone", step).run(callback);
if (result instanceof Promise)
return result.then(finalizer).catch(reportStepError.bind(null, true));
finalizer();
return result;
} catch (e) {
void reportStepError(false, e);
}
};
}
}
async function pollMatcher(qualifiedMatcherName2, info, prefix, ...args) {
const testInfo = (0, import_globals.currentTestInfo)();
const poll = info.poll;
const timeout = poll.timeout ?? info.timeout ?? testInfo?._projectInternal?.expect?.timeout ?? defaultExpectTimeout;
const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : import_testInfo.TestInfoImpl._defaultDeadlineForMatcher(timeout);
const result = await (0, import_utils.pollAgainstDeadline)(async () => {
if (testInfo && (0, import_globals.currentTestInfo)() !== testInfo)
return { continuePolling: false, result: void 0 };
const innerInfo = {
...info,
isSoft: false,
// soft is outside of poll, not inside
poll: void 0
};
const value = await poll.generator();
try {
let matchers = createMatchers(value, innerInfo, prefix);
if (info.isNot)
matchers = matchers.not;
matchers[qualifiedMatcherName2](...args);
return { continuePolling: false, result: void 0 };
} catch (error) {
return { continuePolling: true, result: error };
}
}, deadline, poll.intervals ?? [100, 250, 500, 1e3]);
if (result.timedOut) {
const message = result.result ? [
result.result.message,
"",
`Call Log:`,
`- ${timeoutMessage}`
].join("\n") : timeoutMessage;
throw new Error(message);
}
}
function computeArgsSuffix(matcherName, args) {
let value = "";
if (matcherName === "toHaveScreenshot")
value = (0, import_toMatchSnapshot.toHaveScreenshotStepTitle)(...args);
return value ? `(${value})` : "";
}
const expect = createExpect({}, [], {}).extend(customMatchers);
function mergeExpects(...expects) {
let merged = expect;
for (const e of expects) {
const internals = e[userMatchersSymbol];
if (!internals)
continue;
merged = merged.extend(internals);
}
return merged;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
expect,
mergeExpects,
printReceivedStringContainExpectedResult,
printReceivedStringContainExpectedSubstring
});

63
node_modules/playwright/lib/matchers/matcherHint.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var matcherHint_exports = {};
__export(matcherHint_exports, {
ExpectError: () => ExpectError,
isJestError: () => isJestError,
kNoElementsFoundError: () => kNoElementsFoundError,
matcherHint: () => matcherHint
});
module.exports = __toCommonJS(matcherHint_exports);
var import_utils = require("playwright-core/lib/utils");
const kNoElementsFoundError = "<element(s) not found>";
function matcherHint(state, locator, matcherName, expression, actual, matcherOptions, timeout, expectedReceivedString, preventExtraStatIndent = false) {
let header = state.utils.matcherHint(matcherName, expression, actual, matcherOptions).replace(/ \/\/ deep equality/, "") + " failed\n\n";
const extraSpace = preventExtraStatIndent ? "" : " ";
if (locator)
header += `Locator: ${extraSpace}${String(locator)}
`;
if (expectedReceivedString)
header += `${expectedReceivedString}
`;
if (timeout)
header += `Timeout: ${extraSpace}${timeout}ms
`;
return header;
}
class ExpectError extends Error {
constructor(jestError, customMessage, stackFrames) {
super("");
this.name = jestError.name;
this.message = jestError.message;
this.matcherResult = jestError.matcherResult;
if (customMessage)
this.message = customMessage + "\n\n" + this.message;
this.stack = this.name + ": " + this.message + "\n" + (0, import_utils.stringifyStackFrames)(stackFrames).join("\n");
}
}
function isJestError(e) {
return e instanceof Error && "matcherResult" in e;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ExpectError,
isJestError,
kNoElementsFoundError,
matcherHint
});

360
node_modules/playwright/lib/matchers/matchers.js generated vendored Normal file
View File

@@ -0,0 +1,360 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var matchers_exports = {};
__export(matchers_exports, {
toBeAttached: () => toBeAttached,
toBeChecked: () => toBeChecked,
toBeDisabled: () => toBeDisabled,
toBeEditable: () => toBeEditable,
toBeEmpty: () => toBeEmpty,
toBeEnabled: () => toBeEnabled,
toBeFocused: () => toBeFocused,
toBeHidden: () => toBeHidden,
toBeInViewport: () => toBeInViewport,
toBeOK: () => toBeOK,
toBeVisible: () => toBeVisible,
toContainClass: () => toContainClass,
toContainText: () => toContainText,
toHaveAccessibleDescription: () => toHaveAccessibleDescription,
toHaveAccessibleErrorMessage: () => toHaveAccessibleErrorMessage,
toHaveAccessibleName: () => toHaveAccessibleName,
toHaveAttribute: () => toHaveAttribute,
toHaveCSS: () => toHaveCSS,
toHaveClass: () => toHaveClass,
toHaveCount: () => toHaveCount,
toHaveId: () => toHaveId,
toHaveJSProperty: () => toHaveJSProperty,
toHaveRole: () => toHaveRole,
toHaveText: () => toHaveText,
toHaveTitle: () => toHaveTitle,
toHaveURL: () => toHaveURL,
toHaveValue: () => toHaveValue,
toHaveValues: () => toHaveValues,
toPass: () => toPass
});
module.exports = __toCommonJS(matchers_exports);
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_util = require("../util");
var import_toBeTruthy = require("./toBeTruthy");
var import_toEqual = require("./toEqual");
var import_toHaveURL = require("./toHaveURL");
var import_toMatchText = require("./toMatchText");
var import_config = require("../common/config");
var import_globals = require("../common/globals");
var import_testInfo = require("../worker/testInfo");
function toBeAttached(locator, options) {
const attached = !options || options.attached === void 0 || options.attached;
const expected = attached ? "attached" : "detached";
const arg = attached ? "" : "{ attached: false }";
return import_toBeTruthy.toBeTruthy.call(this, "toBeAttached", locator, "Locator", expected, arg, async (isNot, timeout) => {
return await locator._expect(attached ? "to.be.attached" : "to.be.detached", { isNot, timeout });
}, options);
}
function toBeChecked(locator, options) {
const checked = options?.checked;
const indeterminate = options?.indeterminate;
const expectedValue = {
checked,
indeterminate
};
let expected;
let arg;
if (options?.indeterminate) {
expected = "indeterminate";
arg = `{ indeterminate: true }`;
} else {
expected = options?.checked === false ? "unchecked" : "checked";
arg = options?.checked === false ? `{ checked: false }` : "";
}
return import_toBeTruthy.toBeTruthy.call(this, "toBeChecked", locator, "Locator", expected, arg, async (isNot, timeout) => {
return await locator._expect("to.be.checked", { isNot, timeout, expectedValue });
}, options);
}
function toBeDisabled(locator, options) {
return import_toBeTruthy.toBeTruthy.call(this, "toBeDisabled", locator, "Locator", "disabled", "", async (isNot, timeout) => {
return await locator._expect("to.be.disabled", { isNot, timeout });
}, options);
}
function toBeEditable(locator, options) {
const editable = !options || options.editable === void 0 || options.editable;
const expected = editable ? "editable" : "readOnly";
const arg = editable ? "" : "{ editable: false }";
return import_toBeTruthy.toBeTruthy.call(this, "toBeEditable", locator, "Locator", expected, arg, async (isNot, timeout) => {
return await locator._expect(editable ? "to.be.editable" : "to.be.readonly", { isNot, timeout });
}, options);
}
function toBeEmpty(locator, options) {
return import_toBeTruthy.toBeTruthy.call(this, "toBeEmpty", locator, "Locator", "empty", "", async (isNot, timeout) => {
return await locator._expect("to.be.empty", { isNot, timeout });
}, options);
}
function toBeEnabled(locator, options) {
const enabled = !options || options.enabled === void 0 || options.enabled;
const expected = enabled ? "enabled" : "disabled";
const arg = enabled ? "" : "{ enabled: false }";
return import_toBeTruthy.toBeTruthy.call(this, "toBeEnabled", locator, "Locator", expected, arg, async (isNot, timeout) => {
return await locator._expect(enabled ? "to.be.enabled" : "to.be.disabled", { isNot, timeout });
}, options);
}
function toBeFocused(locator, options) {
return import_toBeTruthy.toBeTruthy.call(this, "toBeFocused", locator, "Locator", "focused", "", async (isNot, timeout) => {
return await locator._expect("to.be.focused", { isNot, timeout });
}, options);
}
function toBeHidden(locator, options) {
return import_toBeTruthy.toBeTruthy.call(this, "toBeHidden", locator, "Locator", "hidden", "", async (isNot, timeout) => {
return await locator._expect("to.be.hidden", { isNot, timeout });
}, options);
}
function toBeVisible(locator, options) {
const visible = !options || options.visible === void 0 || options.visible;
const expected = visible ? "visible" : "hidden";
const arg = visible ? "" : "{ visible: false }";
return import_toBeTruthy.toBeTruthy.call(this, "toBeVisible", locator, "Locator", expected, arg, async (isNot, timeout) => {
return await locator._expect(visible ? "to.be.visible" : "to.be.hidden", { isNot, timeout });
}, options);
}
function toBeInViewport(locator, options) {
return import_toBeTruthy.toBeTruthy.call(this, "toBeInViewport", locator, "Locator", "in viewport", "", async (isNot, timeout) => {
return await locator._expect("to.be.in.viewport", { isNot, expectedNumber: options?.ratio, timeout });
}, options);
}
function toContainText(locator, expected, options = {}) {
if (Array.isArray(expected)) {
return import_toEqual.toEqual.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
return await locator._expect("to.contain.text.array", { expectedText, isNot, useInnerText: options.useInnerText, timeout });
}, expected, { ...options, contains: true });
} else {
return import_toMatchText.toMatchText.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options.useInnerText, timeout });
}, expected, options);
}
}
function toHaveAccessibleDescription(locator, expected, options) {
return import_toMatchText.toMatchText.call(this, "toHaveAccessibleDescription", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
return await locator._expect("to.have.accessible.description", { expectedText, isNot, timeout });
}, expected, options);
}
function toHaveAccessibleName(locator, expected, options) {
return import_toMatchText.toMatchText.call(this, "toHaveAccessibleName", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
return await locator._expect("to.have.accessible.name", { expectedText, isNot, timeout });
}, expected, options);
}
function toHaveAccessibleErrorMessage(locator, expected, options) {
return import_toMatchText.toMatchText.call(this, "toHaveAccessibleErrorMessage", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
return await locator._expect("to.have.accessible.error.message", { expectedText, isNot, timeout });
}, expected, options);
}
function toHaveAttribute(locator, name, expected, options) {
if (!options) {
if (typeof expected === "object" && !(0, import_utils.isRegExp)(expected)) {
options = expected;
expected = void 0;
}
}
if (expected === void 0) {
return import_toBeTruthy.toBeTruthy.call(this, "toHaveAttribute", locator, "Locator", "have attribute", "", async (isNot, timeout) => {
return await locator._expect("to.have.attribute", { expressionArg: name, isNot, timeout });
}, options);
}
return import_toMatchText.toMatchText.call(this, "toHaveAttribute", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase });
return await locator._expect("to.have.attribute.value", { expressionArg: name, expectedText, isNot, timeout });
}, expected, options);
}
function toHaveClass(locator, expected, options) {
if (Array.isArray(expected)) {
return import_toEqual.toEqual.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
return await locator._expect("to.have.class.array", { expectedText, isNot, timeout });
}, expected, options, true);
} else {
return import_toMatchText.toMatchText.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
return await locator._expect("to.have.class", { expectedText, isNot, timeout });
}, expected, options);
}
}
function toContainClass(locator, expected, options) {
if (Array.isArray(expected)) {
if (expected.some((e) => (0, import_utils.isRegExp)(e)))
throw new Error(`"expected" argument in toContainClass cannot contain RegExp values`);
return import_toEqual.toEqual.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
return await locator._expect("to.contain.class.array", { expectedText, isNot, timeout });
}, expected, options, true);
} else {
if ((0, import_utils.isRegExp)(expected))
throw new Error(`"expected" argument in toContainClass cannot be a RegExp value`);
return import_toMatchText.toMatchText.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
return await locator._expect("to.contain.class", { expectedText, isNot, timeout });
}, expected, options);
}
}
function toHaveCount(locator, expected, options) {
return import_toEqual.toEqual.call(this, "toHaveCount", locator, "Locator", async (isNot, timeout) => {
return await locator._expect("to.have.count", { expectedNumber: expected, isNot, timeout });
}, expected, options);
}
function toHaveCSS(locator, name, expected, options) {
return import_toMatchText.toMatchText.call(this, "toHaveCSS", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
return await locator._expect("to.have.css", { expressionArg: name, expectedText, isNot, timeout });
}, expected, options);
}
function toHaveId(locator, expected, options) {
return import_toMatchText.toMatchText.call(this, "toHaveId", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
return await locator._expect("to.have.id", { expectedText, isNot, timeout });
}, expected, options);
}
function toHaveJSProperty(locator, name, expected, options) {
return import_toEqual.toEqual.call(this, "toHaveJSProperty", locator, "Locator", async (isNot, timeout) => {
return await locator._expect("to.have.property", { expressionArg: name, expectedValue: expected, isNot, timeout });
}, expected, options);
}
function toHaveRole(locator, expected, options) {
if (!(0, import_utils.isString)(expected))
throw new Error(`"role" argument in toHaveRole must be a string`);
return import_toMatchText.toMatchText.call(this, "toHaveRole", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
return await locator._expect("to.have.role", { expectedText, isNot, timeout });
}, expected, options);
}
function toHaveText(locator, expected, options = {}) {
if (Array.isArray(expected)) {
return import_toEqual.toEqual.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
return await locator._expect("to.have.text.array", { expectedText, isNot, useInnerText: options?.useInnerText, timeout });
}, expected, options);
} else {
return import_toMatchText.toMatchText.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options?.useInnerText, timeout });
}, expected, options);
}
}
function toHaveValue(locator, expected, options) {
return import_toMatchText.toMatchText.call(this, "toHaveValue", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
return await locator._expect("to.have.value", { expectedText, isNot, timeout });
}, expected, options);
}
function toHaveValues(locator, expected, options) {
return import_toEqual.toEqual.call(this, "toHaveValues", locator, "Locator", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
return await locator._expect("to.have.values", { expectedText, isNot, timeout });
}, expected, options);
}
function toHaveTitle(page, expected, options = {}) {
return import_toMatchText.toMatchText.call(this, "toHaveTitle", page, "Page", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true });
return await page.mainFrame()._expect("to.have.title", { expectedText, isNot, timeout });
}, expected, { receiverLabel: "page", ...options });
}
function toHaveURL(page, expected, options) {
if (typeof expected === "function")
return import_toHaveURL.toHaveURLWithPredicate.call(this, page, expected, options);
const baseURL = page.context()._options.baseURL;
expected = typeof expected === "string" ? (0, import_utils.constructURLBasedOnBaseURL)(baseURL, expected) : expected;
return import_toMatchText.toMatchText.call(this, "toHaveURL", page, "Page", async (isNot, timeout) => {
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase });
return await page.mainFrame()._expect("to.have.url", { expectedText, isNot, timeout });
}, expected, { receiverLabel: "page", ...options });
}
async function toBeOK(response) {
const matcherName = "toBeOK";
(0, import_util.expectTypes)(response, ["APIResponse"], matcherName);
const contentType = response.headers()["content-type"];
const isTextEncoding = contentType && (0, import_utils.isTextualMimeType)(contentType);
const [log, text] = this.isNot === response.ok() ? await Promise.all([
response._fetchLog(),
isTextEncoding ? response.text() : null
]) : [];
const message = () => this.utils.matcherHint(matcherName, void 0, "", { isNot: this.isNot }) + (0, import_util.callLogText)(log) + (text === null ? "" : `
Response text:
${import_utils2.colors.dim(text?.substring(0, 1e3) || "")}`);
const pass = response.ok();
return { message, pass };
}
async function toPass(callback, options = {}) {
const testInfo = (0, import_globals.currentTestInfo)();
const timeout = (0, import_config.takeFirst)(options.timeout, testInfo?._projectInternal.expect?.toPass?.timeout, 0);
const intervals = (0, import_config.takeFirst)(options.intervals, testInfo?._projectInternal.expect?.toPass?.intervals, [100, 250, 500, 1e3]);
const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : import_testInfo.TestInfoImpl._defaultDeadlineForMatcher(timeout);
const result = await (0, import_utils.pollAgainstDeadline)(async () => {
if (testInfo && (0, import_globals.currentTestInfo)() !== testInfo)
return { continuePolling: false, result: void 0 };
try {
await callback();
return { continuePolling: !!this.isNot, result: void 0 };
} catch (e) {
return { continuePolling: !this.isNot, result: e };
}
}, deadline, intervals);
if (result.timedOut) {
const message = result.result ? [
result.result.message,
"",
`Call Log:`,
`- ${timeoutMessage}`
].join("\n") : timeoutMessage;
return { message: () => message, pass: !!this.isNot };
}
return { pass: !this.isNot, message: () => "" };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
toBeAttached,
toBeChecked,
toBeDisabled,
toBeEditable,
toBeEmpty,
toBeEnabled,
toBeFocused,
toBeHidden,
toBeInViewport,
toBeOK,
toBeVisible,
toContainClass,
toContainText,
toHaveAccessibleDescription,
toHaveAccessibleErrorMessage,
toHaveAccessibleName,
toHaveAttribute,
toHaveCSS,
toHaveClass,
toHaveCount,
toHaveId,
toHaveJSProperty,
toHaveRole,
toHaveText,
toHaveTitle,
toHaveURL,
toHaveValue,
toHaveValues,
toPass
});

71
node_modules/playwright/lib/matchers/toBeTruthy.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var toBeTruthy_exports = {};
__export(toBeTruthy_exports, {
toBeTruthy: () => toBeTruthy
});
module.exports = __toCommonJS(toBeTruthy_exports);
var import_util = require("../util");
var import_matcherHint = require("./matcherHint");
async function toBeTruthy(matcherName, receiver, receiverType, expected, arg, query, options = {}) {
(0, import_util.expectTypes)(receiver, [receiverType], matcherName);
const matcherOptions = {
isNot: this.isNot,
promise: this.promise
};
const timeout = options.timeout ?? this.timeout;
const { matches: pass, log, timedOut, received } = await query(!!this.isNot, timeout);
if (pass === !this.isNot) {
return {
name: matcherName,
message: () => "",
pass,
expected
};
}
const notFound = received === import_matcherHint.kNoElementsFoundError ? received : void 0;
let printedReceived;
let printedExpected;
if (pass) {
printedExpected = `Expected: not ${expected}`;
printedReceived = `Received: ${notFound ? import_matcherHint.kNoElementsFoundError : expected}`;
} else {
printedExpected = `Expected: ${expected}`;
printedReceived = `Received: ${notFound ? import_matcherHint.kNoElementsFoundError : received}`;
}
const message = () => {
const header = (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", arg, matcherOptions, timedOut ? timeout : void 0, `${printedExpected}
${printedReceived}`);
const logText = (0, import_util.callLogText)(log);
return `${header}${logText}`;
};
return {
message,
pass,
actual: received,
name: matcherName,
expected,
log,
timeout: timedOut ? timeout : void 0
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
toBeTruthy
});

94
node_modules/playwright/lib/matchers/toEqual.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var toEqual_exports = {};
__export(toEqual_exports, {
toEqual: () => toEqual
});
module.exports = __toCommonJS(toEqual_exports);
var import_utils = require("playwright-core/lib/utils");
var import_util = require("../util");
var import_matcherHint = require("./matcherHint");
const EXPECTED_LABEL = "Expected";
const RECEIVED_LABEL = "Received";
async function toEqual(matcherName, receiver, receiverType, query, expected, options = {}, messagePreventExtraStatIndent) {
(0, import_util.expectTypes)(receiver, [receiverType], matcherName);
const matcherOptions = {
comment: options.contains ? "" : "deep equality",
isNot: this.isNot,
promise: this.promise
};
const timeout = options.timeout ?? this.timeout;
const { matches: pass, received, log, timedOut } = await query(!!this.isNot, timeout);
if (pass === !this.isNot) {
return {
name: matcherName,
message: () => "",
pass,
expected
};
}
let printedReceived;
let printedExpected;
let printedDiff;
if (pass) {
printedExpected = `Expected: not ${this.utils.printExpected(expected)}`;
printedReceived = `Received: ${this.utils.printReceived(received)}`;
} else if (Array.isArray(expected) && Array.isArray(received)) {
const normalizedExpected = expected.map((exp, index) => {
const rec = received[index];
if ((0, import_utils.isRegExp)(exp))
return exp.test(rec) ? rec : exp;
return exp;
});
printedDiff = this.utils.printDiffOrStringify(
normalizedExpected,
received,
EXPECTED_LABEL,
RECEIVED_LABEL,
false
);
} else {
printedDiff = this.utils.printDiffOrStringify(
expected,
received,
EXPECTED_LABEL,
RECEIVED_LABEL,
false
);
}
const message = () => {
const details = printedDiff || `${printedExpected}
${printedReceived}`;
const header = (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", void 0, matcherOptions, timedOut ? timeout : void 0, details, messagePreventExtraStatIndent);
return `${header}${(0, import_util.callLogText)(log)}`;
};
return {
actual: received,
expected,
message,
name: matcherName,
pass,
log,
timeout: timedOut ? timeout : void 0
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
toEqual
});

117
node_modules/playwright/lib/matchers/toHaveURL.js generated vendored Normal file
View File

@@ -0,0 +1,117 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var toHaveURL_exports = {};
__export(toHaveURL_exports, {
toHaveURLWithPredicate: () => toHaveURLWithPredicate
});
module.exports = __toCommonJS(toHaveURL_exports);
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_expect = require("./expect");
var import_matcherHint = require("./matcherHint");
var import_expectBundle = require("../common/expectBundle");
async function toHaveURLWithPredicate(page, expected, options) {
const matcherName = "toHaveURL";
const expression = "page";
const matcherOptions = {
isNot: this.isNot,
promise: this.promise
};
if (typeof expected !== "function") {
throw new Error(
[
// Always display `expected` in expectation place
(0, import_matcherHint.matcherHint)(this, void 0, matcherName, expression, void 0, matcherOptions, void 0, void 0, true),
`${import_utils2.colors.bold("Matcher error")}: ${(0, import_expectBundle.EXPECTED_COLOR)("expected")} value must be a string, regular expression, or predicate`,
this.utils.printWithType("Expected", expected, this.utils.printExpected)
].join("\n\n")
);
}
const timeout = options?.timeout ?? this.timeout;
const baseURL = page.context()._options.baseURL;
let conditionSucceeded = false;
let lastCheckedURLString = void 0;
try {
await page.mainFrame().waitForURL(
(url) => {
lastCheckedURLString = url.toString();
if (options?.ignoreCase) {
return !this.isNot === (0, import_utils.urlMatches)(
baseURL?.toLocaleLowerCase(),
lastCheckedURLString.toLocaleLowerCase(),
expected
);
}
return !this.isNot === (0, import_utils.urlMatches)(baseURL, lastCheckedURLString, expected);
},
{ timeout }
);
conditionSucceeded = true;
} catch (e) {
conditionSucceeded = false;
}
if (conditionSucceeded)
return { name: matcherName, pass: !this.isNot, message: () => "" };
return {
name: matcherName,
pass: this.isNot,
message: () => toHaveURLMessage(
this,
matcherName,
expression,
expected,
lastCheckedURLString,
this.isNot,
true,
timeout
),
actual: lastCheckedURLString,
timeout
};
}
function toHaveURLMessage(state, matcherName, expression, expected, received, pass, didTimeout, timeout) {
const matcherOptions = {
isNot: state.isNot,
promise: state.promise
};
const receivedString = received || "";
const messagePrefix = (0, import_matcherHint.matcherHint)(state, void 0, matcherName, expression, void 0, matcherOptions, didTimeout ? timeout : void 0, void 0, true);
let printedReceived;
let printedExpected;
let printedDiff;
if (typeof expected === "function") {
printedExpected = `Expected predicate to ${!state.isNot ? "succeed" : "fail"}`;
printedReceived = `Received string: ${(0, import_expectBundle.printReceived)(receivedString)}`;
} else {
if (pass) {
printedExpected = `Expected pattern: not ${state.utils.printExpected(expected)}`;
const formattedReceived = (0, import_expect.printReceivedStringContainExpectedResult)(receivedString, null);
printedReceived = `Received string: ${formattedReceived}`;
} else {
const labelExpected = `Expected ${typeof expected === "string" ? "string" : "pattern"}`;
printedDiff = state.utils.printDiffOrStringify(expected, receivedString, labelExpected, "Received string", false);
}
}
const resultDetails = printedDiff ? printedDiff : printedExpected + "\n" + printedReceived;
return messagePrefix + resultDetails;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
toHaveURLWithPredicate
});

View File

@@ -0,0 +1,163 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var toMatchAriaSnapshot_exports = {};
__export(toMatchAriaSnapshot_exports, {
toMatchAriaSnapshot: () => toMatchAriaSnapshot
});
module.exports = __toCommonJS(toMatchAriaSnapshot_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_matcherHint = require("./matcherHint");
var import_expectBundle = require("../common/expectBundle");
var import_util = require("../util");
var import_expect = require("./expect");
var import_globals = require("../common/globals");
async function toMatchAriaSnapshot(receiver, expectedParam, options = {}) {
const matcherName = "toMatchAriaSnapshot";
const testInfo = (0, import_globals.currentTestInfo)();
if (!testInfo)
throw new Error(`toMatchAriaSnapshot() must be called during the test`);
if (testInfo._projectInternal.ignoreSnapshots)
return { pass: !this.isNot, message: () => "", name: "toMatchAriaSnapshot", expected: "" };
const updateSnapshots = testInfo.config.updateSnapshots;
const matcherOptions = {
isNot: this.isNot,
promise: this.promise
};
let expected;
let timeout;
let expectedPath;
if ((0, import_utils.isString)(expectedParam)) {
expected = expectedParam;
timeout = options.timeout ?? this.timeout;
} else {
const legacyPath = testInfo._resolveSnapshotPaths("aria", expectedParam?.name, "dontUpdateSnapshotIndex", ".yml").absoluteSnapshotPath;
expectedPath = testInfo._resolveSnapshotPaths("aria", expectedParam?.name, "updateSnapshotIndex").absoluteSnapshotPath;
if (!await (0, import_util.fileExistsAsync)(expectedPath) && await (0, import_util.fileExistsAsync)(legacyPath))
expectedPath = legacyPath;
expected = await import_fs.default.promises.readFile(expectedPath, "utf8").catch(() => "");
timeout = expectedParam?.timeout ?? this.timeout;
}
const generateMissingBaseline = updateSnapshots === "missing" && !expected;
if (generateMissingBaseline) {
if (this.isNot) {
const message2 = `Matchers using ".not" can't generate new baselines`;
return { pass: this.isNot, message: () => message2, name: "toMatchAriaSnapshot" };
} else {
expected = `- none "Generating new baseline"`;
}
}
expected = unshift(expected);
const { matches: pass, received, log, timedOut } = await receiver._expect("to.match.aria", { expectedValue: expected, isNot: this.isNot, timeout });
const typedReceived = received;
const matcherHintWithExpect = (expectedReceivedString) => {
return (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", void 0, matcherOptions, timedOut ? timeout : void 0, expectedReceivedString);
};
const notFound = typedReceived === import_matcherHint.kNoElementsFoundError;
if (notFound) {
return {
pass: this.isNot,
message: () => matcherHintWithExpect(`Expected: ${this.utils.printExpected(expected)}
Received: ${(0, import_expectBundle.EXPECTED_COLOR)("<element not found>")}`) + (0, import_util.callLogText)(log),
name: "toMatchAriaSnapshot",
expected
};
}
const receivedText = typedReceived.raw;
const message = () => {
if (pass) {
const receivedString = notFound ? receivedText : (0, import_expect.printReceivedStringContainExpectedSubstring)(receivedText, receivedText.indexOf(expected), expected.length);
const expectedReceivedString = `Expected: not ${this.utils.printExpected(expected)}
Received: ${receivedString}`;
return matcherHintWithExpect(expectedReceivedString) + (0, import_util.callLogText)(log);
} else {
const labelExpected = `Expected`;
const expectedReceivedString = notFound ? `${labelExpected}: ${this.utils.printExpected(expected)}
Received: ${receivedText}` : this.utils.printDiffOrStringify(expected, receivedText, labelExpected, "Received", false);
return matcherHintWithExpect(expectedReceivedString) + (0, import_util.callLogText)(log);
}
};
if (!this.isNot) {
if (updateSnapshots === "all" || updateSnapshots === "changed" && pass === this.isNot || generateMissingBaseline) {
if (expectedPath) {
await import_fs.default.promises.mkdir(import_path.default.dirname(expectedPath), { recursive: true });
await import_fs.default.promises.writeFile(expectedPath, typedReceived.regex, "utf8");
const relativePath = import_path.default.relative(process.cwd(), expectedPath);
if (updateSnapshots === "missing") {
const message2 = `A snapshot doesn't exist at ${relativePath}, writing actual.`;
testInfo._hasNonRetriableError = true;
testInfo._failWithError(new Error(message2));
} else {
const message2 = `A snapshot is generated at ${relativePath}.`;
console.log(message2);
}
return { pass: true, message: () => "", name: "toMatchAriaSnapshot" };
} else {
const suggestedRebaseline = `\`
${(0, import_utils.escapeTemplateString)(indent(typedReceived.regex, "{indent} "))}
{indent}\``;
if (updateSnapshots === "missing") {
const message2 = "A snapshot is not provided, generating new baseline.";
testInfo._hasNonRetriableError = true;
testInfo._failWithError(new Error(message2));
}
return { pass: false, message: () => "", name: "toMatchAriaSnapshot", suggestedRebaseline };
}
}
}
return {
name: matcherName,
expected,
message,
pass,
actual: received,
log,
timeout: timedOut ? timeout : void 0
};
}
function unshift(snapshot) {
const lines = snapshot.split("\n");
let whitespacePrefixLength = 100;
for (const line of lines) {
if (!line.trim())
continue;
const match = line.match(/^(\s*)/);
if (match && match[1].length < whitespacePrefixLength)
whitespacePrefixLength = match[1].length;
}
return lines.filter((t) => t.trim()).map((line) => line.substring(whitespacePrefixLength)).join("\n");
}
function indent(snapshot, indent2) {
return snapshot.split("\n").map((line) => indent2 + line).join("\n");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
toMatchAriaSnapshot
});

338
node_modules/playwright/lib/matchers/toMatchSnapshot.js generated vendored Normal file
View File

@@ -0,0 +1,338 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var toMatchSnapshot_exports = {};
__export(toMatchSnapshot_exports, {
toHaveScreenshot: () => toHaveScreenshot,
toHaveScreenshotStepTitle: () => toHaveScreenshotStepTitle,
toMatchSnapshot: () => toMatchSnapshot
});
module.exports = __toCommonJS(toMatchSnapshot_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_util = require("../util");
var import_matcherHint = require("./matcherHint");
var import_globals = require("../common/globals");
const NonConfigProperties = [
"clip",
"fullPage",
"mask",
"maskColor",
"omitBackground",
"timeout"
];
class SnapshotHelper {
constructor(testInfo, matcherName, locator, anonymousSnapshotExtension, configOptions, nameOrOptions, optOptions) {
let name;
if (Array.isArray(nameOrOptions) || typeof nameOrOptions === "string") {
name = nameOrOptions;
this.options = { ...optOptions };
} else {
const { name: nameFromOptions, ...options } = nameOrOptions;
this.options = options;
name = nameFromOptions;
}
this.name = Array.isArray(name) ? name.join(import_path.default.sep) : name || "";
const resolvedPaths = testInfo._resolveSnapshotPaths(matcherName === "toHaveScreenshot" ? "screenshot" : "snapshot", name, "updateSnapshotIndex", anonymousSnapshotExtension);
this.expectedPath = resolvedPaths.absoluteSnapshotPath;
this.attachmentBaseName = resolvedPaths.relativeOutputPath;
const outputBasePath = testInfo._getOutputPath(resolvedPaths.relativeOutputPath);
this.legacyExpectedPath = (0, import_util.addSuffixToFilePath)(outputBasePath, "-expected");
this.previousPath = (0, import_util.addSuffixToFilePath)(outputBasePath, "-previous");
this.actualPath = (0, import_util.addSuffixToFilePath)(outputBasePath, "-actual");
this.diffPath = (0, import_util.addSuffixToFilePath)(outputBasePath, "-diff");
const filteredConfigOptions = { ...configOptions };
for (const prop of NonConfigProperties)
delete filteredConfigOptions[prop];
this.options = {
...filteredConfigOptions,
...this.options
};
if (this.options._comparator) {
this.options.comparator = this.options._comparator;
delete this.options._comparator;
}
if (this.options.maxDiffPixels !== void 0 && this.options.maxDiffPixels < 0)
throw new Error("`maxDiffPixels` option value must be non-negative integer");
if (this.options.maxDiffPixelRatio !== void 0 && (this.options.maxDiffPixelRatio < 0 || this.options.maxDiffPixelRatio > 1))
throw new Error("`maxDiffPixelRatio` option value must be between 0 and 1");
this.matcherName = matcherName;
this.locator = locator;
this.updateSnapshots = testInfo.config.updateSnapshots;
this.mimeType = import_utilsBundle.mime.getType(import_path.default.basename(this.expectedPath)) ?? "application/octet-stream";
this.comparator = (0, import_utils.getComparator)(this.mimeType);
this.testInfo = testInfo;
this.kind = this.mimeType.startsWith("image/") ? "Screenshot" : "Snapshot";
}
createMatcherResult(message, pass, log) {
const unfiltered = {
name: this.matcherName,
expected: this.expectedPath,
actual: this.actualPath,
diff: this.diffPath,
pass,
message: () => message,
log
};
return Object.fromEntries(Object.entries(unfiltered).filter(([_, v]) => v !== void 0));
}
handleMissingNegated() {
const isWriteMissingMode = this.updateSnapshots !== "none";
const message = `A snapshot doesn't exist at ${this.expectedPath}${isWriteMissingMode ? `, matchers using ".not" won't write them automatically.` : "."}`;
return this.createMatcherResult(message, true);
}
handleDifferentNegated() {
return this.createMatcherResult("", false);
}
handleMatchingNegated() {
const message = [
import_utils2.colors.red(`${this.kind} comparison failed:`),
"",
indent("Expected result should be different from the actual one.", " ")
].join("\n");
return this.createMatcherResult(message, true);
}
handleMissing(actual, step) {
const isWriteMissingMode = this.updateSnapshots !== "none";
if (isWriteMissingMode)
writeFileSync(this.expectedPath, actual);
step?._attachToStep({ name: (0, import_util.addSuffixToFilePath)(this.attachmentBaseName, "-expected"), contentType: this.mimeType, path: this.expectedPath });
writeFileSync(this.actualPath, actual);
step?._attachToStep({ name: (0, import_util.addSuffixToFilePath)(this.attachmentBaseName, "-actual"), contentType: this.mimeType, path: this.actualPath });
const message = `A snapshot doesn't exist at ${this.expectedPath}${isWriteMissingMode ? ", writing actual." : "."}`;
if (this.updateSnapshots === "all" || this.updateSnapshots === "changed") {
console.log(message);
return this.createMatcherResult(message, true);
}
if (this.updateSnapshots === "missing") {
this.testInfo._hasNonRetriableError = true;
this.testInfo._failWithError(new Error(message));
return this.createMatcherResult("", true);
}
return this.createMatcherResult(message, false);
}
handleDifferent(actual, expected, previous, diff, header, diffError, log, step) {
const output = [`${header}${indent(diffError, " ")}`];
if (this.name) {
output.push("");
output.push(` Snapshot: ${this.name}`);
}
if (expected !== void 0) {
writeFileSync(this.legacyExpectedPath, expected);
step?._attachToStep({ name: (0, import_util.addSuffixToFilePath)(this.attachmentBaseName, "-expected"), contentType: this.mimeType, path: this.expectedPath });
}
if (previous !== void 0) {
writeFileSync(this.previousPath, previous);
step?._attachToStep({ name: (0, import_util.addSuffixToFilePath)(this.attachmentBaseName, "-previous"), contentType: this.mimeType, path: this.previousPath });
}
if (actual !== void 0) {
writeFileSync(this.actualPath, actual);
step?._attachToStep({ name: (0, import_util.addSuffixToFilePath)(this.attachmentBaseName, "-actual"), contentType: this.mimeType, path: this.actualPath });
}
if (diff !== void 0) {
writeFileSync(this.diffPath, diff);
step?._attachToStep({ name: (0, import_util.addSuffixToFilePath)(this.attachmentBaseName, "-diff"), contentType: this.mimeType, path: this.diffPath });
}
if (log?.length)
output.push((0, import_util.callLogText)(log));
else
output.push("");
return this.createMatcherResult(output.join("\n"), false, log);
}
handleMatching() {
return this.createMatcherResult("", true);
}
}
function toMatchSnapshot(received, nameOrOptions = {}, optOptions = {}) {
const testInfo = (0, import_globals.currentTestInfo)();
if (!testInfo)
throw new Error(`toMatchSnapshot() must be called during the test`);
if (received instanceof Promise)
throw new Error("An unresolved Promise was passed to toMatchSnapshot(), make sure to resolve it by adding await to it.");
if (testInfo._projectInternal.ignoreSnapshots)
return { pass: !this.isNot, message: () => "", name: "toMatchSnapshot", expected: nameOrOptions };
const configOptions = testInfo._projectInternal.expect?.toMatchSnapshot || {};
const helper = new SnapshotHelper(
testInfo,
"toMatchSnapshot",
void 0,
"." + determineFileExtension(received),
configOptions,
nameOrOptions,
optOptions
);
if (this.isNot) {
if (!import_fs.default.existsSync(helper.expectedPath))
return helper.handleMissingNegated();
const isDifferent = !!helper.comparator(received, import_fs.default.readFileSync(helper.expectedPath), helper.options);
return isDifferent ? helper.handleDifferentNegated() : helper.handleMatchingNegated();
}
if (!import_fs.default.existsSync(helper.expectedPath))
return helper.handleMissing(received, this._stepInfo);
const expected = import_fs.default.readFileSync(helper.expectedPath);
if (helper.updateSnapshots === "all") {
if (!(0, import_utils.compareBuffersOrStrings)(received, expected))
return helper.handleMatching();
writeFileSync(helper.expectedPath, received);
console.log(helper.expectedPath + " is not the same, writing actual.");
return helper.createMatcherResult(helper.expectedPath + " running with --update-snapshots, writing actual.", true);
}
if (helper.updateSnapshots === "changed") {
const result2 = helper.comparator(received, expected, helper.options);
if (!result2)
return helper.handleMatching();
writeFileSync(helper.expectedPath, received);
console.log(helper.expectedPath + " does not match, writing actual.");
return helper.createMatcherResult(helper.expectedPath + " running with --update-snapshots, writing actual.", true);
}
const result = helper.comparator(received, expected, helper.options);
if (!result)
return helper.handleMatching();
const receiver = (0, import_utils.isString)(received) ? "string" : "Buffer";
const header = (0, import_matcherHint.matcherHint)(this, void 0, "toMatchSnapshot", receiver, void 0, void 0, void 0);
return helper.handleDifferent(received, expected, void 0, result.diff, header, result.errorMessage, void 0, this._stepInfo);
}
function toHaveScreenshotStepTitle(nameOrOptions = {}, optOptions = {}) {
let name;
if (typeof nameOrOptions === "object" && !Array.isArray(nameOrOptions))
name = nameOrOptions.name;
else
name = nameOrOptions;
return Array.isArray(name) ? name.join(import_path.default.sep) : name || "";
}
async function toHaveScreenshot(pageOrLocator, nameOrOptions = {}, optOptions = {}) {
const testInfo = (0, import_globals.currentTestInfo)();
if (!testInfo)
throw new Error(`toHaveScreenshot() must be called during the test`);
if (testInfo._projectInternal.ignoreSnapshots)
return { pass: !this.isNot, message: () => "", name: "toHaveScreenshot", expected: nameOrOptions };
(0, import_util.expectTypes)(pageOrLocator, ["Page", "Locator"], "toHaveScreenshot");
const [page, locator] = pageOrLocator.constructor.name === "Page" ? [pageOrLocator, void 0] : [pageOrLocator.page(), pageOrLocator];
const configOptions = testInfo._projectInternal.expect?.toHaveScreenshot || {};
const helper = new SnapshotHelper(testInfo, "toHaveScreenshot", locator, void 0, configOptions, nameOrOptions, optOptions);
if (!helper.expectedPath.toLowerCase().endsWith(".png"))
throw new Error(`Screenshot name "${import_path.default.basename(helper.expectedPath)}" must have '.png' extension`);
(0, import_util.expectTypes)(pageOrLocator, ["Page", "Locator"], "toHaveScreenshot");
const style = await loadScreenshotStyles(helper.options.stylePath);
const timeout = helper.options.timeout ?? this.timeout;
const expectScreenshotOptions = {
locator,
animations: helper.options.animations ?? "disabled",
caret: helper.options.caret ?? "hide",
clip: helper.options.clip,
fullPage: helper.options.fullPage,
mask: helper.options.mask,
maskColor: helper.options.maskColor,
omitBackground: helper.options.omitBackground,
scale: helper.options.scale ?? "css",
style,
isNot: !!this.isNot,
timeout,
comparator: helper.options.comparator,
maxDiffPixels: helper.options.maxDiffPixels,
maxDiffPixelRatio: helper.options.maxDiffPixelRatio,
threshold: helper.options.threshold
};
const hasSnapshot = import_fs.default.existsSync(helper.expectedPath);
if (this.isNot) {
if (!hasSnapshot)
return helper.handleMissingNegated();
expectScreenshotOptions.expected = await import_fs.default.promises.readFile(helper.expectedPath);
const isDifferent = !(await page._expectScreenshot(expectScreenshotOptions)).errorMessage;
return isDifferent ? helper.handleDifferentNegated() : helper.handleMatchingNegated();
}
if (helper.updateSnapshots === "none" && !hasSnapshot)
return helper.createMatcherResult(`A snapshot doesn't exist at ${helper.expectedPath}.`, false);
const receiver = locator ? "locator" : "page";
if (!hasSnapshot) {
const { actual: actual2, previous: previous2, diff: diff2, errorMessage: errorMessage2, log: log2, timedOut: timedOut2 } = await page._expectScreenshot(expectScreenshotOptions);
if (errorMessage2) {
const header2 = (0, import_matcherHint.matcherHint)(this, locator, "toHaveScreenshot", receiver, void 0, void 0, timedOut2 ? timeout : void 0);
return helper.handleDifferent(actual2, void 0, previous2, diff2, header2, errorMessage2, log2, this._stepInfo);
}
return helper.handleMissing(actual2, this._stepInfo);
}
const expected = await import_fs.default.promises.readFile(helper.expectedPath);
expectScreenshotOptions.expected = helper.updateSnapshots === "all" ? void 0 : expected;
const { actual, previous, diff, errorMessage, log, timedOut } = await page._expectScreenshot(expectScreenshotOptions);
const writeFiles = () => {
writeFileSync(helper.expectedPath, actual);
writeFileSync(helper.actualPath, actual);
console.log(helper.expectedPath + " is re-generated, writing actual.");
return helper.createMatcherResult(helper.expectedPath + " running with --update-snapshots, writing actual.", true);
};
if (!errorMessage) {
if (helper.updateSnapshots === "all" && actual && (0, import_utils.compareBuffersOrStrings)(actual, expected)) {
console.log(helper.expectedPath + " is re-generated, writing actual.");
return writeFiles();
}
return helper.handleMatching();
}
if (helper.updateSnapshots === "changed" || helper.updateSnapshots === "all")
return writeFiles();
const header = (0, import_matcherHint.matcherHint)(this, void 0, "toHaveScreenshot", receiver, void 0, void 0, timedOut ? timeout : void 0);
return helper.handleDifferent(actual, expectScreenshotOptions.expected, previous, diff, header, errorMessage, log, this._stepInfo);
}
function writeFileSync(aPath, content) {
import_fs.default.mkdirSync(import_path.default.dirname(aPath), { recursive: true });
import_fs.default.writeFileSync(aPath, content);
}
function indent(lines, tab) {
return lines.replace(/^(?=.+$)/gm, tab);
}
function determineFileExtension(file) {
if (typeof file === "string")
return "txt";
if (compareMagicBytes(file, [137, 80, 78, 71, 13, 10, 26, 10]))
return "png";
if (compareMagicBytes(file, [255, 216, 255]))
return "jpg";
return "dat";
}
function compareMagicBytes(file, magicBytes) {
return Buffer.compare(Buffer.from(magicBytes), file.slice(0, magicBytes.length)) === 0;
}
async function loadScreenshotStyles(stylePath) {
if (!stylePath)
return;
const stylePaths = Array.isArray(stylePath) ? stylePath : [stylePath];
const styles = await Promise.all(stylePaths.map(async (stylePath2) => {
const text = await import_fs.default.promises.readFile(stylePath2, "utf8");
return text.trim();
}));
return styles.join("\n").trim() || void 0;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
toHaveScreenshot,
toHaveScreenshotStepTitle,
toMatchSnapshot
});

105
node_modules/playwright/lib/matchers/toMatchText.js generated vendored Normal file
View File

@@ -0,0 +1,105 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var toMatchText_exports = {};
__export(toMatchText_exports, {
toMatchText: () => toMatchText
});
module.exports = __toCommonJS(toMatchText_exports);
var import_utils = require("playwright-core/lib/utils");
var import_util = require("../util");
var import_expect = require("./expect");
var import_matcherHint = require("./matcherHint");
var import_expectBundle = require("../common/expectBundle");
async function toMatchText(matcherName, receiver, receiverType, query, expected, options = {}) {
(0, import_util.expectTypes)(receiver, [receiverType], matcherName);
const matcherOptions = {
isNot: this.isNot,
promise: this.promise
};
if (!(typeof expected === "string") && !(expected && typeof expected.test === "function")) {
throw new Error([
(0, import_matcherHint.matcherHint)(this, receiverType === "Locator" ? receiver : void 0, matcherName, options.receiverLabel ?? receiver, expected, matcherOptions, void 0, void 0, true),
`${import_utils.colors.bold("Matcher error")}: ${(0, import_expectBundle.EXPECTED_COLOR)("expected")} value must be a string or regular expression`,
this.utils.printWithType("Expected", expected, this.utils.printExpected)
].join("\n\n"));
}
const timeout = options.timeout ?? this.timeout;
const { matches: pass, received, log, timedOut } = await query(!!this.isNot, timeout);
if (pass === !this.isNot) {
return {
name: matcherName,
message: () => "",
pass,
expected
};
}
const stringSubstring = options.matchSubstring ? "substring" : "string";
const receivedString = received || "";
const notFound = received === import_matcherHint.kNoElementsFoundError;
let printedReceived;
let printedExpected;
let printedDiff;
if (pass) {
if (typeof expected === "string") {
if (notFound) {
printedExpected = `Expected ${stringSubstring}: not ${this.utils.printExpected(expected)}`;
printedReceived = `Received: ${received}`;
} else {
printedExpected = `Expected ${stringSubstring}: not ${this.utils.printExpected(expected)}`;
const formattedReceived = (0, import_expect.printReceivedStringContainExpectedSubstring)(receivedString, receivedString.indexOf(expected), expected.length);
printedReceived = `Received string: ${formattedReceived}`;
}
} else {
if (notFound) {
printedExpected = `Expected pattern: not ${this.utils.printExpected(expected)}`;
printedReceived = `Received: ${received}`;
} else {
printedExpected = `Expected pattern: not ${this.utils.printExpected(expected)}`;
const formattedReceived = (0, import_expect.printReceivedStringContainExpectedResult)(receivedString, typeof expected.exec === "function" ? expected.exec(receivedString) : null);
printedReceived = `Received string: ${formattedReceived}`;
}
}
} else {
const labelExpected = `Expected ${typeof expected === "string" ? stringSubstring : "pattern"}`;
if (notFound) {
printedExpected = `${labelExpected}: ${this.utils.printExpected(expected)}`;
printedReceived = `Received: ${received}`;
} else {
printedDiff = this.utils.printDiffOrStringify(expected, receivedString, labelExpected, "Received string", false);
}
}
const message = () => {
const resultDetails = printedDiff ? printedDiff : printedExpected + "\n" + printedReceived;
const hints = (0, import_matcherHint.matcherHint)(this, receiverType === "Locator" ? receiver : void 0, matcherName, options.receiverLabel ?? "locator", void 0, matcherOptions, timedOut ? timeout : void 0, resultDetails, true);
return hints + (0, import_util.callLogText)(log);
};
return {
name: matcherName,
expected,
message,
pass,
actual: received,
log,
timeout: timedOut ? timeout : void 0
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
toMatchText
});

59
node_modules/playwright/lib/mcp/bundle.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var bundle_exports = {};
__export(bundle_exports, {
CallToolRequestSchema: () => CallToolRequestSchema,
Client: () => Client,
ListRootsRequestSchema: () => ListRootsRequestSchema,
ListToolsRequestSchema: () => ListToolsRequestSchema,
PingRequestSchema: () => PingRequestSchema,
SSEServerTransport: () => SSEServerTransport,
Server: () => Server,
StdioServerTransport: () => StdioServerTransport,
StreamableHTTPServerTransport: () => StreamableHTTPServerTransport,
z: () => z,
zodToJsonSchema: () => zodToJsonSchema
});
module.exports = __toCommonJS(bundle_exports);
const bundle = require("./mcpBundleImpl");
const zodToJsonSchema = require("./mcpBundleImpl").zodToJsonSchema;
const Client = bundle.Client;
const Server = bundle.Server;
const SSEServerTransport = bundle.SSEServerTransport;
const StdioServerTransport = bundle.StdioServerTransport;
const StreamableHTTPServerTransport = bundle.StreamableHTTPServerTransport;
const CallToolRequestSchema = bundle.CallToolRequestSchema;
const ListRootsRequestSchema = bundle.ListRootsRequestSchema;
const ListToolsRequestSchema = bundle.ListToolsRequestSchema;
const PingRequestSchema = bundle.PingRequestSchema;
const z = bundle.z;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
CallToolRequestSchema,
Client,
ListRootsRequestSchema,
ListToolsRequestSchema,
PingRequestSchema,
SSEServerTransport,
Server,
StdioServerTransport,
StreamableHTTPServerTransport,
z,
zodToJsonSchema
});

30
node_modules/playwright/lib/mcp/exports.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var exports_exports = {};
module.exports = __toCommonJS(exports_exports);
__reExport(exports_exports, require("./inProcessTransport.js"), module.exports);
__reExport(exports_exports, require("./proxyBackend.js"), module.exports);
__reExport(exports_exports, require("./server.js"), module.exports);
__reExport(exports_exports, require("./tool.js"), module.exports);
__reExport(exports_exports, require("./transport.js"), module.exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
...require("./inProcessTransport.js"),
...require("./proxyBackend.js"),
...require("./server.js"),
...require("./tool.js"),
...require("./transport.js")
});

71
node_modules/playwright/lib/mcp/inProcessTransport.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var inProcessTransport_exports = {};
__export(inProcessTransport_exports, {
InProcessTransport: () => InProcessTransport
});
module.exports = __toCommonJS(inProcessTransport_exports);
class InProcessTransport {
constructor(server) {
this._connected = false;
this._server = server;
this._serverTransport = new InProcessServerTransport(this);
}
async start() {
if (this._connected)
throw new Error("InprocessTransport already started!");
await this._server.connect(this._serverTransport);
this._connected = true;
}
async send(message, options) {
if (!this._connected)
throw new Error("Transport not connected");
this._serverTransport._receiveFromClient(message);
}
async close() {
if (this._connected) {
this._connected = false;
this.onclose?.();
this._serverTransport.onclose?.();
}
}
_receiveFromServer(message, extra) {
this.onmessage?.(message, extra);
}
}
class InProcessServerTransport {
constructor(clientTransport) {
this._clientTransport = clientTransport;
}
async start() {
}
async send(message, options) {
this._clientTransport._receiveFromServer(message);
}
async close() {
this.onclose?.();
}
_receiveFromClient(message) {
this.onmessage?.(message);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
InProcessTransport
});

123
node_modules/playwright/lib/mcp/proxyBackend.js generated vendored Normal file
View File

@@ -0,0 +1,123 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var proxyBackend_exports = {};
__export(proxyBackend_exports, {
ProxyBackend: () => ProxyBackend
});
module.exports = __toCommonJS(proxyBackend_exports);
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var mcpBundle = __toESM(require("./bundle"));
const errorsDebug = (0, import_utilsBundle.debug)("pw:mcp:errors");
class ProxyBackend {
constructor(name, version, mcpProviders) {
this._roots = [];
this.name = name;
this.version = version;
this._mcpProviders = mcpProviders;
this._contextSwitchTool = this._defineContextSwitchTool();
}
async initialize(clientVersion, roots) {
this._roots = roots;
await this._setCurrentClient(this._mcpProviders[0]);
}
async listTools() {
const response = await this._currentClient.listTools();
if (this._mcpProviders.length === 1)
return response.tools;
return [
...response.tools,
this._contextSwitchTool
];
}
async callTool(name, args) {
if (name === this._contextSwitchTool.name)
return this._callContextSwitchTool(args);
return await this._currentClient.callTool({
name,
arguments: args
});
}
serverClosed() {
void this._currentClient?.close().catch(errorsDebug);
}
async _callContextSwitchTool(params) {
try {
const factory = this._mcpProviders.find((factory2) => factory2.name === params.name);
if (!factory)
throw new Error("Unknown connection method: " + params.name);
await this._setCurrentClient(factory);
return {
content: [{ type: "text", text: "### Result\nSuccessfully changed connection method.\n" }]
};
} catch (error) {
return {
content: [{ type: "text", text: `### Result
Error: ${error}
` }],
isError: true
};
}
}
_defineContextSwitchTool() {
return {
name: "browser_connect",
description: [
"Connect to a browser using one of the available methods:",
...this._mcpProviders.map((factory) => `- "${factory.name}": ${factory.description}`)
].join("\n"),
inputSchema: mcpBundle.zodToJsonSchema(mcpBundle.z.object({
name: mcpBundle.z.enum(this._mcpProviders.map((factory) => factory.name)).default(this._mcpProviders[0].name).describe("The method to use to connect to the browser")
}), { strictUnions: true }),
annotations: {
title: "Connect to a browser context",
readOnlyHint: true,
openWorldHint: false
}
};
}
async _setCurrentClient(factory) {
await this._currentClient?.close();
this._currentClient = void 0;
const client = new mcpBundle.Client({ name: this.name, version: this.version });
client.registerCapabilities({
roots: {
listRoots: true
}
});
client.setRequestHandler(mcpBundle.ListRootsRequestSchema, () => ({ roots: this._roots }));
client.setRequestHandler(mcpBundle.PingRequestSchema, () => ({}));
const transport = await factory.connect();
await client.connect(transport);
this._currentClient = client;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ProxyBackend
});

118
node_modules/playwright/lib/mcp/server.js generated vendored Normal file
View File

@@ -0,0 +1,118 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var server_exports = {};
__export(server_exports, {
connect: () => connect,
createServer: () => createServer
});
module.exports = __toCommonJS(server_exports);
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var mcpBundle = __toESM(require("./bundle"));
const serverDebug = (0, import_utilsBundle.debug)("pw:mcp:server");
const errorsDebug = (0, import_utilsBundle.debug)("pw:mcp:errors");
async function connect(serverBackendFactory, transport, runHeartbeat) {
const backend = serverBackendFactory();
const server = createServer(backend, runHeartbeat);
await server.connect(transport);
}
function createServer(backend, runHeartbeat) {
let initializedCallback = () => {
};
const initializedPromise = new Promise((resolve) => initializedCallback = resolve);
const server = new mcpBundle.Server({ name: backend.name, version: backend.version }, {
capabilities: {
tools: {}
}
});
server.setRequestHandler(mcpBundle.ListToolsRequestSchema, async () => {
serverDebug("listTools");
await initializedPromise;
const tools = await backend.listTools();
return { tools };
});
let heartbeatRunning = false;
server.setRequestHandler(mcpBundle.CallToolRequestSchema, async (request) => {
serverDebug("callTool", request);
await initializedPromise;
if (runHeartbeat && !heartbeatRunning) {
heartbeatRunning = true;
startHeartbeat(server);
}
try {
return await backend.callTool(request.params.name, request.params.arguments || {});
} catch (error) {
return {
content: [{ type: "text", text: "### Result\n" + String(error) }],
isError: true
};
}
});
addServerListener(server, "initialized", async () => {
try {
const capabilities = server.getClientCapabilities();
let clientRoots = [];
if (capabilities?.roots) {
const { roots } = await server.listRoots(void 0, { timeout: 2e3 }).catch(() => ({ roots: [] }));
clientRoots = roots;
}
const clientVersion = server.getClientVersion() ?? { name: "unknown", version: "unknown" };
await backend.initialize?.(clientVersion, clientRoots);
initializedCallback();
} catch (e) {
errorsDebug(e);
}
});
addServerListener(server, "close", () => backend.serverClosed?.());
return server;
}
const startHeartbeat = (server) => {
const beat = () => {
Promise.race([
server.ping(),
new Promise((_, reject) => setTimeout(() => reject(new Error("ping timeout")), 5e3))
]).then(() => {
setTimeout(beat, 3e3);
}).catch(() => {
void server.close();
});
};
beat();
};
function addServerListener(server, event, listener) {
const oldListener = server[`on${event}`];
server[`on${event}`] = () => {
oldListener?.();
listener();
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
connect,
createServer
});

41
node_modules/playwright/lib/mcp/tool.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var tool_exports = {};
__export(tool_exports, {
toMcpTool: () => toMcpTool
});
module.exports = __toCommonJS(tool_exports);
var import_bundle = require("./bundle");
function toMcpTool(tool) {
return {
name: tool.name,
description: tool.description,
inputSchema: (0, import_bundle.zodToJsonSchema)(tool.inputSchema, { strictUnions: true }),
annotations: {
title: tool.title,
readOnlyHint: tool.type === "readOnly",
destructiveHint: tool.type === "destructive",
openWorldHint: true
}
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
toMcpTool
});

161
node_modules/playwright/lib/mcp/transport.js generated vendored Normal file
View File

@@ -0,0 +1,161 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var transport_exports = {};
__export(transport_exports, {
start: () => start
});
module.exports = __toCommonJS(transport_exports);
var import_assert = __toESM(require("assert"));
var import_http = __toESM(require("http"));
var import_crypto = __toESM(require("crypto"));
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var mcpBundle = __toESM(require("./bundle"));
var mcpServer = __toESM(require("./server"));
async function start(serverBackendFactory, options) {
if (options.port !== void 0) {
const httpServer = await startHttpServer(options);
startHttpTransport(httpServer, serverBackendFactory);
} else {
await startStdioTransport(serverBackendFactory);
}
}
async function startStdioTransport(serverBackendFactory) {
await mcpServer.connect(serverBackendFactory, new mcpBundle.StdioServerTransport(), false);
}
const testDebug = (0, import_utilsBundle.debug)("pw:mcp:test");
async function handleSSE(serverBackendFactory, req, res, url, sessions) {
if (req.method === "POST") {
const sessionId = url.searchParams.get("sessionId");
if (!sessionId) {
res.statusCode = 400;
return res.end("Missing sessionId");
}
const transport = sessions.get(sessionId);
if (!transport) {
res.statusCode = 404;
return res.end("Session not found");
}
return await transport.handlePostMessage(req, res);
} else if (req.method === "GET") {
const transport = new mcpBundle.SSEServerTransport("/sse", res);
sessions.set(transport.sessionId, transport);
testDebug(`create SSE session: ${transport.sessionId}`);
await mcpServer.connect(serverBackendFactory, transport, false);
res.on("close", () => {
testDebug(`delete SSE session: ${transport.sessionId}`);
sessions.delete(transport.sessionId);
});
return;
}
res.statusCode = 405;
res.end("Method not allowed");
}
async function handleStreamable(serverBackendFactory, req, res, sessions) {
const sessionId = req.headers["mcp-session-id"];
if (sessionId) {
const transport = sessions.get(sessionId);
if (!transport) {
res.statusCode = 404;
res.end("Session not found");
return;
}
return await transport.handleRequest(req, res);
}
if (req.method === "POST") {
const transport = new mcpBundle.StreamableHTTPServerTransport({
sessionIdGenerator: () => import_crypto.default.randomUUID(),
onsessioninitialized: async (sessionId2) => {
testDebug(`create http session: ${transport.sessionId}`);
await mcpServer.connect(serverBackendFactory, transport, true);
sessions.set(sessionId2, transport);
}
});
transport.onclose = () => {
if (!transport.sessionId)
return;
sessions.delete(transport.sessionId);
testDebug(`delete http session: ${transport.sessionId}`);
};
await transport.handleRequest(req, res);
return;
}
res.statusCode = 400;
res.end("Invalid request");
}
function startHttpTransport(httpServer, serverBackendFactory) {
const sseSessions = /* @__PURE__ */ new Map();
const streamableSessions = /* @__PURE__ */ new Map();
httpServer.on("request", async (req, res) => {
const url2 = new URL(`http://localhost${req.url}`);
if (url2.pathname.startsWith("/sse"))
await handleSSE(serverBackendFactory, req, res, url2, sseSessions);
else
await handleStreamable(serverBackendFactory, req, res, streamableSessions);
});
const url = httpAddressToString(httpServer.address());
const message = [
`Listening on ${url}`,
"Put this in your client config:",
JSON.stringify({
"mcpServers": {
"playwright": {
"url": `${url}/mcp`
}
}
}, void 0, 2),
"For legacy SSE transport support, you can use the /sse endpoint instead."
].join("\n");
console.error(message);
}
async function startHttpServer(config) {
const { host, port } = config;
const httpServer = import_http.default.createServer();
await new Promise((resolve, reject) => {
httpServer.on("error", reject);
httpServer.listen(port, host, () => {
resolve();
httpServer.removeListener("error", reject);
});
});
return httpServer;
}
function httpAddressToString(address) {
(0, import_assert.default)(address, "Could not bind server socket");
if (typeof address === "string")
return address;
const resolvedPort = address.port;
let resolvedHost = address.family === "IPv4" ? address.address : `[${address.address}]`;
if (resolvedHost === "0.0.0.0" || resolvedHost === "[::]")
resolvedHost = "localhost";
return `http://${resolvedHost}:${resolvedPort}`;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
start
});

94
node_modules/playwright/lib/mcpBundleImpl.js generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,198 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var gitCommitInfoPlugin_exports = {};
__export(gitCommitInfoPlugin_exports, {
addGitCommitInfoPlugin: () => addGitCommitInfoPlugin
});
module.exports = __toCommonJS(gitCommitInfoPlugin_exports);
var fs = __toESM(require("fs"));
var import_utils = require("playwright-core/lib/utils");
const GIT_OPERATIONS_TIMEOUT_MS = 3e3;
const addGitCommitInfoPlugin = (fullConfig) => {
fullConfig.plugins.push({ factory: gitCommitInfoPlugin.bind(null, fullConfig) });
};
function print(s, ...args) {
console.log("GitCommitInfo: " + s, ...args);
}
function debug(s, ...args) {
if (!process.env.DEBUG_GIT_COMMIT_INFO)
return;
print(s, ...args);
}
const gitCommitInfoPlugin = (fullConfig) => {
return {
name: "playwright:git-commit-info",
setup: async (config, configDir) => {
const metadata = config.metadata;
const ci = await ciInfo();
if (!metadata.ci && ci) {
debug("ci info", ci);
metadata.ci = ci;
}
if (fullConfig.captureGitInfo?.commit || fullConfig.captureGitInfo?.commit === void 0 && ci) {
const git = await gitCommitInfo(configDir).catch((e) => print("failed to get git commit info", e));
if (git) {
debug("commit info", git);
metadata.gitCommit = git;
}
}
if (fullConfig.captureGitInfo?.diff || fullConfig.captureGitInfo?.diff === void 0 && ci) {
const diffResult = await gitDiff(configDir, ci).catch((e) => print("failed to get git diff", e));
if (diffResult) {
debug(`diff length ${diffResult.length}`);
metadata.gitDiff = diffResult;
}
}
}
};
};
async function ciInfo() {
if (process.env.GITHUB_ACTIONS) {
let pr;
try {
const json = JSON.parse(await fs.promises.readFile(process.env.GITHUB_EVENT_PATH, "utf8"));
pr = { title: json.pull_request.title, number: json.pull_request.number, baseHash: json.pull_request.base.sha };
} catch {
}
return {
commitHref: `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/commit/${process.env.GITHUB_SHA}`,
commitHash: process.env.GITHUB_SHA,
prHref: pr ? `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/pull/${pr.number}` : void 0,
prTitle: pr?.title,
prBaseHash: pr?.baseHash,
buildHref: `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
};
}
if (process.env.GITLAB_CI) {
return {
commitHref: `${process.env.CI_PROJECT_URL}/-/commit/${process.env.CI_COMMIT_SHA}`,
commitHash: process.env.CI_COMMIT_SHA,
buildHref: process.env.CI_JOB_URL,
branch: process.env.CI_COMMIT_REF_NAME
};
}
if (process.env.JENKINS_URL && process.env.BUILD_URL) {
return {
commitHref: process.env.BUILD_URL,
commitHash: process.env.GIT_COMMIT,
branch: process.env.GIT_BRANCH
};
}
}
async function gitCommitInfo(gitDir) {
const separator = `---786eec917292---`;
const tokens = [
"%H",
// commit hash
"%h",
// abbreviated commit hash
"%s",
// subject
"%B",
// raw body (unwrapped subject and body)
"%an",
// author name
"%ae",
// author email
"%at",
// author date, UNIX timestamp
"%cn",
// committer name
"%ce",
// committer email
"%ct",
// committer date, UNIX timestamp
""
// branch
];
const output = await runGit(`git log -1 --pretty=format:"${tokens.join(separator)}" && git rev-parse --abbrev-ref HEAD`, gitDir);
if (!output)
return void 0;
const [hash, shortHash, subject, body, authorName, authorEmail, authorTime, committerName, committerEmail, committerTime, branch] = output.split(separator);
return {
shortHash,
hash,
subject,
body,
author: {
name: authorName,
email: authorEmail,
time: +authorTime * 1e3
},
committer: {
name: committerName,
email: committerEmail,
time: +committerTime * 1e3
},
branch: branch.trim()
};
}
async function gitDiff(gitDir, ci) {
const diffLimit = 1e5;
if (ci?.prBaseHash) {
await runGit(`git fetch origin ${ci.prBaseHash} --depth=1 --no-auto-maintenance --no-auto-gc --no-tags --no-recurse-submodules`, gitDir);
const diff2 = await runGit(`git diff ${ci.prBaseHash} HEAD`, gitDir);
if (diff2)
return diff2.substring(0, diffLimit);
}
if (ci)
return;
const uncommitted = await runGit("git diff", gitDir);
if (uncommitted === void 0) {
return;
}
if (uncommitted)
return uncommitted.substring(0, diffLimit);
const diff = await runGit("git diff HEAD~1", gitDir);
return diff?.substring(0, diffLimit);
}
async function runGit(command, cwd) {
debug(`running "${command}"`);
const start = (0, import_utils.monotonicTime)();
const result = await (0, import_utils.spawnAsync)(
command,
[],
{ stdio: "pipe", cwd, timeout: GIT_OPERATIONS_TIMEOUT_MS, shell: true }
);
if ((0, import_utils.monotonicTime)() - start > GIT_OPERATIONS_TIMEOUT_MS) {
print(`timeout of ${GIT_OPERATIONS_TIMEOUT_MS}ms exceeded while running "${command}"`);
return;
}
if (result.code)
debug(`failure, code=${result.code}
${result.stderr}`);
else
debug(`success`);
return result.code ? void 0 : result.stdout.trim();
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
addGitCommitInfoPlugin
});

28
node_modules/playwright/lib/plugins/index.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var plugins_exports = {};
__export(plugins_exports, {
webServer: () => import_webServerPlugin.webServer
});
module.exports = __toCommonJS(plugins_exports);
var import_webServerPlugin = require("./webServerPlugin");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
webServer
});

207
node_modules/playwright/lib/plugins/webServerPlugin.js generated vendored Normal file
View File

@@ -0,0 +1,207 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var webServerPlugin_exports = {};
__export(webServerPlugin_exports, {
WebServerPlugin: () => WebServerPlugin,
webServer: () => webServer,
webServerPluginsForConfig: () => webServerPluginsForConfig
});
module.exports = __toCommonJS(webServerPlugin_exports);
var import_net = __toESM(require("net"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
const DEFAULT_ENVIRONMENT_VARIABLES = {
"BROWSER": "none",
// Disable that create-react-app will open the page in the browser
"FORCE_COLOR": "1",
"DEBUG_COLORS": "1"
};
const debugWebServer = (0, import_utilsBundle.debug)("pw:webserver");
class WebServerPlugin {
constructor(options, checkPortOnly) {
this.name = "playwright:webserver";
this._options = options;
this._checkPortOnly = checkPortOnly;
}
async setup(config, configDir, reporter) {
this._reporter = reporter;
this._isAvailableCallback = this._options.url ? getIsAvailableFunction(this._options.url, this._checkPortOnly, !!this._options.ignoreHTTPSErrors, this._reporter.onStdErr?.bind(this._reporter)) : void 0;
this._options.cwd = this._options.cwd ? import_path.default.resolve(configDir, this._options.cwd) : configDir;
try {
await this._startProcess();
await this._waitForProcess();
} catch (error) {
await this.teardown();
throw error;
}
}
async teardown() {
debugWebServer(`Terminating the WebServer`);
await this._killProcess?.();
debugWebServer(`Terminated the WebServer`);
}
async _startProcess() {
let processExitedReject = (error) => {
};
this._processExitedPromise = new Promise((_, reject) => processExitedReject = reject);
const isAlreadyAvailable = await this._isAvailableCallback?.();
if (isAlreadyAvailable) {
debugWebServer(`WebServer is already available`);
if (this._options.reuseExistingServer)
return;
const port = new URL(this._options.url).port;
throw new Error(`${this._options.url ?? `http://localhost${port ? ":" + port : ""}`} is already used, make sure that nothing is running on the port/url or set reuseExistingServer:true in config.webServer.`);
}
debugWebServer(`Starting WebServer process ${this._options.command}...`);
const { launchedProcess, gracefullyClose } = await (0, import_utils.launchProcess)({
command: this._options.command,
env: {
...DEFAULT_ENVIRONMENT_VARIABLES,
...process.env,
...this._options.env
},
cwd: this._options.cwd,
stdio: "stdin",
shell: true,
attemptToGracefullyClose: async () => {
if (process.platform === "win32")
throw new Error("Graceful shutdown is not supported on Windows");
if (!this._options.gracefulShutdown)
throw new Error("skip graceful shutdown");
const { signal, timeout = 0 } = this._options.gracefulShutdown;
process.kill(-launchedProcess.pid, signal);
return new Promise((resolve, reject) => {
const timer = timeout !== 0 ? setTimeout(() => reject(new Error(`process didn't close gracefully within timeout`)), timeout) : void 0;
launchedProcess.once("close", (...args) => {
clearTimeout(timer);
resolve();
});
});
},
log: () => {
},
onExit: (code) => processExitedReject(new Error(code ? `Process from config.webServer was not able to start. Exit code: ${code}` : "Process from config.webServer exited early.")),
tempDirectories: []
});
this._killProcess = gracefullyClose;
debugWebServer(`Process started`);
launchedProcess.stderr.on("data", (data) => {
if (debugWebServer.enabled || (this._options.stderr === "pipe" || !this._options.stderr))
this._reporter.onStdErr?.(prefixOutputLines(data.toString(), this._options.name));
});
launchedProcess.stdout.on("data", (data) => {
if (debugWebServer.enabled || this._options.stdout === "pipe")
this._reporter.onStdOut?.(prefixOutputLines(data.toString(), this._options.name));
});
}
async _waitForProcess() {
if (!this._isAvailableCallback) {
this._processExitedPromise.catch(() => {
});
return;
}
debugWebServer(`Waiting for availability...`);
const launchTimeout = this._options.timeout || 60 * 1e3;
const cancellationToken = { canceled: false };
const { timedOut } = await Promise.race([
(0, import_utils.raceAgainstDeadline)(() => waitFor(this._isAvailableCallback, cancellationToken), (0, import_utils.monotonicTime)() + launchTimeout),
this._processExitedPromise
]);
cancellationToken.canceled = true;
if (timedOut)
throw new Error(`Timed out waiting ${launchTimeout}ms from config.webServer.`);
debugWebServer(`WebServer available`);
}
}
async function isPortUsed(port) {
const innerIsPortUsed = (host) => new Promise((resolve) => {
const conn = import_net.default.connect(port, host).on("error", () => {
resolve(false);
}).on("connect", () => {
conn.end();
resolve(true);
});
});
return await innerIsPortUsed("127.0.0.1") || await innerIsPortUsed("::1");
}
async function waitFor(waitFn, cancellationToken) {
const logScale = [100, 250, 500];
while (!cancellationToken.canceled) {
const connected = await waitFn();
if (connected)
return;
const delay = logScale.shift() || 1e3;
debugWebServer(`Waiting ${delay}ms`);
await new Promise((x) => setTimeout(x, delay));
}
}
function getIsAvailableFunction(url, checkPortOnly, ignoreHTTPSErrors, onStdErr) {
const urlObject = new URL(url);
if (!checkPortOnly)
return () => (0, import_utils.isURLAvailable)(urlObject, ignoreHTTPSErrors, debugWebServer, onStdErr);
const port = urlObject.port;
return () => isPortUsed(+port);
}
const webServer = (options) => {
return new WebServerPlugin(options, false);
};
const webServerPluginsForConfig = (config) => {
const shouldSetBaseUrl = !!config.config.webServer;
const webServerPlugins = [];
for (const webServerConfig of config.webServers) {
if (webServerConfig.port && webServerConfig.url)
throw new Error(`Either 'port' or 'url' should be specified in config.webServer.`);
let url;
if (webServerConfig.port || webServerConfig.url) {
url = webServerConfig.url || `http://localhost:${webServerConfig.port}`;
if (shouldSetBaseUrl && !webServerConfig.url)
process.env.PLAYWRIGHT_TEST_BASE_URL = url;
}
webServerPlugins.push(new WebServerPlugin({ ...webServerConfig, url }, webServerConfig.port !== void 0));
}
return webServerPlugins;
};
function prefixOutputLines(output, prefixName = "WebServer") {
const lastIsNewLine = output[output.length - 1] === "\n";
let lines = output.split("\n");
if (lastIsNewLine)
lines.pop();
lines = lines.map((line) => import_utils2.colors.dim(`[${prefixName}] `) + line);
if (lastIsNewLine)
lines.push("");
return lines.join("\n");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
WebServerPlugin,
webServer,
webServerPluginsForConfig
});

344
node_modules/playwright/lib/program.js generated vendored Normal file
View File

@@ -0,0 +1,344 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var program_exports = {};
__export(program_exports, {
program: () => import_program2.program
});
module.exports = __toCommonJS(program_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_program = require("playwright-core/lib/cli/program");
var import_utils = require("playwright-core/lib/utils");
var import_config = require("./common/config");
var import_configLoader = require("./common/configLoader");
var import_program2 = require("playwright-core/lib/cli/program");
var import_base = require("./reporters/base");
var import_html = require("./reporters/html");
var import_merge = require("./reporters/merge");
var import_projectUtils = require("./runner/projectUtils");
var testServer = __toESM(require("./runner/testServer"));
var import_watchMode = require("./runner/watchMode");
var import_testRunner = require("./runner/testRunner");
var import_reporters = require("./runner/reporters");
function addTestCommand(program3) {
const command = program3.command("test [test-filter...]");
command.description("run tests with Playwright Test");
const options = testOptions.sort((a, b) => a[0].replace(/-/g, "").localeCompare(b[0].replace(/-/g, "")));
options.forEach(([name, { description, choices, preset }]) => {
const option = command.createOption(name, description);
if (choices)
option.choices(choices);
if (preset)
option.preset(preset);
command.addOption(option);
return command;
});
command.action(async (args, opts) => {
try {
await runTests(args, opts);
} catch (e) {
console.error(e);
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
}
});
command.addHelpText("afterAll", `
Arguments [test-filter...]:
Pass arguments to filter test files. Each argument is treated as a regular expression. Matching is performed against the absolute file paths.
Examples:
$ npx playwright test my.spec.ts
$ npx playwright test some.spec.ts:42
$ npx playwright test --headed
$ npx playwright test --project=webkit`);
}
function addClearCacheCommand(program3) {
const command = program3.command("clear-cache");
command.description("clears build and test caches");
command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
command.action(async (opts) => {
const runner = new import_testRunner.TestRunner((0, import_configLoader.resolveConfigLocation)(opts.config), {});
const { status } = await runner.clearCache((0, import_reporters.createErrorCollectingReporter)(import_base.terminalScreen));
const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
(0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
});
}
function addDevServerCommand(program3) {
const command = program3.command("dev-server", { hidden: true });
command.description("start dev server");
command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
command.action(async (options) => {
const runner = new import_testRunner.TestRunner((0, import_configLoader.resolveConfigLocation)(options.config), {});
await runner.startDevServer((0, import_reporters.createErrorCollectingReporter)(import_base.terminalScreen), "in-process");
});
}
function addTestServerCommand(program3) {
const command = program3.command("test-server", { hidden: true });
command.description("start test server");
command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
command.option("--host <host>", "Host to start the server on", "localhost");
command.option("--port <port>", "Port to start the server on", "0");
command.action((opts) => runTestServer(opts));
}
function addShowReportCommand(program3) {
const command = program3.command("show-report [report]");
command.description("show HTML report");
command.action((report, options) => (0, import_html.showHTMLReport)(report, options.host, +options.port));
command.option("--host <host>", "Host to serve report on", "localhost");
command.option("--port <port>", "Port to serve report on", "9323");
command.addHelpText("afterAll", `
Arguments [report]:
When specified, opens given report, otherwise opens last generated report.
Examples:
$ npx playwright show-report
$ npx playwright show-report playwright-report`);
}
function addMergeReportsCommand(program3) {
const command = program3.command("merge-reports [dir]");
command.description("merge multiple blob reports (for sharded tests) into a single report");
command.action(async (dir, options) => {
try {
await mergeReports(dir, options);
} catch (e) {
console.error(e);
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
}
});
command.option("-c, --config <file>", `Configuration file. Can be used to specify additional configuration for the output report.`);
command.option("--reporter <reporter>", `Reporter to use, comma-separated, can be ${import_config.builtInReporters.map((name) => `"${name}"`).join(", ")} (default: "${import_config.defaultReporter}")`);
command.addHelpText("afterAll", `
Arguments [dir]:
Directory containing blob reports.
Examples:
$ npx playwright merge-reports playwright-report`);
}
async function runTests(args, opts) {
await (0, import_utils.startProfiling)();
const cliOverrides = overridesFromOptions(opts);
const config = await (0, import_configLoader.loadConfigFromFile)(opts.config, cliOverrides, opts.deps === false);
config.cliArgs = args;
config.cliGrep = opts.grep;
config.cliOnlyChanged = opts.onlyChanged === true ? "HEAD" : opts.onlyChanged;
config.cliGrepInvert = opts.grepInvert;
config.cliListOnly = !!opts.list;
config.cliProjectFilter = opts.project || void 0;
config.cliPassWithNoTests = !!opts.passWithNoTests;
config.cliLastFailed = !!opts.lastFailed;
(0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
if (opts.ui || opts.uiHost || opts.uiPort) {
if (opts.onlyChanged)
throw new Error(`--only-changed is not supported in UI mode. If you'd like that to change, see https://github.com/microsoft/playwright/issues/15075 for more details.`);
const status2 = await testServer.runUIMode(opts.config, cliOverrides, {
host: opts.uiHost,
port: opts.uiPort ? +opts.uiPort : void 0,
args,
grep: opts.grep,
grepInvert: opts.grepInvert,
project: opts.project || void 0,
reporter: Array.isArray(opts.reporter) ? opts.reporter : opts.reporter ? [opts.reporter] : void 0
});
await (0, import_utils.stopProfiling)("runner");
const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
(0, import_utils.gracefullyProcessExitDoNotHang)(exitCode2);
return;
}
if (process.env.PWTEST_WATCH) {
if (opts.onlyChanged)
throw new Error(`--only-changed is not supported in watch mode. If you'd like that to change, file an issue and let us know about your usecase for it.`);
const status2 = await (0, import_watchMode.runWatchModeLoop)(
(0, import_configLoader.resolveConfigLocation)(opts.config),
{
projects: opts.project,
files: args,
grep: opts.grep
}
);
await (0, import_utils.stopProfiling)("runner");
const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
(0, import_utils.gracefullyProcessExitDoNotHang)(exitCode2);
return;
}
const status = await (0, import_testRunner.runAllTestsWithConfig)(config);
await (0, import_utils.stopProfiling)("runner");
const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
(0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
}
async function runTestServer(opts) {
const host = opts.host || "localhost";
const port = opts.port ? +opts.port : 0;
const status = await testServer.runTestServer(opts.config, {}, { host, port });
const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
(0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
}
async function mergeReports(reportDir, opts) {
const configFile = opts.config;
const config = configFile ? await (0, import_configLoader.loadConfigFromFile)(configFile) : await (0, import_configLoader.loadEmptyConfigForMergeReports)();
const dir = import_path.default.resolve(process.cwd(), reportDir || "");
const dirStat = await import_fs.default.promises.stat(dir).catch((e) => null);
if (!dirStat)
throw new Error("Directory does not exist: " + dir);
if (!dirStat.isDirectory())
throw new Error(`"${dir}" is not a directory`);
let reporterDescriptions = resolveReporterOption(opts.reporter);
if (!reporterDescriptions && configFile)
reporterDescriptions = config.config.reporter;
if (!reporterDescriptions)
reporterDescriptions = [[import_config.defaultReporter]];
const rootDirOverride = configFile ? config.config.rootDir : void 0;
await (0, import_merge.createMergedReport)(config, dir, reporterDescriptions, rootDirOverride);
(0, import_utils.gracefullyProcessExitDoNotHang)(0);
}
function overridesFromOptions(options) {
const overrides = {
failOnFlakyTests: options.failOnFlakyTests ? true : void 0,
forbidOnly: options.forbidOnly ? true : void 0,
fullyParallel: options.fullyParallel ? true : void 0,
globalTimeout: options.globalTimeout ? parseInt(options.globalTimeout, 10) : void 0,
maxFailures: options.x ? 1 : options.maxFailures ? parseInt(options.maxFailures, 10) : void 0,
outputDir: options.output ? import_path.default.resolve(process.cwd(), options.output) : void 0,
quiet: options.quiet ? options.quiet : void 0,
repeatEach: options.repeatEach ? parseInt(options.repeatEach, 10) : void 0,
retries: options.retries ? parseInt(options.retries, 10) : void 0,
reporter: resolveReporterOption(options.reporter),
shard: resolveShardOption(options.shard),
timeout: options.timeout ? parseInt(options.timeout, 10) : void 0,
tsconfig: options.tsconfig ? import_path.default.resolve(process.cwd(), options.tsconfig) : void 0,
ignoreSnapshots: options.ignoreSnapshots ? !!options.ignoreSnapshots : void 0,
updateSnapshots: options.updateSnapshots,
updateSourceMethod: options.updateSourceMethod,
workers: options.workers
};
if (options.browser) {
const browserOpt = options.browser.toLowerCase();
if (!["all", "chromium", "firefox", "webkit"].includes(browserOpt))
throw new Error(`Unsupported browser "${options.browser}", must be one of "all", "chromium", "firefox" or "webkit"`);
const browserNames = browserOpt === "all" ? ["chromium", "firefox", "webkit"] : [browserOpt];
overrides.projects = browserNames.map((browserName) => {
return {
name: browserName,
use: { browserName }
};
});
}
if (options.headed || options.debug)
overrides.use = { headless: false };
if (!options.ui && options.debug) {
overrides.debug = true;
process.env.PWDEBUG = "1";
}
if (!options.ui && options.trace) {
overrides.use = overrides.use || {};
overrides.use.trace = options.trace;
}
if (overrides.tsconfig && !import_fs.default.existsSync(overrides.tsconfig))
throw new Error(`--tsconfig "${options.tsconfig}" does not exist`);
return overrides;
}
function resolveReporterOption(reporter) {
if (!reporter || !reporter.length)
return void 0;
return reporter.split(",").map((r) => [resolveReporter(r)]);
}
function resolveShardOption(shard) {
if (!shard)
return void 0;
const shardPair = shard.split("/");
if (shardPair.length !== 2) {
throw new Error(
`--shard "${shard}", expected format is "current/all", 1-based, for example "3/5".`
);
}
const current = parseInt(shardPair[0], 10);
const total = parseInt(shardPair[1], 10);
if (isNaN(total) || total < 1)
throw new Error(`--shard "${shard}" total must be a positive number`);
if (isNaN(current) || current < 1 || current > total) {
throw new Error(
`--shard "${shard}" current must be a positive number, not greater than shard total`
);
}
return { current, total };
}
function resolveReporter(id) {
if (import_config.builtInReporters.includes(id))
return id;
const localPath = import_path.default.resolve(process.cwd(), id);
if (import_fs.default.existsSync(localPath))
return localPath;
return require.resolve(id, { paths: [process.cwd()] });
}
const kTraceModes = ["on", "off", "on-first-retry", "on-all-retries", "retain-on-failure", "retain-on-first-failure"];
const testOptions = [
/* deprecated */
["--browser <browser>", { description: `Browser to use for tests, one of "all", "chromium", "firefox" or "webkit" (default: "chromium")` }],
["-c, --config <file>", { description: `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"` }],
["--debug", { description: `Run tests with Playwright Inspector. Shortcut for "PWDEBUG=1" environment variable and "--timeout=0 --max-failures=1 --headed --workers=1" options` }],
["--fail-on-flaky-tests", { description: `Fail if any test is flagged as flaky (default: false)` }],
["--forbid-only", { description: `Fail if test.only is called (default: false)` }],
["--fully-parallel", { description: `Run all tests in parallel (default: false)` }],
["--global-timeout <timeout>", { description: `Maximum time this test suite can run in milliseconds (default: unlimited)` }],
["-g, --grep <grep>", { description: `Only run tests matching this regular expression (default: ".*")` }],
["--grep-invert <grep>", { description: `Only run tests that do not match this regular expression` }],
["--headed", { description: `Run tests in headed browsers (default: headless)` }],
["--ignore-snapshots", { description: `Ignore screenshot and snapshot expectations` }],
["--last-failed", { description: `Only re-run the failures` }],
["--list", { description: `Collect all the tests and report them, but do not run` }],
["--max-failures <N>", { description: `Stop after the first N failures` }],
["--no-deps", { description: `Do not run project dependencies` }],
["--output <dir>", { description: `Folder for output artifacts (default: "test-results")` }],
["--only-changed [ref]", { description: `Only run test files that have been changed between 'HEAD' and 'ref'. Defaults to running all uncommitted changes. Only supports Git.` }],
["--pass-with-no-tests", { description: `Makes test run succeed even if no tests were found` }],
["--project <project-name...>", { description: `Only run tests from the specified list of projects, supports '*' wildcard (default: run all projects)` }],
["--quiet", { description: `Suppress stdio` }],
["--repeat-each <N>", { description: `Run each test N times (default: 1)` }],
["--reporter <reporter>", { description: `Reporter to use, comma-separated, can be ${import_config.builtInReporters.map((name) => `"${name}"`).join(", ")} (default: "${import_config.defaultReporter}")` }],
["--retries <retries>", { description: `Maximum retry count for flaky tests, zero for no retries (default: no retries)` }],
["--shard <shard>", { description: `Shard tests and execute only the selected shard, specify in the form "current/all", 1-based, for example "3/5"` }],
["--timeout <timeout>", { description: `Specify test timeout threshold in milliseconds, zero for unlimited (default: ${import_config.defaultTimeout})` }],
["--trace <mode>", { description: `Force tracing mode`, choices: kTraceModes }],
["--tsconfig <path>", { description: `Path to a single tsconfig applicable to all imported files (default: look up tsconfig for each imported file separately)` }],
["--ui", { description: `Run tests in interactive UI mode` }],
["--ui-host <host>", { description: `Host to serve UI on; specifying this option opens UI in a browser tab` }],
["--ui-port <port>", { description: `Port to serve UI on, 0 for any free port; specifying this option opens UI in a browser tab` }],
["-u, --update-snapshots [mode]", { description: `Update snapshots with actual results. Running tests without the flag defaults to "missing"`, choices: ["all", "changed", "missing", "none"], preset: "changed" }],
["--update-source-method <method>", { description: `Chooses the way source is updated (default: "patch")`, choices: ["overwrite", "3way", "patch"] }],
["-j, --workers <workers>", { description: `Number of concurrent workers or percentage of logical CPU cores, use 1 to run in a single worker (default: 50%)` }],
["-x", { description: `Stop after the first failure` }]
];
addTestCommand(import_program.program);
addShowReportCommand(import_program.program);
addMergeReportsCommand(import_program.program);
addClearCacheCommand(import_program.program);
addDevServerCommand(import_program.program);
addTestServerCommand(import_program.program);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
program
});

611
node_modules/playwright/lib/reporters/base.js generated vendored Normal file
View File

@@ -0,0 +1,611 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var base_exports = {};
__export(base_exports, {
TerminalReporter: () => TerminalReporter,
fitToWidth: () => fitToWidth,
formatError: () => formatError,
formatFailure: () => formatFailure,
formatResultFailure: () => formatResultFailure,
formatRetry: () => formatRetry,
internalScreen: () => internalScreen,
kOutputSymbol: () => kOutputSymbol,
nonTerminalScreen: () => nonTerminalScreen,
prepareErrorStack: () => prepareErrorStack,
relativeFilePath: () => relativeFilePath,
resolveOutputFile: () => resolveOutputFile,
separator: () => separator,
stepSuffix: () => stepSuffix,
terminalScreen: () => terminalScreen
});
module.exports = __toCommonJS(base_exports);
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_utils2 = require("playwright-core/lib/utils");
var import_util = require("../util");
var import_utilsBundle2 = require("../utilsBundle");
const kOutputSymbol = Symbol("output");
const DEFAULT_TTY_WIDTH = 100;
const DEFAULT_TTY_HEIGHT = 40;
const originalProcessStdout = process.stdout;
const originalProcessStderr = process.stderr;
const terminalScreen = (() => {
let isTTY = !!originalProcessStdout.isTTY;
let ttyWidth = originalProcessStdout.columns || 0;
let ttyHeight = originalProcessStdout.rows || 0;
if (process.env.PLAYWRIGHT_FORCE_TTY === "false" || process.env.PLAYWRIGHT_FORCE_TTY === "0") {
isTTY = false;
ttyWidth = 0;
ttyHeight = 0;
} else if (process.env.PLAYWRIGHT_FORCE_TTY === "true" || process.env.PLAYWRIGHT_FORCE_TTY === "1") {
isTTY = true;
ttyWidth = originalProcessStdout.columns || DEFAULT_TTY_WIDTH;
ttyHeight = originalProcessStdout.rows || DEFAULT_TTY_HEIGHT;
} else if (process.env.PLAYWRIGHT_FORCE_TTY) {
isTTY = true;
const sizeMatch = process.env.PLAYWRIGHT_FORCE_TTY.match(/^(\d+)x(\d+)$/);
if (sizeMatch) {
ttyWidth = +sizeMatch[1];
ttyHeight = +sizeMatch[2];
} else {
ttyWidth = +process.env.PLAYWRIGHT_FORCE_TTY;
ttyHeight = DEFAULT_TTY_HEIGHT;
}
if (isNaN(ttyWidth))
ttyWidth = DEFAULT_TTY_WIDTH;
if (isNaN(ttyHeight))
ttyHeight = DEFAULT_TTY_HEIGHT;
}
let useColors = isTTY;
if (process.env.DEBUG_COLORS === "0" || process.env.DEBUG_COLORS === "false" || process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false")
useColors = false;
else if (process.env.DEBUG_COLORS || process.env.FORCE_COLOR)
useColors = true;
const colors = useColors ? import_utils2.colors : import_utils2.noColors;
return {
resolveFiles: "cwd",
isTTY,
ttyWidth,
ttyHeight,
colors,
stdout: originalProcessStdout,
stderr: originalProcessStderr
};
})();
const nonTerminalScreen = {
colors: terminalScreen.colors,
isTTY: false,
ttyWidth: 0,
ttyHeight: 0,
resolveFiles: "rootDir"
};
const internalScreen = {
colors: import_utils2.colors,
isTTY: false,
ttyWidth: 0,
ttyHeight: 0,
resolveFiles: "rootDir"
};
class TerminalReporter {
constructor(options = {}) {
this.totalTestCount = 0;
this.fileDurations = /* @__PURE__ */ new Map();
this._fatalErrors = [];
this._failureCount = 0;
this.screen = options.screen ?? terminalScreen;
this._omitFailures = options.omitFailures || false;
}
version() {
return "v2";
}
onConfigure(config) {
this.config = config;
}
onBegin(suite) {
this.suite = suite;
this.totalTestCount = suite.allTests().length;
}
onStdOut(chunk, test, result) {
this._appendOutput({ chunk, type: "stdout" }, result);
}
onStdErr(chunk, test, result) {
this._appendOutput({ chunk, type: "stderr" }, result);
}
_appendOutput(output, result) {
if (!result)
return;
result[kOutputSymbol] = result[kOutputSymbol] || [];
result[kOutputSymbol].push(output);
}
onTestEnd(test, result) {
if (result.status !== "skipped" && result.status !== test.expectedStatus)
++this._failureCount;
const projectName = test.titlePath()[1];
const relativePath = relativeTestPath(this.screen, this.config, test);
const fileAndProject = (projectName ? `[${projectName}] \u203A ` : "") + relativePath;
const entry = this.fileDurations.get(fileAndProject) || { duration: 0, workers: /* @__PURE__ */ new Set() };
entry.duration += result.duration;
entry.workers.add(result.workerIndex);
this.fileDurations.set(fileAndProject, entry);
}
onError(error) {
this._fatalErrors.push(error);
}
async onEnd(result) {
this.result = result;
}
fitToScreen(line, prefix) {
if (!this.screen.ttyWidth) {
return line;
}
return fitToWidth(line, this.screen.ttyWidth, prefix);
}
generateStartingMessage() {
const jobs = this.config.metadata.actualWorkers ?? this.config.workers;
const shardDetails = this.config.shard ? `, shard ${this.config.shard.current} of ${this.config.shard.total}` : "";
if (!this.totalTestCount)
return "";
return "\n" + this.screen.colors.dim("Running ") + this.totalTestCount + this.screen.colors.dim(` test${this.totalTestCount !== 1 ? "s" : ""} using `) + jobs + this.screen.colors.dim(` worker${jobs !== 1 ? "s" : ""}${shardDetails}`);
}
getSlowTests() {
if (!this.config.reportSlowTests)
return [];
const fileDurations = [...this.fileDurations.entries()].filter(([key, value]) => value.workers.size === 1).map(([key, value]) => [key, value.duration]);
fileDurations.sort((a, b) => b[1] - a[1]);
const count = Math.min(fileDurations.length, this.config.reportSlowTests.max || Number.POSITIVE_INFINITY);
const threshold = this.config.reportSlowTests.threshold;
return fileDurations.filter(([, duration]) => duration > threshold).slice(0, count);
}
generateSummaryMessage({ didNotRun, skipped, expected, interrupted, unexpected, flaky, fatalErrors }) {
const tokens = [];
if (unexpected.length) {
tokens.push(this.screen.colors.red(` ${unexpected.length} failed`));
for (const test of unexpected)
tokens.push(this.screen.colors.red(this.formatTestHeader(test, { indent: " " })));
}
if (interrupted.length) {
tokens.push(this.screen.colors.yellow(` ${interrupted.length} interrupted`));
for (const test of interrupted)
tokens.push(this.screen.colors.yellow(this.formatTestHeader(test, { indent: " " })));
}
if (flaky.length) {
tokens.push(this.screen.colors.yellow(` ${flaky.length} flaky`));
for (const test of flaky)
tokens.push(this.screen.colors.yellow(this.formatTestHeader(test, { indent: " " })));
}
if (skipped)
tokens.push(this.screen.colors.yellow(` ${skipped} skipped`));
if (didNotRun)
tokens.push(this.screen.colors.yellow(` ${didNotRun} did not run`));
if (expected)
tokens.push(this.screen.colors.green(` ${expected} passed`) + this.screen.colors.dim(` (${(0, import_utilsBundle.ms)(this.result.duration)})`));
if (fatalErrors.length && expected + unexpected.length + interrupted.length + flaky.length > 0)
tokens.push(this.screen.colors.red(` ${fatalErrors.length === 1 ? "1 error was not a part of any test" : fatalErrors.length + " errors were not a part of any test"}, see above for details`));
return tokens.join("\n");
}
generateSummary() {
let didNotRun = 0;
let skipped = 0;
let expected = 0;
const interrupted = [];
const interruptedToPrint = [];
const unexpected = [];
const flaky = [];
this.suite.allTests().forEach((test) => {
switch (test.outcome()) {
case "skipped": {
if (test.results.some((result) => result.status === "interrupted")) {
if (test.results.some((result) => !!result.error))
interruptedToPrint.push(test);
interrupted.push(test);
} else if (!test.results.length || test.expectedStatus !== "skipped") {
++didNotRun;
} else {
++skipped;
}
break;
}
case "expected":
++expected;
break;
case "unexpected":
unexpected.push(test);
break;
case "flaky":
flaky.push(test);
break;
}
});
const failuresToPrint = [...unexpected, ...flaky, ...interruptedToPrint];
return {
didNotRun,
skipped,
expected,
interrupted,
unexpected,
flaky,
failuresToPrint,
fatalErrors: this._fatalErrors
};
}
epilogue(full) {
const summary = this.generateSummary();
const summaryMessage = this.generateSummaryMessage(summary);
if (full && summary.failuresToPrint.length && !this._omitFailures)
this._printFailures(summary.failuresToPrint);
this._printSlowTests();
this._printSummary(summaryMessage);
}
_printFailures(failures) {
this.writeLine("");
failures.forEach((test, index) => {
this.writeLine(this.formatFailure(test, index + 1));
});
}
_printSlowTests() {
const slowTests = this.getSlowTests();
slowTests.forEach(([file, duration]) => {
this.writeLine(this.screen.colors.yellow(" Slow test file: ") + file + this.screen.colors.yellow(` (${(0, import_utilsBundle.ms)(duration)})`));
});
if (slowTests.length)
this.writeLine(this.screen.colors.yellow(" Consider running tests from slow files in parallel. See: https://playwright.dev/docs/test-parallel"));
}
_printSummary(summary) {
if (summary.trim())
this.writeLine(summary);
}
willRetry(test) {
return test.outcome() === "unexpected" && test.results.length <= test.retries;
}
formatTestTitle(test, step, omitLocation = false) {
return formatTestTitle(this.screen, this.config, test, step, omitLocation);
}
formatTestHeader(test, options = {}) {
return formatTestHeader(this.screen, this.config, test, options);
}
formatFailure(test, index) {
return formatFailure(this.screen, this.config, test, index);
}
formatError(error) {
return formatError(this.screen, error);
}
writeLine(line) {
this.screen.stdout?.write(line ? line + "\n" : "\n");
}
}
function formatFailure(screen, config, test, index) {
const lines = [];
const header = formatTestHeader(screen, config, test, { indent: " ", index, mode: "error" });
lines.push(screen.colors.red(header));
for (const result of test.results) {
const resultLines = [];
const errors = formatResultFailure(screen, test, result, " ");
if (!errors.length)
continue;
if (result.retry) {
resultLines.push("");
resultLines.push(screen.colors.gray(separator(screen, ` Retry #${result.retry}`)));
}
resultLines.push(...errors.map((error) => "\n" + error.message));
const attachmentGroups = groupAttachments(result.attachments);
for (let i = 0; i < attachmentGroups.length; ++i) {
const attachment = attachmentGroups[i];
if (attachment.name === "error-context" && attachment.path) {
resultLines.push("");
resultLines.push(screen.colors.dim(` Error Context: ${relativeFilePath(screen, config, attachment.path)}`));
continue;
}
if (attachment.name.startsWith("_"))
continue;
const hasPrintableContent = attachment.contentType.startsWith("text/");
if (!attachment.path && !hasPrintableContent)
continue;
resultLines.push("");
resultLines.push(screen.colors.dim(separator(screen, ` attachment #${i + 1}: ${screen.colors.bold(attachment.name)} (${attachment.contentType})`)));
if (attachment.actual?.path) {
if (attachment.expected?.path) {
const expectedPath = relativeFilePath(screen, config, attachment.expected.path);
resultLines.push(screen.colors.dim(` Expected: ${expectedPath}`));
}
const actualPath = relativeFilePath(screen, config, attachment.actual.path);
resultLines.push(screen.colors.dim(` Received: ${actualPath}`));
if (attachment.previous?.path) {
const previousPath = relativeFilePath(screen, config, attachment.previous.path);
resultLines.push(screen.colors.dim(` Previous: ${previousPath}`));
}
if (attachment.diff?.path) {
const diffPath = relativeFilePath(screen, config, attachment.diff.path);
resultLines.push(screen.colors.dim(` Diff: ${diffPath}`));
}
} else if (attachment.path) {
const relativePath = relativeFilePath(screen, config, attachment.path);
resultLines.push(screen.colors.dim(` ${relativePath}`));
if (attachment.name === "trace") {
const packageManagerCommand = (0, import_utils.getPackageManagerExecCommand)();
resultLines.push(screen.colors.dim(` Usage:`));
resultLines.push("");
resultLines.push(screen.colors.dim(` ${packageManagerCommand} playwright show-trace ${quotePathIfNeeded(relativePath)}`));
resultLines.push("");
}
} else {
if (attachment.contentType.startsWith("text/") && attachment.body) {
let text = attachment.body.toString();
if (text.length > 300)
text = text.slice(0, 300) + "...";
for (const line of text.split("\n"))
resultLines.push(screen.colors.dim(` ${line}`));
}
}
resultLines.push(screen.colors.dim(separator(screen, " ")));
}
lines.push(...resultLines);
}
lines.push("");
return lines.join("\n");
}
function formatRetry(screen, result) {
const retryLines = [];
if (result.retry) {
retryLines.push("");
retryLines.push(screen.colors.gray(separator(screen, ` Retry #${result.retry}`)));
}
return retryLines;
}
function quotePathIfNeeded(path2) {
if (/\s/.test(path2))
return `"${path2}"`;
return path2;
}
function formatResultFailure(screen, test, result, initialIndent) {
const errorDetails = [];
if (result.status === "passed" && test.expectedStatus === "failed") {
errorDetails.push({
message: indent(screen.colors.red(`Expected to fail, but passed.`), initialIndent)
});
}
if (result.status === "interrupted") {
errorDetails.push({
message: indent(screen.colors.red(`Test was interrupted.`), initialIndent)
});
}
for (const error of result.errors) {
const formattedError = formatError(screen, error);
errorDetails.push({
message: indent(formattedError.message, initialIndent),
location: formattedError.location
});
}
return errorDetails;
}
function relativeFilePath(screen, config, file) {
if (screen.resolveFiles === "cwd")
return import_path.default.relative(process.cwd(), file);
return import_path.default.relative(config.rootDir, file);
}
function relativeTestPath(screen, config, test) {
return relativeFilePath(screen, config, test.location.file);
}
function stepSuffix(step) {
const stepTitles = step ? step.titlePath() : [];
return stepTitles.map((t) => t.split("\n")[0]).map((t) => " \u203A " + t).join("");
}
function formatTestTitle(screen, config, test, step, omitLocation = false) {
const [, projectName, , ...titles] = test.titlePath();
let location;
if (omitLocation)
location = `${relativeTestPath(screen, config, test)}`;
else
location = `${relativeTestPath(screen, config, test)}:${test.location.line}:${test.location.column}`;
const projectTitle = projectName ? `[${projectName}] \u203A ` : "";
const testTitle = `${projectTitle}${location} \u203A ${titles.join(" \u203A ")}`;
const extraTags = test.tags.filter((t) => !testTitle.includes(t));
return `${testTitle}${stepSuffix(step)}${extraTags.length ? " " + extraTags.join(" ") : ""}`;
}
function formatTestHeader(screen, config, test, options = {}) {
const title = formatTestTitle(screen, config, test);
const header = `${options.indent || ""}${options.index ? options.index + ") " : ""}${title}`;
let fullHeader = header;
if (options.mode === "error") {
const stepPaths = /* @__PURE__ */ new Set();
for (const result of test.results.filter((r) => !!r.errors.length)) {
const stepPath = [];
const visit = (steps) => {
const errors = steps.filter((s) => s.error);
if (errors.length > 1)
return;
if (errors.length === 1 && errors[0].category === "test.step") {
stepPath.push(errors[0].title);
visit(errors[0].steps);
}
};
visit(result.steps);
stepPaths.add(["", ...stepPath].join(" \u203A "));
}
fullHeader = header + (stepPaths.size === 1 ? stepPaths.values().next().value : "");
}
return separator(screen, fullHeader);
}
function formatError(screen, error) {
const message = error.message || error.value || "";
const stack = error.stack;
if (!stack && !error.location)
return { message };
const tokens = [];
const parsedStack = stack ? prepareErrorStack(stack) : void 0;
tokens.push(parsedStack?.message || message);
if (error.snippet) {
let snippet = error.snippet;
if (!screen.colors.enabled)
snippet = (0, import_util.stripAnsiEscapes)(snippet);
tokens.push("");
tokens.push(snippet);
}
if (parsedStack && parsedStack.stackLines.length)
tokens.push(screen.colors.dim(parsedStack.stackLines.join("\n")));
let location = error.location;
if (parsedStack && !location)
location = parsedStack.location;
if (error.cause)
tokens.push(screen.colors.dim("[cause]: ") + formatError(screen, error.cause).message);
return {
location,
message: tokens.join("\n")
};
}
function separator(screen, text = "") {
if (text)
text += " ";
const columns = Math.min(100, screen.ttyWidth || 100);
return text + screen.colors.dim("\u2500".repeat(Math.max(0, columns - (0, import_util.stripAnsiEscapes)(text).length)));
}
function indent(lines, tab) {
return lines.replace(/^(?=.+$)/gm, tab);
}
function prepareErrorStack(stack) {
return (0, import_utils.parseErrorStack)(stack, import_path.default.sep, !!process.env.PWDEBUGIMPL);
}
function characterWidth(c) {
return import_utilsBundle2.getEastAsianWidth.eastAsianWidth(c.codePointAt(0));
}
function stringWidth(v) {
let width = 0;
for (const { segment } of new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(v))
width += characterWidth(segment);
return width;
}
function suffixOfWidth(v, width) {
const segments = [...new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(v)];
let suffixBegin = v.length;
for (const { segment, index } of segments.reverse()) {
const segmentWidth = stringWidth(segment);
if (segmentWidth > width)
break;
width -= segmentWidth;
suffixBegin = index;
}
return v.substring(suffixBegin);
}
function fitToWidth(line, width, prefix) {
const prefixLength = prefix ? (0, import_util.stripAnsiEscapes)(prefix).length : 0;
width -= prefixLength;
if (stringWidth(line) <= width)
return line;
const parts = line.split(import_util.ansiRegex);
const taken = [];
for (let i = parts.length - 1; i >= 0; i--) {
if (i % 2) {
taken.push(parts[i]);
} else {
let part = suffixOfWidth(parts[i], width);
const wasTruncated = part.length < parts[i].length;
if (wasTruncated && parts[i].length > 0) {
part = "\u2026" + suffixOfWidth(parts[i], width - 1);
}
taken.push(part);
width -= stringWidth(part);
}
}
return taken.reverse().join("");
}
function resolveFromEnv(name) {
const value = process.env[name];
if (value)
return import_path.default.resolve(process.cwd(), value);
return void 0;
}
function resolveOutputFile(reporterName, options) {
const name = reporterName.toUpperCase();
let outputFile = resolveFromEnv(`PLAYWRIGHT_${name}_OUTPUT_FILE`);
if (!outputFile && options.outputFile)
outputFile = import_path.default.resolve(options.configDir, options.outputFile);
if (outputFile)
return { outputFile };
let outputDir = resolveFromEnv(`PLAYWRIGHT_${name}_OUTPUT_DIR`);
if (!outputDir && options.outputDir)
outputDir = import_path.default.resolve(options.configDir, options.outputDir);
if (!outputDir && options.default)
outputDir = (0, import_util.resolveReporterOutputPath)(options.default.outputDir, options.configDir, void 0);
if (!outputDir)
outputDir = options.configDir;
const reportName = process.env[`PLAYWRIGHT_${name}_OUTPUT_NAME`] ?? options.fileName ?? options.default?.fileName;
if (!reportName)
return void 0;
outputFile = import_path.default.resolve(outputDir, reportName);
return { outputFile, outputDir };
}
function groupAttachments(attachments) {
const result = [];
const attachmentsByPrefix = /* @__PURE__ */ new Map();
for (const attachment of attachments) {
if (!attachment.path) {
result.push(attachment);
continue;
}
const match = attachment.name.match(/^(.*)-(expected|actual|diff|previous)(\.[^.]+)?$/);
if (!match) {
result.push(attachment);
continue;
}
const [, name, category] = match;
let group = attachmentsByPrefix.get(name);
if (!group) {
group = { ...attachment, name };
attachmentsByPrefix.set(name, group);
result.push(group);
}
if (category === "expected")
group.expected = attachment;
else if (category === "actual")
group.actual = attachment;
else if (category === "diff")
group.diff = attachment;
else if (category === "previous")
group.previous = attachment;
}
return result;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TerminalReporter,
fitToWidth,
formatError,
formatFailure,
formatResultFailure,
formatRetry,
internalScreen,
kOutputSymbol,
nonTerminalScreen,
prepareErrorStack,
relativeFilePath,
resolveOutputFile,
separator,
stepSuffix,
terminalScreen
});

135
node_modules/playwright/lib/reporters/blob.js generated vendored Normal file
View File

@@ -0,0 +1,135 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var blob_exports = {};
__export(blob_exports, {
BlobReporter: () => BlobReporter,
currentBlobReportVersion: () => currentBlobReportVersion
});
module.exports = __toCommonJS(blob_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_stream = require("stream");
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_zipBundle = require("playwright-core/lib/zipBundle");
var import_base = require("./base");
var import_teleEmitter = require("./teleEmitter");
const currentBlobReportVersion = 2;
class BlobReporter extends import_teleEmitter.TeleReporterEmitter {
constructor(options) {
super((message) => this._messages.push(message));
this._messages = [];
this._attachments = [];
this._options = options;
if (this._options.fileName && !this._options.fileName.endsWith(".zip"))
throw new Error(`Blob report file name must end with .zip extension: ${this._options.fileName}`);
this._salt = (0, import_utils2.createGuid)();
}
onConfigure(config) {
const metadata = {
version: currentBlobReportVersion,
userAgent: (0, import_utils2.getUserAgent)(),
name: process.env.PWTEST_BOT_NAME,
shard: config.shard ?? void 0,
pathSeparator: import_path.default.sep
};
this._messages.push({
method: "onBlobReportMetadata",
params: metadata
});
this._config = config;
super.onConfigure(config);
}
async onEnd(result) {
await super.onEnd(result);
const zipFileName = await this._prepareOutputFile();
const zipFile = new import_zipBundle.yazl.ZipFile();
const zipFinishPromise = new import_utils2.ManualPromise();
const finishPromise = zipFinishPromise.catch((e) => {
throw new Error(`Failed to write report ${zipFileName}: ` + e.message);
});
zipFile.on("error", (error) => zipFinishPromise.reject(error));
zipFile.outputStream.pipe(import_fs.default.createWriteStream(zipFileName)).on("close", () => {
zipFinishPromise.resolve(void 0);
}).on("error", (error) => zipFinishPromise.reject(error));
for (const { originalPath, zipEntryPath } of this._attachments) {
if (!import_fs.default.statSync(originalPath, { throwIfNoEntry: false })?.isFile())
continue;
zipFile.addFile(originalPath, zipEntryPath);
}
const lines = this._messages.map((m) => JSON.stringify(m) + "\n");
const content = import_stream.Readable.from(lines);
zipFile.addReadStream(content, "report.jsonl");
zipFile.end();
await finishPromise;
}
async _prepareOutputFile() {
const { outputFile, outputDir } = (0, import_base.resolveOutputFile)("BLOB", {
...this._options,
default: {
fileName: this._defaultReportName(this._config),
outputDir: "blob-report"
}
});
if (!process.env.PWTEST_BLOB_DO_NOT_REMOVE)
await (0, import_utils.removeFolders)([outputDir]);
await import_fs.default.promises.mkdir(import_path.default.dirname(outputFile), { recursive: true });
return outputFile;
}
_defaultReportName(config) {
let reportName = "report";
if (this._options._commandHash)
reportName += "-" + (0, import_utils.sanitizeForFilePath)(this._options._commandHash);
if (config.shard) {
const paddedNumber = `${config.shard.current}`.padStart(`${config.shard.total}`.length, "0");
reportName = `${reportName}-${paddedNumber}`;
}
return `${reportName}.zip`;
}
_serializeAttachments(attachments) {
return super._serializeAttachments(attachments).map((attachment) => {
if (!attachment.path)
return attachment;
const sha1 = (0, import_utils2.calculateSha1)(attachment.path + this._salt);
const extension = import_utilsBundle.mime.getExtension(attachment.contentType) || "dat";
const newPath = `resources/${sha1}.${extension}`;
this._attachments.push({ originalPath: attachment.path, zipEntryPath: newPath });
return {
...attachment,
path: newPath
};
});
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
BlobReporter,
currentBlobReportVersion
});

82
node_modules/playwright/lib/reporters/dot.js generated vendored Normal file
View File

@@ -0,0 +1,82 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var dot_exports = {};
__export(dot_exports, {
default: () => dot_default
});
module.exports = __toCommonJS(dot_exports);
var import_base = require("./base");
class DotReporter extends import_base.TerminalReporter {
constructor() {
super(...arguments);
this._counter = 0;
}
onBegin(suite) {
super.onBegin(suite);
this.writeLine(this.generateStartingMessage());
}
onStdOut(chunk, test, result) {
super.onStdOut(chunk, test, result);
if (!this.config.quiet)
this.screen.stdout.write(chunk);
}
onStdErr(chunk, test, result) {
super.onStdErr(chunk, test, result);
if (!this.config.quiet)
this.screen.stderr.write(chunk);
}
onTestEnd(test, result) {
super.onTestEnd(test, result);
if (this._counter === 80) {
this.screen.stdout.write("\n");
this._counter = 0;
}
++this._counter;
if (result.status === "skipped") {
this.screen.stdout.write(this.screen.colors.yellow("\xB0"));
return;
}
if (this.willRetry(test)) {
this.screen.stdout.write(this.screen.colors.gray("\xD7"));
return;
}
switch (test.outcome()) {
case "expected":
this.screen.stdout.write(this.screen.colors.green("\xB7"));
break;
case "unexpected":
this.screen.stdout.write(this.screen.colors.red(result.status === "timedOut" ? "T" : "F"));
break;
case "flaky":
this.screen.stdout.write(this.screen.colors.yellow("\xB1"));
break;
}
}
onError(error) {
super.onError(error);
this.writeLine("\n" + this.formatError(error).message);
this._counter = 0;
}
async onEnd(result) {
await super.onEnd(result);
this.screen.stdout.write("\n");
this.epilogue(true);
}
}
var dot_default = DotReporter;

32
node_modules/playwright/lib/reporters/empty.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var empty_exports = {};
__export(empty_exports, {
default: () => empty_default
});
module.exports = __toCommonJS(empty_exports);
class EmptyReporter {
version() {
return "v2";
}
printsToStdio() {
return false;
}
}
var empty_default = EmptyReporter;

128
node_modules/playwright/lib/reporters/github.js generated vendored Normal file
View File

@@ -0,0 +1,128 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var github_exports = {};
__export(github_exports, {
GitHubReporter: () => GitHubReporter,
default: () => github_default
});
module.exports = __toCommonJS(github_exports);
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_base = require("./base");
var import_util = require("../util");
class GitHubLogger {
_log(message, type = "notice", options = {}) {
message = message.replace(/\n/g, "%0A");
const configs = Object.entries(options).map(([key, option]) => `${key}=${option}`).join(",");
process.stdout.write((0, import_util.stripAnsiEscapes)(`::${type} ${configs}::${message}
`));
}
debug(message, options) {
this._log(message, "debug", options);
}
error(message, options) {
this._log(message, "error", options);
}
notice(message, options) {
this._log(message, "notice", options);
}
warning(message, options) {
this._log(message, "warning", options);
}
}
class GitHubReporter extends import_base.TerminalReporter {
constructor(options = {}) {
super(options);
this.githubLogger = new GitHubLogger();
this.screen = { ...this.screen, colors: import_utils.noColors };
}
printsToStdio() {
return false;
}
async onEnd(result) {
await super.onEnd(result);
this._printAnnotations();
}
onError(error) {
const errorMessage = this.formatError(error).message;
this.githubLogger.error(errorMessage);
}
_printAnnotations() {
const summary = this.generateSummary();
const summaryMessage = this.generateSummaryMessage(summary);
if (summary.failuresToPrint.length)
this._printFailureAnnotations(summary.failuresToPrint);
this._printSlowTestAnnotations();
this._printSummaryAnnotation(summaryMessage);
}
_printSlowTestAnnotations() {
this.getSlowTests().forEach(([file, duration]) => {
const filePath = workspaceRelativePath(import_path.default.join(process.cwd(), file));
this.githubLogger.warning(`${filePath} took ${(0, import_utilsBundle.ms)(duration)}`, {
title: "Slow Test",
file: filePath
});
});
}
_printSummaryAnnotation(summary) {
this.githubLogger.notice(summary, {
title: "\u{1F3AD} Playwright Run Summary"
});
}
_printFailureAnnotations(failures) {
failures.forEach((test, index) => {
const title = this.formatTestTitle(test);
const header = this.formatTestHeader(test, { indent: " ", index: index + 1, mode: "error" });
for (const result of test.results) {
const errors = (0, import_base.formatResultFailure)(this.screen, test, result, " ");
for (const error of errors) {
const options = {
file: workspaceRelativePath(error.location?.file || test.location.file),
title
};
if (error.location) {
options.line = error.location.line;
options.col = error.location.column;
}
const message = [header, ...(0, import_base.formatRetry)(this.screen, result), error.message].join("\n");
this.githubLogger.error(message, options);
}
}
});
}
}
function workspaceRelativePath(filePath) {
return import_path.default.relative(process.env["GITHUB_WORKSPACE"] ?? "", filePath);
}
var github_default = GitHubReporter;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
GitHubReporter
});

631
node_modules/playwright/lib/reporters/html.js generated vendored Normal file
View File

@@ -0,0 +1,631 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var html_exports = {};
__export(html_exports, {
default: () => html_default,
showHTMLReport: () => showHTMLReport,
startHtmlReportServer: () => startHtmlReportServer
});
module.exports = __toCommonJS(html_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_stream = require("stream");
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_utilsBundle2 = require("playwright-core/lib/utilsBundle");
var import_zipBundle = require("playwright-core/lib/zipBundle");
var import_base = require("./base");
var import_babelBundle = require("../transform/babelBundle");
var import_util = require("../util");
const htmlReportOptions = ["always", "never", "on-failure"];
const isHtmlReportOption = (type) => {
return htmlReportOptions.includes(type);
};
class HtmlReporter {
constructor(options) {
this._topLevelErrors = [];
this._options = options;
}
version() {
return "v2";
}
printsToStdio() {
return false;
}
onConfigure(config) {
this.config = config;
}
onBegin(suite) {
const { outputFolder, open: open2, attachmentsBaseURL, host, port } = this._resolveOptions();
this._outputFolder = outputFolder;
this._open = open2;
this._host = host;
this._port = port;
this._attachmentsBaseURL = attachmentsBaseURL;
const reportedWarnings = /* @__PURE__ */ new Set();
for (const project of this.config.projects) {
if (this._isSubdirectory(outputFolder, project.outputDir) || this._isSubdirectory(project.outputDir, outputFolder)) {
const key = outputFolder + "|" + project.outputDir;
if (reportedWarnings.has(key))
continue;
reportedWarnings.add(key);
writeLine(import_utils2.colors.red(`Configuration Error: HTML reporter output folder clashes with the tests output folder:`));
writeLine(`
html reporter folder: ${import_utils2.colors.bold(outputFolder)}
test results folder: ${import_utils2.colors.bold(project.outputDir)}`);
writeLine("");
writeLine(`HTML reporter will clear its output directory prior to being generated, which will lead to the artifact loss.
`);
}
}
this.suite = suite;
}
_resolveOptions() {
const outputFolder = reportFolderFromEnv() ?? (0, import_util.resolveReporterOutputPath)("playwright-report", this._options.configDir, this._options.outputFolder);
return {
outputFolder,
open: getHtmlReportOptionProcessEnv() || this._options.open || "on-failure",
attachmentsBaseURL: process.env.PLAYWRIGHT_HTML_ATTACHMENTS_BASE_URL || this._options.attachmentsBaseURL || "data/",
host: process.env.PLAYWRIGHT_HTML_HOST || this._options.host,
port: process.env.PLAYWRIGHT_HTML_PORT ? +process.env.PLAYWRIGHT_HTML_PORT : this._options.port
};
}
_isSubdirectory(parentDir, dir) {
const relativePath = import_path.default.relative(parentDir, dir);
return !!relativePath && !relativePath.startsWith("..") && !import_path.default.isAbsolute(relativePath);
}
onError(error) {
this._topLevelErrors.push(error);
}
async onEnd(result) {
const projectSuites = this.suite.suites;
await (0, import_utils.removeFolders)([this._outputFolder]);
let noSnippets;
if (process.env.PLAYWRIGHT_HTML_NO_SNIPPETS === "false" || process.env.PLAYWRIGHT_HTML_NO_SNIPPETS === "0")
noSnippets = false;
else if (process.env.PLAYWRIGHT_HTML_NO_SNIPPETS)
noSnippets = true;
noSnippets = noSnippets || this._options.noSnippets;
const builder = new HtmlBuilder(this.config, this._outputFolder, this._attachmentsBaseURL, process.env.PLAYWRIGHT_HTML_TITLE || this._options.title, noSnippets);
this._buildResult = await builder.build(this.config.metadata, projectSuites, result, this._topLevelErrors);
}
async onExit() {
if (process.env.CI || !this._buildResult)
return;
const { ok, singleTestId } = this._buildResult;
const shouldOpen = !this._options._isTestServer && (this._open === "always" || !ok && this._open === "on-failure");
if (shouldOpen) {
await showHTMLReport(this._outputFolder, this._host, this._port, singleTestId);
} else if (this._options._mode === "test" && !this._options._isTestServer) {
const packageManagerCommand = (0, import_utils.getPackageManagerExecCommand)();
const relativeReportPath = this._outputFolder === standaloneDefaultFolder() ? "" : " " + import_path.default.relative(process.cwd(), this._outputFolder);
const hostArg = this._host ? ` --host ${this._host}` : "";
const portArg = this._port ? ` --port ${this._port}` : "";
writeLine("");
writeLine("To open last HTML report run:");
writeLine(import_utils2.colors.cyan(`
${packageManagerCommand} playwright show-report${relativeReportPath}${hostArg}${portArg}
`));
}
}
}
function reportFolderFromEnv() {
const envValue = process.env.PLAYWRIGHT_HTML_OUTPUT_DIR || process.env.PLAYWRIGHT_HTML_REPORT;
return envValue ? import_path.default.resolve(envValue) : void 0;
}
function getHtmlReportOptionProcessEnv() {
const htmlOpenEnv = process.env.PLAYWRIGHT_HTML_OPEN || process.env.PW_TEST_HTML_REPORT_OPEN;
if (!htmlOpenEnv)
return void 0;
if (!isHtmlReportOption(htmlOpenEnv)) {
writeLine(import_utils2.colors.red(`Configuration Error: HTML reporter Invalid value for PLAYWRIGHT_HTML_OPEN: ${htmlOpenEnv}. Valid values are: ${htmlReportOptions.join(", ")}`));
return void 0;
}
return htmlOpenEnv;
}
function standaloneDefaultFolder() {
return reportFolderFromEnv() ?? (0, import_util.resolveReporterOutputPath)("playwright-report", process.cwd(), void 0);
}
async function showHTMLReport(reportFolder, host = "localhost", port, testId) {
const folder = reportFolder ?? standaloneDefaultFolder();
try {
(0, import_utils.assert)(import_fs.default.statSync(folder).isDirectory());
} catch (e) {
writeLine(import_utils2.colors.red(`No report found at "${folder}"`));
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
return;
}
const server = startHtmlReportServer(folder);
await server.start({ port, host, preferredPort: port ? void 0 : 9323 });
let url = server.urlPrefix("human-readable");
writeLine("");
writeLine(import_utils2.colors.cyan(` Serving HTML report at ${url}. Press Ctrl+C to quit.`));
if (testId)
url += `#?testId=${testId}`;
url = url.replace("0.0.0.0", "localhost");
await (0, import_utilsBundle.open)(url, { wait: true }).catch(() => {
});
await new Promise(() => {
});
}
function startHtmlReportServer(folder) {
const server = new import_utils.HttpServer();
server.routePrefix("/", (request, response) => {
let relativePath = new URL("http://localhost" + request.url).pathname;
if (relativePath.startsWith("/trace/file")) {
const url = new URL("http://localhost" + request.url);
try {
return server.serveFile(request, response, url.searchParams.get("path"));
} catch (e) {
return false;
}
}
if (relativePath.endsWith("/stall.js"))
return true;
if (relativePath === "/")
relativePath = "/index.html";
const absolutePath = import_path.default.join(folder, ...relativePath.split("/"));
return server.serveFile(request, response, absolutePath);
});
return server;
}
class HtmlBuilder {
constructor(config, outputDir, attachmentsBaseURL, title, noSnippets = false) {
this._stepsInFile = new import_utils.MultiMap();
this._hasTraces = false;
this._config = config;
this._reportFolder = outputDir;
this._noSnippets = noSnippets;
import_fs.default.mkdirSync(this._reportFolder, { recursive: true });
this._dataZipFile = new import_zipBundle.yazl.ZipFile();
this._attachmentsBaseURL = attachmentsBaseURL;
this._title = title;
}
async build(metadata, projectSuites, result, topLevelErrors) {
const data = /* @__PURE__ */ new Map();
for (const projectSuite of projectSuites) {
for (const fileSuite of projectSuite.suites) {
const fileName = this._relativeLocation(fileSuite.location).file;
const fileId = (0, import_utils.calculateSha1)((0, import_utils.toPosixPath)(fileName)).slice(0, 20);
let fileEntry = data.get(fileId);
if (!fileEntry) {
fileEntry = {
testFile: { fileId, fileName, tests: [] },
testFileSummary: { fileId, fileName, tests: [], stats: emptyStats() }
};
data.set(fileId, fileEntry);
}
const { testFile, testFileSummary } = fileEntry;
const testEntries = [];
this._processSuite(fileSuite, projectSuite.project().name, [], testEntries);
for (const test of testEntries) {
testFile.tests.push(test.testCase);
testFileSummary.tests.push(test.testCaseSummary);
}
}
}
if (!this._noSnippets)
createSnippets(this._stepsInFile);
let ok = true;
for (const [fileId, { testFile, testFileSummary }] of data) {
const stats = testFileSummary.stats;
for (const test of testFileSummary.tests) {
if (test.outcome === "expected")
++stats.expected;
if (test.outcome === "skipped")
++stats.skipped;
if (test.outcome === "unexpected")
++stats.unexpected;
if (test.outcome === "flaky")
++stats.flaky;
++stats.total;
}
stats.ok = stats.unexpected + stats.flaky === 0;
if (!stats.ok)
ok = false;
const testCaseSummaryComparator = (t1, t2) => {
const w1 = (t1.outcome === "unexpected" ? 1e3 : 0) + (t1.outcome === "flaky" ? 1 : 0);
const w2 = (t2.outcome === "unexpected" ? 1e3 : 0) + (t2.outcome === "flaky" ? 1 : 0);
return w2 - w1;
};
testFileSummary.tests.sort(testCaseSummaryComparator);
this._addDataFile(fileId + ".json", testFile);
}
const htmlReport = {
metadata,
title: this._title,
startTime: result.startTime.getTime(),
duration: result.duration,
files: [...data.values()].map((e) => e.testFileSummary),
projectNames: projectSuites.map((r) => r.project().name),
stats: { ...[...data.values()].reduce((a, e) => addStats(a, e.testFileSummary.stats), emptyStats()) },
errors: topLevelErrors.map((error) => (0, import_base.formatError)(import_base.internalScreen, error).message)
};
htmlReport.files.sort((f1, f2) => {
const w1 = f1.stats.unexpected * 1e3 + f1.stats.flaky;
const w2 = f2.stats.unexpected * 1e3 + f2.stats.flaky;
return w2 - w1;
});
this._addDataFile("report.json", htmlReport);
let singleTestId;
if (htmlReport.stats.total === 1) {
const testFile = data.values().next().value.testFile;
singleTestId = testFile.tests[0].testId;
}
if (process.env.PW_HMR === "1") {
const redirectFile = import_path.default.join(this._reportFolder, "index.html");
await this._writeReportData(redirectFile);
async function redirect() {
const hmrURL = new URL("http://localhost:44224");
const popup = window.open(hmrURL);
const listener = (evt) => {
if (evt.source === popup && evt.data === "ready") {
const element = document.getElementById("playwrightReportBase64");
popup.postMessage(element?.textContent ?? "", hmrURL.origin);
window.removeEventListener("message", listener);
window.close();
}
};
window.addEventListener("message", listener);
}
import_fs.default.appendFileSync(redirectFile, `<script>(${redirect.toString()})()</script>`);
return { ok, singleTestId };
}
const appFolder = import_path.default.join(require.resolve("playwright-core"), "..", "lib", "vite", "htmlReport");
await (0, import_utils.copyFileAndMakeWritable)(import_path.default.join(appFolder, "index.html"), import_path.default.join(this._reportFolder, "index.html"));
if (this._hasTraces) {
const traceViewerFolder = import_path.default.join(require.resolve("playwright-core"), "..", "lib", "vite", "traceViewer");
const traceViewerTargetFolder = import_path.default.join(this._reportFolder, "trace");
const traceViewerAssetsTargetFolder = import_path.default.join(traceViewerTargetFolder, "assets");
import_fs.default.mkdirSync(traceViewerAssetsTargetFolder, { recursive: true });
for (const file of import_fs.default.readdirSync(traceViewerFolder)) {
if (file.endsWith(".map") || file.includes("watch") || file.includes("assets"))
continue;
await (0, import_utils.copyFileAndMakeWritable)(import_path.default.join(traceViewerFolder, file), import_path.default.join(traceViewerTargetFolder, file));
}
for (const file of import_fs.default.readdirSync(import_path.default.join(traceViewerFolder, "assets"))) {
if (file.endsWith(".map") || file.includes("xtermModule"))
continue;
await (0, import_utils.copyFileAndMakeWritable)(import_path.default.join(traceViewerFolder, "assets", file), import_path.default.join(traceViewerAssetsTargetFolder, file));
}
}
await this._writeReportData(import_path.default.join(this._reportFolder, "index.html"));
return { ok, singleTestId };
}
async _writeReportData(filePath) {
import_fs.default.appendFileSync(filePath, '<script id="playwrightReportBase64" type="application/zip">data:application/zip;base64,');
await new Promise((f) => {
this._dataZipFile.end(void 0, () => {
this._dataZipFile.outputStream.pipe(new Base64Encoder()).pipe(import_fs.default.createWriteStream(filePath, { flags: "a" })).on("close", f);
});
});
import_fs.default.appendFileSync(filePath, "</script>");
}
_addDataFile(fileName, data) {
this._dataZipFile.addBuffer(Buffer.from(JSON.stringify(data)), fileName);
}
_processSuite(suite, projectName, path2, outTests) {
const newPath = [...path2, suite.title];
suite.entries().forEach((e) => {
if (e.type === "test")
outTests.push(this._createTestEntry(e, projectName, newPath));
else
this._processSuite(e, projectName, newPath, outTests);
});
}
_createTestEntry(test, projectName, path2) {
const duration = test.results.reduce((a, r) => a + r.duration, 0);
const location = this._relativeLocation(test.location);
path2 = path2.slice(1).filter((path3) => path3.length > 0);
const results = test.results.map((r) => this._createTestResult(test, r));
return {
testCase: {
testId: test.id,
title: test.title,
projectName,
location,
duration,
annotations: this._serializeAnnotations(test.annotations),
tags: test.tags,
outcome: test.outcome(),
path: path2,
results,
ok: test.outcome() === "expected" || test.outcome() === "flaky"
},
testCaseSummary: {
testId: test.id,
title: test.title,
projectName,
location,
duration,
annotations: this._serializeAnnotations(test.annotations),
tags: test.tags,
outcome: test.outcome(),
path: path2,
ok: test.outcome() === "expected" || test.outcome() === "flaky",
results: results.map((result) => {
return { attachments: result.attachments.map((a) => ({ name: a.name, contentType: a.contentType, path: a.path })) };
})
}
};
}
_serializeAttachments(attachments) {
let lastAttachment;
return attachments.map((a) => {
if (a.name === "trace")
this._hasTraces = true;
if ((a.name === "stdout" || a.name === "stderr") && a.contentType === "text/plain") {
if (lastAttachment && lastAttachment.name === a.name && lastAttachment.contentType === a.contentType) {
lastAttachment.body += (0, import_util.stripAnsiEscapes)(a.body);
return null;
}
a.body = (0, import_util.stripAnsiEscapes)(a.body);
lastAttachment = a;
return a;
}
if (a.path) {
let fileName = a.path;
try {
const buffer = import_fs.default.readFileSync(a.path);
const sha1 = (0, import_utils.calculateSha1)(buffer) + import_path.default.extname(a.path);
fileName = this._attachmentsBaseURL + sha1;
import_fs.default.mkdirSync(import_path.default.join(this._reportFolder, "data"), { recursive: true });
import_fs.default.writeFileSync(import_path.default.join(this._reportFolder, "data", sha1), buffer);
} catch (e) {
}
return {
name: a.name,
contentType: a.contentType,
path: fileName,
body: a.body
};
}
if (a.body instanceof Buffer) {
if (isTextContentType(a.contentType)) {
const charset = a.contentType.match(/charset=(.*)/)?.[1];
try {
const body = a.body.toString(charset || "utf-8");
return {
name: a.name,
contentType: a.contentType,
body
};
} catch (e) {
}
}
import_fs.default.mkdirSync(import_path.default.join(this._reportFolder, "data"), { recursive: true });
const extension = (0, import_utils.sanitizeForFilePath)(import_path.default.extname(a.name).replace(/^\./, "")) || import_utilsBundle2.mime.getExtension(a.contentType) || "dat";
const sha1 = (0, import_utils.calculateSha1)(a.body) + "." + extension;
import_fs.default.writeFileSync(import_path.default.join(this._reportFolder, "data", sha1), a.body);
return {
name: a.name,
contentType: a.contentType,
path: this._attachmentsBaseURL + sha1
};
}
return {
name: a.name,
contentType: a.contentType,
body: a.body
};
}).filter(Boolean);
}
_serializeAnnotations(annotations) {
return annotations.map((a) => ({
type: a.type,
description: a.description === void 0 ? void 0 : String(a.description),
location: a.location ? {
file: a.location.file,
line: a.location.line,
column: a.location.column
} : void 0
}));
}
_createTestResult(test, result) {
return {
duration: result.duration,
startTime: result.startTime.toISOString(),
retry: result.retry,
steps: dedupeSteps(result.steps).map((s) => this._createTestStep(s, result)),
errors: (0, import_base.formatResultFailure)(import_base.internalScreen, test, result, "").map((error) => {
return {
message: error.message,
codeframe: error.location ? createErrorCodeframe(error.message, error.location) : void 0
};
}),
status: result.status,
annotations: this._serializeAnnotations(result.annotations),
attachments: this._serializeAttachments([
...result.attachments,
...result.stdout.map((m) => stdioAttachment(m, "stdout")),
...result.stderr.map((m) => stdioAttachment(m, "stderr"))
])
};
}
_createTestStep(dedupedStep, result) {
const { step, duration, count } = dedupedStep;
const skipped = dedupedStep.step.annotations?.find((a) => a.type === "skip");
let title = step.title;
if (skipped)
title = `${title} (skipped${skipped.description ? ": " + skipped.description : ""})`;
const testStep = {
title,
startTime: step.startTime.toISOString(),
duration,
steps: dedupeSteps(step.steps).map((s) => this._createTestStep(s, result)),
attachments: step.attachments.map((s) => {
const index = result.attachments.indexOf(s);
if (index === -1)
throw new Error("Unexpected, attachment not found");
return index;
}),
location: this._relativeLocation(step.location),
error: step.error?.message,
count,
skipped: !!skipped
};
if (step.location)
this._stepsInFile.set(step.location.file, testStep);
return testStep;
}
_relativeLocation(location) {
if (!location)
return void 0;
const file = (0, import_utils.toPosixPath)(import_path.default.relative(this._config.rootDir, location.file));
return {
file,
line: location.line,
column: location.column
};
}
}
const emptyStats = () => {
return {
total: 0,
expected: 0,
unexpected: 0,
flaky: 0,
skipped: 0,
ok: true
};
};
const addStats = (stats, delta) => {
stats.total += delta.total;
stats.skipped += delta.skipped;
stats.expected += delta.expected;
stats.unexpected += delta.unexpected;
stats.flaky += delta.flaky;
stats.ok = stats.ok && delta.ok;
return stats;
};
class Base64Encoder extends import_stream.Transform {
_transform(chunk, encoding, callback) {
if (this._remainder) {
chunk = Buffer.concat([this._remainder, chunk]);
this._remainder = void 0;
}
const remaining = chunk.length % 3;
if (remaining) {
this._remainder = chunk.slice(chunk.length - remaining);
chunk = chunk.slice(0, chunk.length - remaining);
}
chunk = chunk.toString("base64");
this.push(Buffer.from(chunk));
callback();
}
_flush(callback) {
if (this._remainder)
this.push(Buffer.from(this._remainder.toString("base64")));
callback();
}
}
function isTextContentType(contentType) {
return contentType.startsWith("text/") || contentType.startsWith("application/json");
}
function stdioAttachment(chunk, type) {
return {
name: type,
contentType: "text/plain",
body: typeof chunk === "string" ? chunk : chunk.toString("utf-8")
};
}
function dedupeSteps(steps) {
const result = [];
let lastResult = void 0;
for (const step of steps) {
const canDedupe = !step.error && step.duration >= 0 && step.location?.file && !step.steps.length;
const lastStep = lastResult?.step;
if (canDedupe && lastResult && lastStep && step.category === lastStep.category && step.title === lastStep.title && step.location?.file === lastStep.location?.file && step.location?.line === lastStep.location?.line && step.location?.column === lastStep.location?.column) {
++lastResult.count;
lastResult.duration += step.duration;
continue;
}
lastResult = { step, count: 1, duration: step.duration };
result.push(lastResult);
if (!canDedupe)
lastResult = void 0;
}
return result;
}
function createSnippets(stepsInFile) {
for (const file of stepsInFile.keys()) {
let source;
try {
source = import_fs.default.readFileSync(file, "utf-8") + "\n//";
} catch (e) {
continue;
}
const lines = source.split("\n").length;
const highlighted = (0, import_babelBundle.codeFrameColumns)(source, { start: { line: lines, column: 1 } }, { highlightCode: true, linesAbove: lines, linesBelow: 0 });
const highlightedLines = highlighted.split("\n");
const lineWithArrow = highlightedLines[highlightedLines.length - 1];
for (const step of stepsInFile.get(file)) {
if (step.location.line < 2 || step.location.line >= lines)
continue;
const snippetLines = highlightedLines.slice(step.location.line - 2, step.location.line + 1);
const index = lineWithArrow.indexOf("^");
const shiftedArrow = lineWithArrow.slice(0, index) + " ".repeat(step.location.column - 1) + lineWithArrow.slice(index);
snippetLines.splice(2, 0, shiftedArrow);
step.snippet = snippetLines.join("\n");
}
}
}
function createErrorCodeframe(message, location) {
let source;
try {
source = import_fs.default.readFileSync(location.file, "utf-8") + "\n//";
} catch (e) {
return;
}
return (0, import_babelBundle.codeFrameColumns)(
source,
{
start: {
line: location.line,
column: location.column
}
},
{
highlightCode: false,
linesAbove: 100,
linesBelow: 100,
message: (0, import_util.stripAnsiEscapes)(message).split("\n")[0] || void 0
}
);
}
function writeLine(line) {
process.stdout.write(line + "\n");
}
var html_default = HtmlReporter;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
showHTMLReport,
startHtmlReportServer
});

View File

@@ -0,0 +1,130 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var internalReporter_exports = {};
__export(internalReporter_exports, {
InternalReporter: () => InternalReporter
});
module.exports = __toCommonJS(internalReporter_exports);
var import_fs = __toESM(require("fs"));
var import_utils = require("playwright-core/lib/utils");
var import_base = require("./base");
var import_multiplexer = require("./multiplexer");
var import_test = require("../common/test");
var import_babelBundle = require("../transform/babelBundle");
var import_reporterV2 = require("./reporterV2");
class InternalReporter {
constructor(reporters) {
this._didBegin = false;
this._reporter = new import_multiplexer.Multiplexer(reporters.map(import_reporterV2.wrapReporterAsV2));
}
version() {
return "v2";
}
onConfigure(config) {
this._config = config;
this._startTime = /* @__PURE__ */ new Date();
this._monotonicStartTime = (0, import_utils.monotonicTime)();
this._reporter.onConfigure?.(config);
}
onBegin(suite) {
this._didBegin = true;
this._reporter.onBegin?.(suite);
}
onTestBegin(test, result) {
this._reporter.onTestBegin?.(test, result);
}
onStdOut(chunk, test, result) {
this._reporter.onStdOut?.(chunk, test, result);
}
onStdErr(chunk, test, result) {
this._reporter.onStdErr?.(chunk, test, result);
}
onTestEnd(test, result) {
this._addSnippetToTestErrors(test, result);
this._reporter.onTestEnd?.(test, result);
}
async onEnd(result) {
if (!this._didBegin) {
this.onBegin(new import_test.Suite("", "root"));
}
return await this._reporter.onEnd?.({
...result,
startTime: this._startTime,
duration: (0, import_utils.monotonicTime)() - this._monotonicStartTime
});
}
async onExit() {
await this._reporter.onExit?.();
}
onError(error) {
addLocationAndSnippetToError(this._config, error);
this._reporter.onError?.(error);
}
onStepBegin(test, result, step) {
this._reporter.onStepBegin?.(test, result, step);
}
onStepEnd(test, result, step) {
this._addSnippetToStepError(test, step);
this._reporter.onStepEnd?.(test, result, step);
}
printsToStdio() {
return this._reporter.printsToStdio ? this._reporter.printsToStdio() : true;
}
_addSnippetToTestErrors(test, result) {
for (const error of result.errors)
addLocationAndSnippetToError(this._config, error, test.location.file);
}
_addSnippetToStepError(test, step) {
if (step.error)
addLocationAndSnippetToError(this._config, step.error, test.location.file);
}
}
function addLocationAndSnippetToError(config, error, file) {
if (error.stack && !error.location)
error.location = (0, import_base.prepareErrorStack)(error.stack).location;
const location = error.location;
if (!location)
return;
try {
const tokens = [];
const source = import_fs.default.readFileSync(location.file, "utf8");
const codeFrame = (0, import_babelBundle.codeFrameColumns)(source, { start: location }, { highlightCode: true });
if (!file || import_fs.default.realpathSync(file) !== location.file) {
tokens.push(import_base.internalScreen.colors.gray(` at `) + `${(0, import_base.relativeFilePath)(import_base.internalScreen, config, location.file)}:${location.line}`);
tokens.push("");
}
tokens.push(codeFrame);
error.snippet = tokens.join("\n");
} catch (e) {
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
InternalReporter
});

254
node_modules/playwright/lib/reporters/json.js generated vendored Normal file
View File

@@ -0,0 +1,254 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var json_exports = {};
__export(json_exports, {
default: () => json_default,
serializePatterns: () => serializePatterns
});
module.exports = __toCommonJS(json_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_base = require("./base");
var import_config = require("../common/config");
class JSONReporter {
constructor(options) {
this._errors = [];
this._resolvedOutputFile = (0, import_base.resolveOutputFile)("JSON", options)?.outputFile;
}
version() {
return "v2";
}
printsToStdio() {
return !this._resolvedOutputFile;
}
onConfigure(config) {
this.config = config;
}
onBegin(suite) {
this.suite = suite;
}
onError(error) {
this._errors.push(error);
}
async onEnd(result) {
await outputReport(this._serializeReport(result), this._resolvedOutputFile);
}
_serializeReport(result) {
const report = {
config: {
...removePrivateFields(this.config),
rootDir: (0, import_utils.toPosixPath)(this.config.rootDir),
projects: this.config.projects.map((project) => {
return {
outputDir: (0, import_utils.toPosixPath)(project.outputDir),
repeatEach: project.repeatEach,
retries: project.retries,
metadata: project.metadata,
id: (0, import_config.getProjectId)(project),
name: project.name,
testDir: (0, import_utils.toPosixPath)(project.testDir),
testIgnore: serializePatterns(project.testIgnore),
testMatch: serializePatterns(project.testMatch),
timeout: project.timeout
};
})
},
suites: this._mergeSuites(this.suite.suites),
errors: this._errors,
stats: {
startTime: result.startTime.toISOString(),
duration: result.duration,
expected: 0,
skipped: 0,
unexpected: 0,
flaky: 0
}
};
for (const test of this.suite.allTests())
++report.stats[test.outcome()];
return report;
}
_mergeSuites(suites) {
const fileSuites = new import_utils.MultiMap();
for (const projectSuite of suites) {
const projectId = (0, import_config.getProjectId)(projectSuite.project());
const projectName = projectSuite.project().name;
for (const fileSuite of projectSuite.suites) {
const file = fileSuite.location.file;
const serialized = this._serializeSuite(projectId, projectName, fileSuite);
if (serialized)
fileSuites.set(file, serialized);
}
}
const results = [];
for (const [, suites2] of fileSuites) {
const result = {
title: suites2[0].title,
file: suites2[0].file,
column: 0,
line: 0,
specs: []
};
for (const suite of suites2)
this._mergeTestsFromSuite(result, suite);
results.push(result);
}
return results;
}
_relativeLocation(location) {
if (!location)
return { file: "", line: 0, column: 0 };
return {
file: (0, import_utils.toPosixPath)(import_path.default.relative(this.config.rootDir, location.file)),
line: location.line,
column: location.column
};
}
_locationMatches(s1, s2) {
return s1.file === s2.file && s1.line === s2.line && s1.column === s2.column;
}
_mergeTestsFromSuite(to, from) {
for (const fromSuite of from.suites || []) {
const toSuite = (to.suites || []).find((s) => s.title === fromSuite.title && this._locationMatches(s, fromSuite));
if (toSuite) {
this._mergeTestsFromSuite(toSuite, fromSuite);
} else {
if (!to.suites)
to.suites = [];
to.suites.push(fromSuite);
}
}
for (const spec of from.specs || []) {
const toSpec = to.specs.find((s) => s.title === spec.title && s.file === (0, import_utils.toPosixPath)(import_path.default.relative(this.config.rootDir, spec.file)) && s.line === spec.line && s.column === spec.column);
if (toSpec)
toSpec.tests.push(...spec.tests);
else
to.specs.push(spec);
}
}
_serializeSuite(projectId, projectName, suite) {
if (!suite.allTests().length)
return null;
const suites = suite.suites.map((suite2) => this._serializeSuite(projectId, projectName, suite2)).filter((s) => s);
return {
title: suite.title,
...this._relativeLocation(suite.location),
specs: suite.tests.map((test) => this._serializeTestSpec(projectId, projectName, test)),
suites: suites.length ? suites : void 0
};
}
_serializeTestSpec(projectId, projectName, test) {
return {
title: test.title,
ok: test.ok(),
tags: test.tags.map((tag) => tag.substring(1)),
// Strip '@'.
tests: [this._serializeTest(projectId, projectName, test)],
id: test.id,
...this._relativeLocation(test.location)
};
}
_serializeTest(projectId, projectName, test) {
return {
timeout: test.timeout,
annotations: test.annotations,
expectedStatus: test.expectedStatus,
projectId,
projectName,
results: test.results.map((r) => this._serializeTestResult(r, test)),
status: test.outcome()
};
}
_serializeTestResult(result, test) {
const steps = result.steps.filter((s) => s.category === "test.step");
const jsonResult = {
workerIndex: result.workerIndex,
parallelIndex: result.parallelIndex,
status: result.status,
duration: result.duration,
error: result.error,
errors: result.errors.map((e) => this._serializeError(e)),
stdout: result.stdout.map((s) => stdioEntry(s)),
stderr: result.stderr.map((s) => stdioEntry(s)),
retry: result.retry,
steps: steps.length ? steps.map((s) => this._serializeTestStep(s)) : void 0,
startTime: result.startTime.toISOString(),
annotations: result.annotations,
attachments: result.attachments.map((a) => ({
name: a.name,
contentType: a.contentType,
path: a.path,
body: a.body?.toString("base64")
}))
};
if (result.error?.stack)
jsonResult.errorLocation = (0, import_base.prepareErrorStack)(result.error.stack).location;
return jsonResult;
}
_serializeError(error) {
return (0, import_base.formatError)(import_base.nonTerminalScreen, error);
}
_serializeTestStep(step) {
const steps = step.steps.filter((s) => s.category === "test.step");
return {
title: step.title,
duration: step.duration,
error: step.error,
steps: steps.length ? steps.map((s) => this._serializeTestStep(s)) : void 0
};
}
}
async function outputReport(report, resolvedOutputFile) {
const reportString = JSON.stringify(report, void 0, 2);
if (resolvedOutputFile) {
await import_fs.default.promises.mkdir(import_path.default.dirname(resolvedOutputFile), { recursive: true });
await import_fs.default.promises.writeFile(resolvedOutputFile, reportString);
} else {
console.log(reportString);
}
}
function stdioEntry(s) {
if (typeof s === "string")
return { text: s };
return { buffer: s.toString("base64") };
}
function removePrivateFields(config) {
return Object.fromEntries(Object.entries(config).filter(([name, value]) => !name.startsWith("_")));
}
function serializePatterns(patterns) {
if (!Array.isArray(patterns))
patterns = [patterns];
return patterns.map((s) => s.toString());
}
var json_default = JSONReporter;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
serializePatterns
});

230
node_modules/playwright/lib/reporters/junit.js generated vendored Normal file
View File

@@ -0,0 +1,230 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var junit_exports = {};
__export(junit_exports, {
default: () => junit_default
});
module.exports = __toCommonJS(junit_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_base = require("./base");
var import_util = require("../util");
class JUnitReporter {
constructor(options) {
this.totalTests = 0;
this.totalFailures = 0;
this.totalSkipped = 0;
this.stripANSIControlSequences = false;
this.includeProjectInTestName = false;
this.stripANSIControlSequences = (0, import_utils.getAsBooleanFromENV)("PLAYWRIGHT_JUNIT_STRIP_ANSI", !!options.stripANSIControlSequences);
this.includeProjectInTestName = (0, import_utils.getAsBooleanFromENV)("PLAYWRIGHT_JUNIT_INCLUDE_PROJECT_IN_TEST_NAME", !!options.includeProjectInTestName);
this.configDir = options.configDir;
this.resolvedOutputFile = (0, import_base.resolveOutputFile)("JUNIT", options)?.outputFile;
}
version() {
return "v2";
}
printsToStdio() {
return !this.resolvedOutputFile;
}
onConfigure(config) {
this.config = config;
}
onBegin(suite) {
this.suite = suite;
this.timestamp = /* @__PURE__ */ new Date();
}
async onEnd(result) {
const children = [];
for (const projectSuite of this.suite.suites) {
for (const fileSuite of projectSuite.suites)
children.push(await this._buildTestSuite(projectSuite.title, fileSuite));
}
const tokens = [];
const self = this;
const root = {
name: "testsuites",
attributes: {
id: process.env[`PLAYWRIGHT_JUNIT_SUITE_ID`] || "",
name: process.env[`PLAYWRIGHT_JUNIT_SUITE_NAME`] || "",
tests: self.totalTests,
failures: self.totalFailures,
skipped: self.totalSkipped,
errors: 0,
time: result.duration / 1e3
},
children
};
serializeXML(root, tokens, this.stripANSIControlSequences);
const reportString = tokens.join("\n");
if (this.resolvedOutputFile) {
await import_fs.default.promises.mkdir(import_path.default.dirname(this.resolvedOutputFile), { recursive: true });
await import_fs.default.promises.writeFile(this.resolvedOutputFile, reportString);
} else {
console.log(reportString);
}
}
async _buildTestSuite(projectName, suite) {
let tests = 0;
let skipped = 0;
let failures = 0;
let duration = 0;
const children = [];
const testCaseNamePrefix = projectName && this.includeProjectInTestName ? `[${projectName}] ` : "";
for (const test of suite.allTests()) {
++tests;
if (test.outcome() === "skipped")
++skipped;
if (!test.ok())
++failures;
for (const result of test.results)
duration += result.duration;
await this._addTestCase(suite.title, testCaseNamePrefix, test, children);
}
this.totalTests += tests;
this.totalSkipped += skipped;
this.totalFailures += failures;
const entry = {
name: "testsuite",
attributes: {
name: suite.title,
timestamp: this.timestamp.toISOString(),
hostname: projectName,
tests,
failures,
skipped,
time: duration / 1e3,
errors: 0
},
children
};
return entry;
}
async _addTestCase(suiteName, namePrefix, test, entries) {
const entry = {
name: "testcase",
attributes: {
// Skip root, project, file
name: namePrefix + test.titlePath().slice(3).join(" \u203A "),
// filename
classname: suiteName,
time: test.results.reduce((acc, value) => acc + value.duration, 0) / 1e3
},
children: []
};
entries.push(entry);
const properties = {
name: "properties",
children: []
};
for (const annotation of test.annotations) {
const property = {
name: "property",
attributes: {
name: annotation.type,
value: annotation?.description ? annotation.description : ""
}
};
properties.children?.push(property);
}
if (properties.children?.length)
entry.children.push(properties);
if (test.outcome() === "skipped") {
entry.children.push({ name: "skipped" });
return;
}
if (!test.ok()) {
entry.children.push({
name: "failure",
attributes: {
message: `${import_path.default.basename(test.location.file)}:${test.location.line}:${test.location.column} ${test.title}`,
type: "FAILURE"
},
text: (0, import_util.stripAnsiEscapes)((0, import_base.formatFailure)(import_base.nonTerminalScreen, this.config, test))
});
}
const systemOut = [];
const systemErr = [];
for (const result of test.results) {
systemOut.push(...result.stdout.map((item) => item.toString()));
systemErr.push(...result.stderr.map((item) => item.toString()));
for (const attachment of result.attachments) {
if (!attachment.path)
continue;
let attachmentPath = import_path.default.relative(this.configDir, attachment.path);
try {
if (this.resolvedOutputFile)
attachmentPath = import_path.default.relative(import_path.default.dirname(this.resolvedOutputFile), attachment.path);
} catch {
systemOut.push(`
Warning: Unable to make attachment path ${attachment.path} relative to report output file ${this.resolvedOutputFile}`);
}
try {
await import_fs.default.promises.access(attachment.path);
systemOut.push(`
[[ATTACHMENT|${attachmentPath}]]
`);
} catch {
systemErr.push(`
Warning: attachment ${attachmentPath} is missing`);
}
}
}
if (systemOut.length)
entry.children.push({ name: "system-out", text: systemOut.join("") });
if (systemErr.length)
entry.children.push({ name: "system-err", text: systemErr.join("") });
}
}
function serializeXML(entry, tokens, stripANSIControlSequences) {
const attrs = [];
for (const [name, value] of Object.entries(entry.attributes || {}))
attrs.push(`${name}="${escape(String(value), stripANSIControlSequences, false)}"`);
tokens.push(`<${entry.name}${attrs.length ? " " : ""}${attrs.join(" ")}>`);
for (const child of entry.children || [])
serializeXML(child, tokens, stripANSIControlSequences);
if (entry.text)
tokens.push(escape(entry.text, stripANSIControlSequences, true));
tokens.push(`</${entry.name}>`);
}
const discouragedXMLCharacters = /[\u0000-\u0008\u000b-\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f]/g;
function escape(text, stripANSIControlSequences, isCharacterData) {
if (stripANSIControlSequences)
text = (0, import_util.stripAnsiEscapes)(text);
if (isCharacterData) {
text = "<![CDATA[" + text.replace(/]]>/g, "]]&gt;") + "]]>";
} else {
const escapeRe = /[&"'<>]/g;
text = text.replace(escapeRe, (c) => ({ "&": "&amp;", '"': "&quot;", "'": "&apos;", "<": "&lt;", ">": "&gt;" })[c]);
}
text = text.replace(discouragedXMLCharacters, "");
return text;
}
var junit_default = JUnitReporter;

113
node_modules/playwright/lib/reporters/line.js generated vendored Normal file
View File

@@ -0,0 +1,113 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var line_exports = {};
__export(line_exports, {
default: () => line_default
});
module.exports = __toCommonJS(line_exports);
var import_base = require("./base");
class LineReporter extends import_base.TerminalReporter {
constructor() {
super(...arguments);
this._current = 0;
this._failures = 0;
this._didBegin = false;
}
onBegin(suite) {
super.onBegin(suite);
const startingMessage = this.generateStartingMessage();
if (startingMessage) {
this.writeLine(startingMessage);
this.writeLine();
}
this._didBegin = true;
}
onStdOut(chunk, test, result) {
super.onStdOut(chunk, test, result);
this._dumpToStdio(test, chunk, this.screen.stdout);
}
onStdErr(chunk, test, result) {
super.onStdErr(chunk, test, result);
this._dumpToStdio(test, chunk, this.screen.stderr);
}
_dumpToStdio(test, chunk, stream) {
if (this.config.quiet)
return;
if (!process.env.PW_TEST_DEBUG_REPORTERS)
stream.write(`\x1B[1A\x1B[2K`);
if (test && this._lastTest !== test) {
const title = this.screen.colors.dim(this.formatTestTitle(test));
stream.write(this.fitToScreen(title) + `
`);
this._lastTest = test;
}
stream.write(chunk);
if (chunk[chunk.length - 1] !== "\n")
this.writeLine();
this.writeLine();
}
onTestBegin(test, result) {
++this._current;
this._updateLine(test, result, void 0);
}
onStepBegin(test, result, step) {
if (this.screen.isTTY && step.category === "test.step")
this._updateLine(test, result, step);
}
onStepEnd(test, result, step) {
if (this.screen.isTTY && step.category === "test.step")
this._updateLine(test, result, step.parent);
}
onTestEnd(test, result) {
super.onTestEnd(test, result);
if (!this.willRetry(test) && (test.outcome() === "flaky" || test.outcome() === "unexpected" || result.status === "interrupted")) {
if (!process.env.PW_TEST_DEBUG_REPORTERS)
this.screen.stdout.write(`\x1B[1A\x1B[2K`);
this.writeLine(this.formatFailure(test, ++this._failures));
this.writeLine();
}
}
_updateLine(test, result, step) {
const retriesPrefix = this.totalTestCount < this._current ? ` (retries)` : ``;
const prefix = `[${this._current}/${this.totalTestCount}]${retriesPrefix} `;
const currentRetrySuffix = result.retry ? this.screen.colors.yellow(` (retry #${result.retry})`) : "";
const title = this.formatTestTitle(test, step) + currentRetrySuffix;
if (process.env.PW_TEST_DEBUG_REPORTERS)
this.screen.stdout.write(`${prefix + title}
`);
else
this.screen.stdout.write(`\x1B[1A\x1B[2K${prefix + this.fitToScreen(title, prefix)}
`);
}
onError(error) {
super.onError(error);
const message = this.formatError(error).message + "\n";
if (!process.env.PW_TEST_DEBUG_REPORTERS && this._didBegin)
this.screen.stdout.write(`\x1B[1A\x1B[2K`);
this.screen.stdout.write(message);
this.writeLine();
}
async onEnd(result) {
if (!process.env.PW_TEST_DEBUG_REPORTERS && this._didBegin)
this.screen.stdout.write(`\x1B[1A\x1B[2K`);
await super.onEnd(result);
this.epilogue(false);
}
}
var line_default = LineReporter;

231
node_modules/playwright/lib/reporters/list.js generated vendored Normal file
View File

@@ -0,0 +1,231 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var list_exports = {};
__export(list_exports, {
default: () => list_default
});
module.exports = __toCommonJS(list_exports);
var import_utils = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_base = require("./base");
var import_util = require("../util");
const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === "win32" && process.env.TERM_PROGRAM !== "vscode" && !process.env.WT_SESSION;
const POSITIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? "ok" : "\u2713";
const NEGATIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? "x" : "\u2718";
class ListReporter extends import_base.TerminalReporter {
constructor(options) {
super(options);
this._lastRow = 0;
this._lastColumn = 0;
this._testRows = /* @__PURE__ */ new Map();
this._stepRows = /* @__PURE__ */ new Map();
this._resultIndex = /* @__PURE__ */ new Map();
this._stepIndex = /* @__PURE__ */ new Map();
this._needNewLine = false;
this._printSteps = (0, import_utils.getAsBooleanFromENV)("PLAYWRIGHT_LIST_PRINT_STEPS", options?.printSteps);
}
onBegin(suite) {
super.onBegin(suite);
const startingMessage = this.generateStartingMessage();
if (startingMessage) {
this.writeLine(startingMessage);
this.writeLine("");
}
}
onTestBegin(test, result) {
const index = String(this._resultIndex.size + 1);
this._resultIndex.set(result, index);
if (!this.screen.isTTY)
return;
this._maybeWriteNewLine();
this._testRows.set(test, this._lastRow);
const prefix = this._testPrefix(index, "");
const line = this.screen.colors.dim(this.formatTestTitle(test)) + this._retrySuffix(result);
this._appendLine(line, prefix);
}
onStdOut(chunk, test, result) {
super.onStdOut(chunk, test, result);
this._dumpToStdio(test, chunk, this.screen.stdout);
}
onStdErr(chunk, test, result) {
super.onStdErr(chunk, test, result);
this._dumpToStdio(test, chunk, this.screen.stderr);
}
getStepIndex(testIndex, result, step) {
if (this._stepIndex.has(step))
return this._stepIndex.get(step);
const ordinal = (result[lastStepOrdinalSymbol] || 0) + 1;
result[lastStepOrdinalSymbol] = ordinal;
const stepIndex = `${testIndex}.${ordinal}`;
this._stepIndex.set(step, stepIndex);
return stepIndex;
}
onStepBegin(test, result, step) {
if (step.category !== "test.step")
return;
const testIndex = this._resultIndex.get(result) || "";
if (!this.screen.isTTY)
return;
if (this._printSteps) {
this._maybeWriteNewLine();
this._stepRows.set(step, this._lastRow);
const prefix = this._testPrefix(this.getStepIndex(testIndex, result, step), "");
const line = test.title + this.screen.colors.dim((0, import_base.stepSuffix)(step));
this._appendLine(line, prefix);
} else {
this._updateOrAppendLine(this._testRows, test, this.screen.colors.dim(this.formatTestTitle(test, step)) + this._retrySuffix(result), this._testPrefix(testIndex, ""));
}
}
onStepEnd(test, result, step) {
if (step.category !== "test.step")
return;
const testIndex = this._resultIndex.get(result) || "";
if (!this._printSteps) {
if (this.screen.isTTY)
this._updateOrAppendLine(this._testRows, test, this.screen.colors.dim(this.formatTestTitle(test, step.parent)) + this._retrySuffix(result), this._testPrefix(testIndex, ""));
return;
}
const index = this.getStepIndex(testIndex, result, step);
const title = this.screen.isTTY ? test.title + this.screen.colors.dim((0, import_base.stepSuffix)(step)) : this.formatTestTitle(test, step);
const prefix = this._testPrefix(index, "");
let text = "";
if (step.error)
text = this.screen.colors.red(title);
else
text = title;
text += this.screen.colors.dim(` (${(0, import_utilsBundle.ms)(step.duration)})`);
this._updateOrAppendLine(this._stepRows, step, text, prefix);
}
_maybeWriteNewLine() {
if (this._needNewLine) {
this._needNewLine = false;
this.screen.stdout.write("\n");
++this._lastRow;
this._lastColumn = 0;
}
}
_updateLineCountAndNewLineFlagForOutput(text) {
this._needNewLine = text[text.length - 1] !== "\n";
if (!this.screen.ttyWidth)
return;
for (const ch of text) {
if (ch === "\n") {
this._lastColumn = 0;
++this._lastRow;
continue;
}
++this._lastColumn;
if (this._lastColumn > this.screen.ttyWidth) {
this._lastColumn = 0;
++this._lastRow;
}
}
}
_dumpToStdio(test, chunk, stream) {
if (this.config.quiet)
return;
const text = chunk.toString("utf-8");
this._updateLineCountAndNewLineFlagForOutput(text);
stream.write(chunk);
}
onTestEnd(test, result) {
super.onTestEnd(test, result);
const title = this.formatTestTitle(test);
let prefix = "";
let text = "";
let index = this._resultIndex.get(result);
if (!index) {
index = String(this._resultIndex.size + 1);
this._resultIndex.set(result, index);
}
if (result.status === "skipped") {
prefix = this._testPrefix(index, this.screen.colors.green("-"));
text = this.screen.colors.cyan(title) + this._retrySuffix(result);
} else {
const statusMark = result.status === "passed" ? POSITIVE_STATUS_MARK : NEGATIVE_STATUS_MARK;
if (result.status === test.expectedStatus) {
prefix = this._testPrefix(index, this.screen.colors.green(statusMark));
text = title;
} else {
prefix = this._testPrefix(index, this.screen.colors.red(statusMark));
text = this.screen.colors.red(title);
}
text += this._retrySuffix(result) + this.screen.colors.dim(` (${(0, import_utilsBundle.ms)(result.duration)})`);
}
this._updateOrAppendLine(this._testRows, test, text, prefix);
}
_updateOrAppendLine(entityRowNumbers, entity, text, prefix) {
const row = entityRowNumbers.get(entity);
if (row !== void 0 && this.screen.isTTY && this._lastRow - row < this.screen.ttyHeight) {
this._updateLine(row, text, prefix);
} else {
this._maybeWriteNewLine();
entityRowNumbers.set(entity, this._lastRow);
this._appendLine(text, prefix);
}
}
_appendLine(text, prefix) {
const line = prefix + this.fitToScreen(text, prefix);
if (process.env.PW_TEST_DEBUG_REPORTERS) {
this.screen.stdout.write("#" + this._lastRow + " : " + line + "\n");
} else {
this.screen.stdout.write(line);
this.screen.stdout.write("\n");
}
++this._lastRow;
this._lastColumn = 0;
}
_updateLine(row, text, prefix) {
const line = prefix + this.fitToScreen(text, prefix);
if (process.env.PW_TEST_DEBUG_REPORTERS)
this.screen.stdout.write("#" + row + " : " + line + "\n");
else
this._updateLineForTTY(row, line);
}
_updateLineForTTY(row, line) {
if (row !== this._lastRow)
this.screen.stdout.write(`\x1B[${this._lastRow - row}A`);
this.screen.stdout.write("\x1B[2K\x1B[0G");
this.screen.stdout.write(line);
if (row !== this._lastRow)
this.screen.stdout.write(`\x1B[${this._lastRow - row}E`);
}
_testPrefix(index, statusMark) {
const statusMarkLength = (0, import_util.stripAnsiEscapes)(statusMark).length;
const indexLength = Math.ceil(Math.log10(this.totalTestCount + 1));
return " " + statusMark + " ".repeat(3 - statusMarkLength) + this.screen.colors.dim(index.padStart(indexLength) + " ");
}
_retrySuffix(result) {
return result.retry ? this.screen.colors.yellow(` (retry #${result.retry})`) : "";
}
onError(error) {
super.onError(error);
this._maybeWriteNewLine();
const message = this.formatError(error).message + "\n";
this._updateLineCountAndNewLineFlagForOutput(message);
this.screen.stdout.write(message);
}
async onEnd(result) {
await super.onEnd(result);
this.screen.stdout.write("\n");
this.epilogue(true);
}
}
const lastStepOrdinalSymbol = Symbol("lastStepOrdinal");
var list_default = ListReporter;

View File

@@ -0,0 +1,66 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var listModeReporter_exports = {};
__export(listModeReporter_exports, {
default: () => listModeReporter_default
});
module.exports = __toCommonJS(listModeReporter_exports);
var import_path = __toESM(require("path"));
var import_base = require("./base");
class ListModeReporter {
constructor(options) {
this.screen = options?.screen ?? import_base.terminalScreen;
}
version() {
return "v2";
}
onConfigure(config) {
this.config = config;
}
onBegin(suite) {
this._writeLine(`Listing tests:`);
const tests = suite.allTests();
const files = /* @__PURE__ */ new Set();
for (const test of tests) {
const [, projectName, , ...titles] = test.titlePath();
const location = `${import_path.default.relative(this.config.rootDir, test.location.file)}:${test.location.line}:${test.location.column}`;
const projectTitle = projectName ? `[${projectName}] \u203A ` : "";
this._writeLine(` ${projectTitle}${location} \u203A ${titles.join(" \u203A ")}`);
files.add(test.location.file);
}
this._writeLine(`Total: ${tests.length} ${tests.length === 1 ? "test" : "tests"} in ${files.size} ${files.size === 1 ? "file" : "files"}`);
}
onError(error) {
this.screen.stderr.write("\n" + (0, import_base.formatError)(import_base.terminalScreen, error).message + "\n");
}
_writeLine(line) {
this.screen.stdout.write(line + "\n");
}
}
var listModeReporter_default = ListModeReporter;

144
node_modules/playwright/lib/reporters/markdown.js generated vendored Normal file
View File

@@ -0,0 +1,144 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var markdown_exports = {};
__export(markdown_exports, {
default: () => markdown_default
});
module.exports = __toCommonJS(markdown_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
class MarkdownReporter {
constructor(options) {
this._fatalErrors = [];
this._options = options;
}
printsToStdio() {
return false;
}
onBegin(config, suite) {
this._config = config;
this._suite = suite;
}
onError(error) {
this._fatalErrors.push(error);
}
async onEnd(result) {
const summary = this._generateSummary();
const lines = [];
if (this._fatalErrors.length)
lines.push(`**${this._fatalErrors.length} fatal errors, not part of any test**`);
if (summary.unexpected.length) {
lines.push(`**${summary.unexpected.length} failed**`);
this._printTestList(":x:", summary.unexpected, lines);
}
if (summary.flaky.length) {
lines.push(`<details>`);
lines.push(`<summary><b>${summary.flaky.length} flaky</b></summary>`);
this._printTestList(":warning:", summary.flaky, lines, " <br/>");
lines.push(`</details>`);
lines.push(``);
}
if (summary.interrupted.length) {
lines.push(`<details>`);
lines.push(`<summary><b>${summary.interrupted.length} interrupted</b></summary>`);
this._printTestList(":warning:", summary.interrupted, lines, " <br/>");
lines.push(`</details>`);
lines.push(``);
}
const skipped = summary.skipped ? `, ${summary.skipped} skipped` : "";
const didNotRun = summary.didNotRun ? `, ${summary.didNotRun} did not run` : "";
lines.push(`**${summary.expected} passed${skipped}${didNotRun}**`);
lines.push(``);
await this.publishReport(lines.join("\n"));
}
async publishReport(report) {
const maybeRelativeFile = this._options.outputFile || "report.md";
const reportFile = import_path.default.resolve(this._options.configDir, maybeRelativeFile);
await import_fs.default.promises.mkdir(import_path.default.dirname(reportFile), { recursive: true });
await import_fs.default.promises.writeFile(reportFile, report);
}
_generateSummary() {
let didNotRun = 0;
let skipped = 0;
let expected = 0;
const interrupted = [];
const interruptedToPrint = [];
const unexpected = [];
const flaky = [];
this._suite.allTests().forEach((test) => {
switch (test.outcome()) {
case "skipped": {
if (test.results.some((result) => result.status === "interrupted")) {
if (test.results.some((result) => !!result.error))
interruptedToPrint.push(test);
interrupted.push(test);
} else if (!test.results.length || test.expectedStatus !== "skipped") {
++didNotRun;
} else {
++skipped;
}
break;
}
case "expected":
++expected;
break;
case "unexpected":
unexpected.push(test);
break;
case "flaky":
flaky.push(test);
break;
}
});
return {
didNotRun,
skipped,
expected,
interrupted,
unexpected,
flaky
};
}
_printTestList(prefix, tests, lines, suffix) {
for (const test of tests)
lines.push(`${prefix} ${formatTestTitle(this._config.rootDir, test)}${suffix || ""}`);
lines.push(``);
}
}
function formatTestTitle(rootDir, test) {
const [, projectName, , ...titles] = test.titlePath();
const relativeTestPath = import_path.default.relative(rootDir, test.location.file);
const location = `${relativeTestPath}:${test.location.line}`;
const projectTitle = projectName ? `[${projectName}] \u203A ` : "";
const testTitle = `${projectTitle}${location} \u203A ${titles.join(" \u203A ")}`;
const extraTags = test.tags.filter((t) => !testTitle.includes(t));
const formattedTags = extraTags.map((t) => `\`${t}\``).join(" ");
return `${testTitle}${extraTags.length ? " " + formattedTags : ""}`;
}
var markdown_default = MarkdownReporter;

533
node_modules/playwright/lib/reporters/merge.js generated vendored Normal file
View File

@@ -0,0 +1,533 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var merge_exports = {};
__export(merge_exports, {
createMergedReport: () => createMergedReport
});
module.exports = __toCommonJS(merge_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_blob = require("./blob");
var import_multiplexer = require("./multiplexer");
var import_stringInternPool = require("../isomorphic/stringInternPool");
var import_teleReceiver = require("../isomorphic/teleReceiver");
var import_reporters = require("../runner/reporters");
var import_util = require("../util");
async function createMergedReport(config, dir, reporterDescriptions, rootDirOverride) {
const reporters = await (0, import_reporters.createReporters)(config, "merge", false, reporterDescriptions);
const multiplexer = new import_multiplexer.Multiplexer(reporters);
const stringPool = new import_stringInternPool.StringInternPool();
let printStatus = () => {
};
if (!multiplexer.printsToStdio()) {
printStatus = printStatusToStdout;
printStatus(`merging reports from ${dir}`);
}
const shardFiles = await sortedShardFiles(dir);
if (shardFiles.length === 0)
throw new Error(`No report files found in ${dir}`);
const eventData = await mergeEvents(dir, shardFiles, stringPool, printStatus, rootDirOverride);
const pathSeparator = rootDirOverride ? import_path.default.sep : eventData.pathSeparatorFromMetadata ?? import_path.default.sep;
const receiver = new import_teleReceiver.TeleReporterReceiver(multiplexer, {
mergeProjects: false,
mergeTestCases: false,
resolvePath: (rootDir, relativePath) => stringPool.internString(rootDir + pathSeparator + relativePath),
configOverrides: config.config
});
printStatus(`processing test events`);
const dispatchEvents = async (events) => {
for (const event of events) {
if (event.method === "onEnd")
printStatus(`building final report`);
await receiver.dispatch(event);
if (event.method === "onEnd")
printStatus(`finished building report`);
}
};
await dispatchEvents(eventData.prologue);
for (const { reportFile, eventPatchers, metadata } of eventData.reports) {
const reportJsonl = await import_fs.default.promises.readFile(reportFile);
const events = parseTestEvents(reportJsonl);
new import_stringInternPool.JsonStringInternalizer(stringPool).traverse(events);
eventPatchers.patchers.push(new AttachmentPathPatcher(dir));
if (metadata.name)
eventPatchers.patchers.push(new GlobalErrorPatcher(metadata.name));
eventPatchers.patchEvents(events);
await dispatchEvents(events);
}
await dispatchEvents(eventData.epilogue);
}
const commonEventNames = ["onBlobReportMetadata", "onConfigure", "onProject", "onBegin", "onEnd"];
const commonEvents = new Set(commonEventNames);
const commonEventRegex = new RegExp(`${commonEventNames.join("|")}`);
function parseCommonEvents(reportJsonl) {
return splitBufferLines(reportJsonl).map((line) => line.toString("utf8")).filter((line) => commonEventRegex.test(line)).map((line) => JSON.parse(line)).filter((event) => commonEvents.has(event.method));
}
function parseTestEvents(reportJsonl) {
return splitBufferLines(reportJsonl).map((line) => line.toString("utf8")).filter((line) => line.length).map((line) => JSON.parse(line)).filter((event) => !commonEvents.has(event.method));
}
function splitBufferLines(buffer) {
const lines = [];
let start = 0;
while (start < buffer.length) {
const end = buffer.indexOf(10, start);
if (end === -1) {
lines.push(buffer.slice(start));
break;
}
lines.push(buffer.slice(start, end));
start = end + 1;
}
return lines;
}
async function extractAndParseReports(dir, shardFiles, internalizer, printStatus) {
const shardEvents = [];
await import_fs.default.promises.mkdir(import_path.default.join(dir, "resources"), { recursive: true });
const reportNames = new UniqueFileNameGenerator();
for (const file of shardFiles) {
const absolutePath = import_path.default.join(dir, file);
printStatus(`extracting: ${(0, import_util.relativeFilePath)(absolutePath)}`);
const zipFile = new import_utils.ZipFile(absolutePath);
const entryNames = await zipFile.entries();
for (const entryName of entryNames.sort()) {
let fileName = import_path.default.join(dir, entryName);
const content = await zipFile.read(entryName);
if (entryName.endsWith(".jsonl")) {
fileName = reportNames.makeUnique(fileName);
let parsedEvents = parseCommonEvents(content);
internalizer.traverse(parsedEvents);
const metadata = findMetadata(parsedEvents, file);
parsedEvents = modernizer.modernize(metadata.version, parsedEvents);
shardEvents.push({
file,
localPath: fileName,
metadata,
parsedEvents
});
}
await import_fs.default.promises.writeFile(fileName, content);
}
zipFile.close();
}
return shardEvents;
}
function findMetadata(events, file) {
if (events[0]?.method !== "onBlobReportMetadata")
throw new Error(`No metadata event found in ${file}`);
const metadata = events[0].params;
if (metadata.version > import_blob.currentBlobReportVersion)
throw new Error(`Blob report ${file} was created with a newer version of Playwright.`);
return metadata;
}
async function mergeEvents(dir, shardReportFiles, stringPool, printStatus, rootDirOverride) {
const internalizer = new import_stringInternPool.JsonStringInternalizer(stringPool);
const configureEvents = [];
const projectEvents = [];
const endEvents = [];
const blobs = await extractAndParseReports(dir, shardReportFiles, internalizer, printStatus);
blobs.sort((a, b) => {
const nameA = a.metadata.name ?? "";
const nameB = b.metadata.name ?? "";
if (nameA !== nameB)
return nameA.localeCompare(nameB);
const shardA = a.metadata.shard?.current ?? 0;
const shardB = b.metadata.shard?.current ?? 0;
if (shardA !== shardB)
return shardA - shardB;
return a.file.localeCompare(b.file);
});
printStatus(`merging events`);
const reports = [];
const globalTestIdSet = /* @__PURE__ */ new Set();
for (let i = 0; i < blobs.length; ++i) {
const { parsedEvents, metadata, localPath } = blobs[i];
const eventPatchers = new JsonEventPatchers();
eventPatchers.patchers.push(new IdsPatcher(
stringPool,
metadata.name,
String(i),
globalTestIdSet
));
if (rootDirOverride)
eventPatchers.patchers.push(new PathSeparatorPatcher(metadata.pathSeparator));
eventPatchers.patchEvents(parsedEvents);
for (const event of parsedEvents) {
if (event.method === "onConfigure")
configureEvents.push(event);
else if (event.method === "onProject")
projectEvents.push(event);
else if (event.method === "onEnd")
endEvents.push(event);
}
reports.push({
eventPatchers,
reportFile: localPath,
metadata
});
}
return {
prologue: [
mergeConfigureEvents(configureEvents, rootDirOverride),
...projectEvents,
{ method: "onBegin", params: void 0 }
],
reports,
epilogue: [
mergeEndEvents(endEvents),
{ method: "onExit", params: void 0 }
],
pathSeparatorFromMetadata: blobs[0]?.metadata.pathSeparator
};
}
function mergeConfigureEvents(configureEvents, rootDirOverride) {
if (!configureEvents.length)
throw new Error("No configure events found");
let config = {
configFile: void 0,
globalTimeout: 0,
maxFailures: 0,
metadata: {},
rootDir: "",
version: "",
workers: 0
};
for (const event of configureEvents)
config = mergeConfigs(config, event.params.config);
if (rootDirOverride) {
config.rootDir = rootDirOverride;
} else {
const rootDirs = new Set(configureEvents.map((e) => e.params.config.rootDir));
if (rootDirs.size > 1) {
throw new Error([
`Blob reports being merged were recorded with different test directories, and`,
`merging cannot proceed. This may happen if you are merging reports from`,
`machines with different environments, like different operating systems or`,
`if the tests ran with different playwright configs.`,
``,
`You can force merge by specifying a merge config file with "-c" option. If`,
`you'd like all test paths to be correct, make sure 'testDir' in the merge config`,
`file points to the actual tests location.`,
``,
`Found directories:`,
...rootDirs
].join("\n"));
}
}
return {
method: "onConfigure",
params: {
config
}
};
}
function mergeConfigs(to, from) {
return {
...to,
...from,
metadata: {
...to.metadata,
...from.metadata,
actualWorkers: (to.metadata.actualWorkers || 0) + (from.metadata.actualWorkers || 0)
},
workers: to.workers + from.workers
};
}
function mergeEndEvents(endEvents) {
let startTime = endEvents.length ? 1e13 : Date.now();
let status = "passed";
let duration = 0;
for (const event of endEvents) {
const shardResult = event.params.result;
if (shardResult.status === "failed")
status = "failed";
else if (shardResult.status === "timedout" && status !== "failed")
status = "timedout";
else if (shardResult.status === "interrupted" && status !== "failed" && status !== "timedout")
status = "interrupted";
startTime = Math.min(startTime, shardResult.startTime);
duration = Math.max(duration, shardResult.duration);
}
const result = {
status,
startTime,
duration
};
return {
method: "onEnd",
params: {
result
}
};
}
async function sortedShardFiles(dir) {
const files = await import_fs.default.promises.readdir(dir);
return files.filter((file) => file.endsWith(".zip")).sort();
}
function printStatusToStdout(message) {
process.stdout.write(`${message}
`);
}
class UniqueFileNameGenerator {
constructor() {
this._usedNames = /* @__PURE__ */ new Set();
}
makeUnique(name) {
if (!this._usedNames.has(name)) {
this._usedNames.add(name);
return name;
}
const extension = import_path.default.extname(name);
name = name.substring(0, name.length - extension.length);
let index = 0;
while (true) {
const candidate = `${name}-${++index}${extension}`;
if (!this._usedNames.has(candidate)) {
this._usedNames.add(candidate);
return candidate;
}
}
}
}
class IdsPatcher {
constructor(stringPool, botName, salt, globalTestIdSet) {
this._stringPool = stringPool;
this._botName = botName;
this._salt = salt;
this._testIdsMap = /* @__PURE__ */ new Map();
this._globalTestIdSet = globalTestIdSet;
}
patchEvent(event) {
const { method, params } = event;
switch (method) {
case "onProject":
this._onProject(params.project);
return;
case "onAttach":
case "onTestBegin":
case "onStepBegin":
case "onStepEnd":
case "onStdIO":
params.testId = params.testId ? this._mapTestId(params.testId) : void 0;
return;
case "onTestEnd":
params.test.testId = this._mapTestId(params.test.testId);
return;
}
}
_onProject(project) {
project.metadata ??= {};
project.suites.forEach((suite) => this._updateTestIds(suite));
}
_updateTestIds(suite) {
suite.entries.forEach((entry) => {
if ("testId" in entry)
this._updateTestId(entry);
else
this._updateTestIds(entry);
});
}
_updateTestId(test) {
test.testId = this._mapTestId(test.testId);
if (this._botName) {
test.tags = test.tags || [];
test.tags.unshift("@" + this._botName);
}
}
_mapTestId(testId) {
const t1 = this._stringPool.internString(testId);
if (this._testIdsMap.has(t1))
return this._testIdsMap.get(t1);
if (this._globalTestIdSet.has(t1)) {
const t2 = this._stringPool.internString(testId + this._salt);
this._globalTestIdSet.add(t2);
this._testIdsMap.set(t1, t2);
return t2;
}
this._globalTestIdSet.add(t1);
this._testIdsMap.set(t1, t1);
return t1;
}
}
class AttachmentPathPatcher {
constructor(_resourceDir) {
this._resourceDir = _resourceDir;
}
patchEvent(event) {
if (event.method === "onAttach")
this._patchAttachments(event.params.attachments);
else if (event.method === "onTestEnd")
this._patchAttachments(event.params.result.attachments ?? []);
}
_patchAttachments(attachments) {
for (const attachment of attachments) {
if (!attachment.path)
continue;
attachment.path = import_path.default.join(this._resourceDir, attachment.path);
}
}
}
class PathSeparatorPatcher {
constructor(from) {
this._from = from ?? (import_path.default.sep === "/" ? "\\" : "/");
this._to = import_path.default.sep;
}
patchEvent(jsonEvent) {
if (this._from === this._to)
return;
if (jsonEvent.method === "onProject") {
this._updateProject(jsonEvent.params.project);
return;
}
if (jsonEvent.method === "onTestEnd") {
const test = jsonEvent.params.test;
test.annotations?.forEach((annotation) => this._updateAnnotationLocation(annotation));
const testResult = jsonEvent.params.result;
testResult.annotations?.forEach((annotation) => this._updateAnnotationLocation(annotation));
testResult.errors.forEach((error) => this._updateErrorLocations(error));
(testResult.attachments ?? []).forEach((attachment) => {
if (attachment.path)
attachment.path = this._updatePath(attachment.path);
});
return;
}
if (jsonEvent.method === "onStepBegin") {
const step = jsonEvent.params.step;
this._updateLocation(step.location);
return;
}
if (jsonEvent.method === "onStepEnd") {
const step = jsonEvent.params.step;
this._updateErrorLocations(step.error);
step.annotations?.forEach((annotation) => this._updateAnnotationLocation(annotation));
return;
}
if (jsonEvent.method === "onAttach") {
const attach = jsonEvent.params;
attach.attachments.forEach((attachment) => {
if (attachment.path)
attachment.path = this._updatePath(attachment.path);
});
return;
}
}
_updateProject(project) {
project.outputDir = this._updatePath(project.outputDir);
project.testDir = this._updatePath(project.testDir);
project.snapshotDir = this._updatePath(project.snapshotDir);
project.suites.forEach((suite) => this._updateSuite(suite, true));
}
_updateSuite(suite, isFileSuite = false) {
this._updateLocation(suite.location);
if (isFileSuite)
suite.title = this._updatePath(suite.title);
for (const entry of suite.entries) {
if ("testId" in entry) {
this._updateLocation(entry.location);
entry.annotations?.forEach((annotation) => this._updateAnnotationLocation(annotation));
} else {
this._updateSuite(entry);
}
}
}
_updateErrorLocations(error) {
while (error) {
this._updateLocation(error.location);
error = error.cause;
}
}
_updateAnnotationLocation(annotation) {
this._updateLocation(annotation.location);
}
_updateLocation(location) {
if (location)
location.file = this._updatePath(location.file);
}
_updatePath(text) {
return text.split(this._from).join(this._to);
}
}
class GlobalErrorPatcher {
constructor(botName) {
this._prefix = `(${botName}) `;
}
patchEvent(event) {
if (event.method !== "onError")
return;
const error = event.params.error;
if (error.message !== void 0)
error.message = this._prefix + error.message;
if (error.stack !== void 0)
error.stack = this._prefix + error.stack;
}
}
class JsonEventPatchers {
constructor() {
this.patchers = [];
}
patchEvents(events) {
for (const event of events) {
for (const patcher of this.patchers)
patcher.patchEvent(event);
}
}
}
class BlobModernizer {
modernize(fromVersion, events) {
const result = [];
for (const event of events)
result.push(...this._modernize(fromVersion, event));
return result;
}
_modernize(fromVersion, event) {
let events = [event];
for (let version = fromVersion; version < import_blob.currentBlobReportVersion; ++version)
events = this[`_modernize_${version}_to_${version + 1}`].call(this, events);
return events;
}
_modernize_1_to_2(events) {
return events.map((event) => {
if (event.method === "onProject") {
const modernizeSuite = (suite) => {
const newSuites = suite.suites.map(modernizeSuite);
const { suites, tests, ...remainder } = suite;
return { entries: [...newSuites, ...tests], ...remainder };
};
const project = event.params.project;
project.suites = project.suites.map(modernizeSuite);
}
return event;
});
}
}
const modernizer = new BlobModernizer();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createMergedReport
});

104
node_modules/playwright/lib/reporters/multiplexer.js generated vendored Normal file
View File

@@ -0,0 +1,104 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var multiplexer_exports = {};
__export(multiplexer_exports, {
Multiplexer: () => Multiplexer
});
module.exports = __toCommonJS(multiplexer_exports);
class Multiplexer {
constructor(reporters) {
this._reporters = reporters;
}
version() {
return "v2";
}
onConfigure(config) {
for (const reporter of this._reporters)
wrap(() => reporter.onConfigure?.(config));
}
onBegin(suite) {
for (const reporter of this._reporters)
wrap(() => reporter.onBegin?.(suite));
}
onTestBegin(test, result) {
for (const reporter of this._reporters)
wrap(() => reporter.onTestBegin?.(test, result));
}
onStdOut(chunk, test, result) {
for (const reporter of this._reporters)
wrap(() => reporter.onStdOut?.(chunk, test, result));
}
onStdErr(chunk, test, result) {
for (const reporter of this._reporters)
wrap(() => reporter.onStdErr?.(chunk, test, result));
}
onTestEnd(test, result) {
for (const reporter of this._reporters)
wrap(() => reporter.onTestEnd?.(test, result));
}
async onEnd(result) {
for (const reporter of this._reporters) {
const outResult = await wrapAsync(() => reporter.onEnd?.(result));
if (outResult?.status)
result.status = outResult.status;
}
return result;
}
async onExit() {
for (const reporter of this._reporters)
await wrapAsync(() => reporter.onExit?.());
}
onError(error) {
for (const reporter of this._reporters)
wrap(() => reporter.onError?.(error));
}
onStepBegin(test, result, step) {
for (const reporter of this._reporters)
wrap(() => reporter.onStepBegin?.(test, result, step));
}
onStepEnd(test, result, step) {
for (const reporter of this._reporters)
wrap(() => reporter.onStepEnd?.(test, result, step));
}
printsToStdio() {
return this._reporters.some((r) => {
let prints = false;
wrap(() => prints = r.printsToStdio ? r.printsToStdio() : true);
return prints;
});
}
}
async function wrapAsync(callback) {
try {
return await callback();
} catch (e) {
console.error("Error in reporter", e);
}
}
function wrap(callback) {
try {
callback();
} catch (e) {
console.error("Error in reporter", e);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Multiplexer
});

102
node_modules/playwright/lib/reporters/reporterV2.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var reporterV2_exports = {};
__export(reporterV2_exports, {
wrapReporterAsV2: () => wrapReporterAsV2
});
module.exports = __toCommonJS(reporterV2_exports);
function wrapReporterAsV2(reporter) {
try {
if ("version" in reporter && reporter.version() === "v2")
return reporter;
} catch (e) {
}
return new ReporterV2Wrapper(reporter);
}
class ReporterV2Wrapper {
constructor(reporter) {
this._deferred = [];
this._reporter = reporter;
}
version() {
return "v2";
}
onConfigure(config) {
this._config = config;
}
onBegin(suite) {
this._reporter.onBegin?.(this._config, suite);
const deferred = this._deferred;
this._deferred = null;
for (const item of deferred) {
if (item.error)
this.onError(item.error);
if (item.stdout)
this.onStdOut(item.stdout.chunk, item.stdout.test, item.stdout.result);
if (item.stderr)
this.onStdErr(item.stderr.chunk, item.stderr.test, item.stderr.result);
}
}
onTestBegin(test, result) {
this._reporter.onTestBegin?.(test, result);
}
onStdOut(chunk, test, result) {
if (this._deferred) {
this._deferred.push({ stdout: { chunk, test, result } });
return;
}
this._reporter.onStdOut?.(chunk, test, result);
}
onStdErr(chunk, test, result) {
if (this._deferred) {
this._deferred.push({ stderr: { chunk, test, result } });
return;
}
this._reporter.onStdErr?.(chunk, test, result);
}
onTestEnd(test, result) {
this._reporter.onTestEnd?.(test, result);
}
async onEnd(result) {
return await this._reporter.onEnd?.(result);
}
async onExit() {
await this._reporter.onExit?.();
}
onError(error) {
if (this._deferred) {
this._deferred.push({ error });
return;
}
this._reporter.onError?.(error);
}
onStepBegin(test, result, step) {
this._reporter.onStepBegin?.(test, result, step);
}
onStepEnd(test, result, step) {
this._reporter.onStepEnd?.(test, result, step);
}
printsToStdio() {
return this._reporter.printsToStdio ? this._reporter.printsToStdio() : true;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
wrapReporterAsV2
});

295
node_modules/playwright/lib/reporters/teleEmitter.js generated vendored Normal file
View File

@@ -0,0 +1,295 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var teleEmitter_exports = {};
__export(teleEmitter_exports, {
TeleReporterEmitter: () => TeleReporterEmitter
});
module.exports = __toCommonJS(teleEmitter_exports);
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_teleReceiver = require("../isomorphic/teleReceiver");
class TeleReporterEmitter {
constructor(messageSink, options = {}) {
this._resultKnownAttachmentCounts = /* @__PURE__ */ new Map();
// In case there is blob reporter and UI mode, make sure one does override
// the id assigned by the other.
this._idSymbol = Symbol("id");
this._messageSink = messageSink;
this._emitterOptions = options;
}
version() {
return "v2";
}
onConfigure(config) {
this._rootDir = config.rootDir;
this._messageSink({ method: "onConfigure", params: { config: this._serializeConfig(config) } });
}
onBegin(suite) {
const projects = suite.suites.map((projectSuite) => this._serializeProject(projectSuite));
for (const project of projects)
this._messageSink({ method: "onProject", params: { project } });
this._messageSink({ method: "onBegin", params: void 0 });
}
onTestBegin(test, result) {
result[this._idSymbol] = (0, import_utils.createGuid)();
this._messageSink({
method: "onTestBegin",
params: {
testId: test.id,
result: this._serializeResultStart(result)
}
});
}
onTestEnd(test, result) {
const testEnd = {
testId: test.id,
expectedStatus: test.expectedStatus,
timeout: test.timeout,
annotations: []
};
this._sendNewAttachments(result, test.id);
this._messageSink({
method: "onTestEnd",
params: {
test: testEnd,
result: this._serializeResultEnd(result)
}
});
this._resultKnownAttachmentCounts.delete(result[this._idSymbol]);
}
onStepBegin(test, result, step) {
step[this._idSymbol] = (0, import_utils.createGuid)();
this._messageSink({
method: "onStepBegin",
params: {
testId: test.id,
resultId: result[this._idSymbol],
step: this._serializeStepStart(step)
}
});
}
onStepEnd(test, result, step) {
const resultId = result[this._idSymbol];
this._sendNewAttachments(result, test.id);
this._messageSink({
method: "onStepEnd",
params: {
testId: test.id,
resultId,
step: this._serializeStepEnd(step, result)
}
});
}
onError(error) {
this._messageSink({
method: "onError",
params: { error }
});
}
onStdOut(chunk, test, result) {
this._onStdIO("stdout", chunk, test, result);
}
onStdErr(chunk, test, result) {
this._onStdIO("stderr", chunk, test, result);
}
_onStdIO(type, chunk, test, result) {
if (this._emitterOptions.omitOutput)
return;
const isBase64 = typeof chunk !== "string";
const data = isBase64 ? chunk.toString("base64") : chunk;
this._messageSink({
method: "onStdIO",
params: { testId: test?.id, resultId: result ? result[this._idSymbol] : void 0, type, data, isBase64 }
});
}
async onEnd(result) {
const resultPayload = {
status: result.status,
startTime: result.startTime.getTime(),
duration: result.duration
};
this._messageSink({
method: "onEnd",
params: {
result: resultPayload
}
});
}
printsToStdio() {
return false;
}
_serializeConfig(config) {
return {
configFile: this._relativePath(config.configFile),
globalTimeout: config.globalTimeout,
maxFailures: config.maxFailures,
metadata: config.metadata,
rootDir: config.rootDir,
version: config.version,
workers: config.workers
};
}
_serializeProject(suite) {
const project = suite.project();
const report = {
metadata: project.metadata,
name: project.name,
outputDir: this._relativePath(project.outputDir),
repeatEach: project.repeatEach,
retries: project.retries,
testDir: this._relativePath(project.testDir),
testIgnore: (0, import_teleReceiver.serializeRegexPatterns)(project.testIgnore),
testMatch: (0, import_teleReceiver.serializeRegexPatterns)(project.testMatch),
timeout: project.timeout,
suites: suite.suites.map((fileSuite) => {
return this._serializeSuite(fileSuite);
}),
grep: (0, import_teleReceiver.serializeRegexPatterns)(project.grep),
grepInvert: (0, import_teleReceiver.serializeRegexPatterns)(project.grepInvert || []),
dependencies: project.dependencies,
snapshotDir: this._relativePath(project.snapshotDir),
teardown: project.teardown,
use: this._serializeProjectUseOptions(project.use)
};
return report;
}
_serializeProjectUseOptions(use) {
return {
testIdAttribute: use.testIdAttribute
};
}
_serializeSuite(suite) {
const result = {
title: suite.title,
location: this._relativeLocation(suite.location),
entries: suite.entries().map((e) => {
if (e.type === "test")
return this._serializeTest(e);
return this._serializeSuite(e);
})
};
return result;
}
_serializeTest(test) {
return {
testId: test.id,
title: test.title,
location: this._relativeLocation(test.location),
retries: test.retries,
tags: test.tags,
repeatEachIndex: test.repeatEachIndex,
annotations: this._relativeAnnotationLocations(test.annotations)
};
}
_serializeResultStart(result) {
return {
id: result[this._idSymbol],
retry: result.retry,
workerIndex: result.workerIndex,
parallelIndex: result.parallelIndex,
startTime: +result.startTime
};
}
_serializeResultEnd(result) {
return {
id: result[this._idSymbol],
duration: result.duration,
status: result.status,
errors: result.errors,
annotations: result.annotations?.length ? this._relativeAnnotationLocations(result.annotations) : void 0
};
}
_sendNewAttachments(result, testId) {
const resultId = result[this._idSymbol];
const knownAttachmentCount = this._resultKnownAttachmentCounts.get(resultId) ?? 0;
if (result.attachments.length > knownAttachmentCount) {
this._messageSink({
method: "onAttach",
params: {
testId,
resultId,
attachments: this._serializeAttachments(result.attachments.slice(knownAttachmentCount))
}
});
}
this._resultKnownAttachmentCounts.set(resultId, result.attachments.length);
}
_serializeAttachments(attachments) {
return attachments.map((a) => {
const { body, ...rest } = a;
return {
...rest,
// There is no Buffer in the browser, so there is no point in sending the data there.
base64: body && !this._emitterOptions.omitBuffers ? body.toString("base64") : void 0
};
});
}
_serializeStepStart(step) {
return {
id: step[this._idSymbol],
parentStepId: step.parent?.[this._idSymbol],
title: step.title,
category: step.category,
startTime: +step.startTime,
location: this._relativeLocation(step.location)
};
}
_serializeStepEnd(step, result) {
return {
id: step[this._idSymbol],
duration: step.duration,
error: step.error,
attachments: step.attachments.length ? step.attachments.map((a) => result.attachments.indexOf(a)) : void 0,
annotations: step.annotations.length ? this._relativeAnnotationLocations(step.annotations) : void 0
};
}
_relativeAnnotationLocations(annotations) {
return annotations.map((annotation) => ({
...annotation,
location: annotation.location ? this._relativeLocation(annotation.location) : void 0
}));
}
_relativeLocation(location) {
if (!location)
return location;
return {
...location,
file: this._relativePath(location.file)
};
}
_relativePath(absolutePath) {
if (!absolutePath)
return absolutePath;
return import_path.default.relative(this._rootDir, absolutePath);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TeleReporterEmitter
});

View File

@@ -0,0 +1,16 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var blobV1_exports = {};
module.exports = __toCommonJS(blobV1_exports);

505
node_modules/playwright/lib/runner/dispatcher.js generated vendored Normal file
View File

@@ -0,0 +1,505 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var dispatcher_exports = {};
__export(dispatcher_exports, {
Dispatcher: () => Dispatcher
});
module.exports = __toCommonJS(dispatcher_exports);
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_rebase = require("./rebase");
var import_workerHost = require("./workerHost");
var import_ipc = require("../common/ipc");
class Dispatcher {
constructor(config, reporter, failureTracker) {
this._workerSlots = [];
this._queue = [];
this._workerLimitPerProjectId = /* @__PURE__ */ new Map();
this._queuedOrRunningHashCount = /* @__PURE__ */ new Map();
this._finished = new import_utils.ManualPromise();
this._isStopped = true;
this._extraEnvByProjectId = /* @__PURE__ */ new Map();
this._producedEnvByProjectId = /* @__PURE__ */ new Map();
this._config = config;
this._reporter = reporter;
this._failureTracker = failureTracker;
for (const project of config.projects) {
if (project.workers)
this._workerLimitPerProjectId.set(project.id, project.workers);
}
}
_findFirstJobToRun() {
for (let index = 0; index < this._queue.length; index++) {
const job = this._queue[index];
const projectIdWorkerLimit = this._workerLimitPerProjectId.get(job.projectId);
if (!projectIdWorkerLimit)
return index;
const runningWorkersWithSameProjectId = this._workerSlots.filter((w) => w.busy && w.worker && w.worker.projectId() === job.projectId).length;
if (runningWorkersWithSameProjectId < projectIdWorkerLimit)
return index;
}
return -1;
}
_scheduleJob() {
if (this._isStopped)
return;
const jobIndex = this._findFirstJobToRun();
if (jobIndex === -1)
return;
const job = this._queue[jobIndex];
let workerIndex = this._workerSlots.findIndex((w) => !w.busy && w.worker && w.worker.hash() === job.workerHash && !w.worker.didSendStop());
if (workerIndex === -1)
workerIndex = this._workerSlots.findIndex((w) => !w.busy);
if (workerIndex === -1) {
return;
}
this._queue.splice(jobIndex, 1);
const jobDispatcher = new JobDispatcher(job, this._reporter, this._failureTracker, () => this.stop().catch(() => {
}));
this._workerSlots[workerIndex].busy = true;
this._workerSlots[workerIndex].jobDispatcher = jobDispatcher;
void this._runJobInWorker(workerIndex, jobDispatcher).then(() => {
this._workerSlots[workerIndex].jobDispatcher = void 0;
this._workerSlots[workerIndex].busy = false;
this._checkFinished();
this._scheduleJob();
});
}
async _runJobInWorker(index, jobDispatcher) {
const job = jobDispatcher.job;
if (jobDispatcher.skipWholeJob())
return;
let worker = this._workerSlots[index].worker;
if (worker && (worker.hash() !== job.workerHash || worker.didSendStop())) {
await worker.stop();
worker = void 0;
if (this._isStopped)
return;
}
let startError;
if (!worker) {
worker = this._createWorker(job, index, (0, import_ipc.serializeConfig)(this._config, true));
this._workerSlots[index].worker = worker;
worker.on("exit", () => this._workerSlots[index].worker = void 0);
startError = await worker.start();
if (this._isStopped)
return;
}
if (startError)
jobDispatcher.onExit(startError);
else
jobDispatcher.runInWorker(worker);
const result = await jobDispatcher.jobResult;
this._updateCounterForWorkerHash(job.workerHash, -1);
if (result.didFail)
void worker.stop(
true
/* didFail */
);
else if (this._isWorkerRedundant(worker))
void worker.stop();
if (!this._isStopped && result.newJob) {
this._queue.unshift(result.newJob);
this._updateCounterForWorkerHash(result.newJob.workerHash, 1);
}
}
_checkFinished() {
if (this._finished.isDone())
return;
if (this._queue.length && !this._isStopped)
return;
if (this._workerSlots.some((w) => w.busy))
return;
this._finished.resolve();
}
_isWorkerRedundant(worker) {
let workersWithSameHash = 0;
for (const slot of this._workerSlots) {
if (slot.worker && !slot.worker.didSendStop() && slot.worker.hash() === worker.hash())
workersWithSameHash++;
}
return workersWithSameHash > this._queuedOrRunningHashCount.get(worker.hash());
}
_updateCounterForWorkerHash(hash, delta) {
this._queuedOrRunningHashCount.set(hash, delta + (this._queuedOrRunningHashCount.get(hash) || 0));
}
async run(testGroups, extraEnvByProjectId) {
this._extraEnvByProjectId = extraEnvByProjectId;
this._queue = testGroups;
for (const group of testGroups)
this._updateCounterForWorkerHash(group.workerHash, 1);
this._isStopped = false;
this._workerSlots = [];
if (this._failureTracker.hasReachedMaxFailures())
void this.stop();
for (let i = 0; i < this._config.config.workers; i++)
this._workerSlots.push({ busy: false });
for (let i = 0; i < this._workerSlots.length; i++)
this._scheduleJob();
this._checkFinished();
await this._finished;
}
_createWorker(testGroup, parallelIndex, loaderData) {
const projectConfig = this._config.projects.find((p) => p.id === testGroup.projectId);
const outputDir = projectConfig.project.outputDir;
const recoverFromStepErrors = this._failureTracker.canRecoverFromStepError();
const worker = new import_workerHost.WorkerHost(testGroup, parallelIndex, loaderData, recoverFromStepErrors, this._extraEnvByProjectId.get(testGroup.projectId) || {}, outputDir);
const handleOutput = (params) => {
const chunk = chunkFromParams(params);
if (worker.didFail()) {
return { chunk };
}
const currentlyRunning = this._workerSlots[parallelIndex].jobDispatcher?.currentlyRunning();
if (!currentlyRunning)
return { chunk };
return { chunk, test: currentlyRunning.test, result: currentlyRunning.result };
};
worker.on("stdOut", (params) => {
const { chunk, test, result } = handleOutput(params);
result?.stdout.push(chunk);
this._reporter.onStdOut?.(chunk, test, result);
});
worker.on("stdErr", (params) => {
const { chunk, test, result } = handleOutput(params);
result?.stderr.push(chunk);
this._reporter.onStdErr?.(chunk, test, result);
});
worker.on("teardownErrors", (params) => {
this._failureTracker.onWorkerError();
for (const error of params.fatalErrors)
this._reporter.onError?.(error);
});
worker.on("exit", () => {
const producedEnv = this._producedEnvByProjectId.get(testGroup.projectId) || {};
this._producedEnvByProjectId.set(testGroup.projectId, { ...producedEnv, ...worker.producedEnv() });
});
return worker;
}
producedEnvByProjectId() {
return this._producedEnvByProjectId;
}
async stop() {
if (this._isStopped)
return;
this._isStopped = true;
await Promise.all(this._workerSlots.map(({ worker }) => worker?.stop()));
this._checkFinished();
}
}
class JobDispatcher {
constructor(job, reporter, failureTracker, stopCallback) {
this.jobResult = new import_utils.ManualPromise();
this._listeners = [];
this._failedTests = /* @__PURE__ */ new Set();
this._failedWithNonRetriableError = /* @__PURE__ */ new Set();
this._remainingByTestId = /* @__PURE__ */ new Map();
this._dataByTestId = /* @__PURE__ */ new Map();
this._parallelIndex = 0;
this._workerIndex = 0;
this.job = job;
this._reporter = reporter;
this._failureTracker = failureTracker;
this._stopCallback = stopCallback;
this._remainingByTestId = new Map(this.job.tests.map((e) => [e.id, e]));
}
_onTestBegin(params) {
const test = this._remainingByTestId.get(params.testId);
if (!test) {
return;
}
const result = test._appendTestResult();
this._dataByTestId.set(test.id, { test, result, steps: /* @__PURE__ */ new Map() });
result.parallelIndex = this._parallelIndex;
result.workerIndex = this._workerIndex;
result.startTime = new Date(params.startWallTime);
this._reporter.onTestBegin?.(test, result);
this._currentlyRunning = { test, result };
}
_onTestEnd(params) {
if (this._failureTracker.hasReachedMaxFailures()) {
params.status = "interrupted";
params.errors = [];
}
const data = this._dataByTestId.get(params.testId);
if (!data) {
return;
}
this._dataByTestId.delete(params.testId);
this._remainingByTestId.delete(params.testId);
const { result, test } = data;
result.duration = params.duration;
result.errors = params.errors;
result.error = result.errors[0];
result.status = params.status;
result.annotations = params.annotations;
test.annotations = [...params.annotations];
test.expectedStatus = params.expectedStatus;
test.timeout = params.timeout;
const isFailure = result.status !== "skipped" && result.status !== test.expectedStatus;
if (isFailure)
this._failedTests.add(test);
if (params.hasNonRetriableError)
this._addNonretriableTestAndSerialModeParents(test);
this._reportTestEnd(test, result);
this._currentlyRunning = void 0;
}
_addNonretriableTestAndSerialModeParents(test) {
this._failedWithNonRetriableError.add(test);
for (let parent = test.parent; parent; parent = parent.parent) {
if (parent._parallelMode === "serial")
this._failedWithNonRetriableError.add(parent);
}
}
_onStepBegin(params) {
const data = this._dataByTestId.get(params.testId);
if (!data) {
return;
}
const { result, steps, test } = data;
const parentStep = params.parentStepId ? steps.get(params.parentStepId) : void 0;
const step = {
title: params.title,
titlePath: () => {
const parentPath = parentStep?.titlePath() || [];
return [...parentPath, params.title];
},
parent: parentStep,
category: params.category,
startTime: new Date(params.wallTime),
duration: -1,
steps: [],
attachments: [],
annotations: [],
location: params.location
};
steps.set(params.stepId, step);
(parentStep || result).steps.push(step);
this._reporter.onStepBegin?.(test, result, step);
}
_onStepEnd(params) {
const data = this._dataByTestId.get(params.testId);
if (!data) {
return;
}
const { result, steps, test } = data;
const step = steps.get(params.stepId);
if (!step) {
this._reporter.onStdErr?.("Internal error: step end without step begin: " + params.stepId, test, result);
return;
}
step.duration = params.wallTime - step.startTime.getTime();
if (params.error)
step.error = params.error;
if (params.suggestedRebaseline)
(0, import_rebase.addSuggestedRebaseline)(step.location, params.suggestedRebaseline);
step.annotations = params.annotations;
steps.delete(params.stepId);
this._reporter.onStepEnd?.(test, result, step);
}
_onStepRecoverFromError(resumeAfterStepError, params) {
const data = this._dataByTestId.get(params.testId);
if (!data) {
resumeAfterStepError({ stepId: params.stepId, status: "failed" });
return;
}
const { steps } = data;
const step = steps.get(params.stepId);
if (!step) {
resumeAfterStepError({ stepId: params.stepId, status: "failed" });
return;
}
const testError = {
...params.error,
location: step.location
};
this._failureTracker.recoverFromStepError(params.stepId, testError, resumeAfterStepError);
}
_onAttach(params) {
const data = this._dataByTestId.get(params.testId);
if (!data) {
return;
}
const attachment = {
name: params.name,
path: params.path,
contentType: params.contentType,
body: params.body !== void 0 ? Buffer.from(params.body, "base64") : void 0
};
data.result.attachments.push(attachment);
if (params.stepId) {
const step = data.steps.get(params.stepId);
if (step)
step.attachments.push(attachment);
else
this._reporter.onStdErr?.("Internal error: step id not found: " + params.stepId);
}
}
_failTestWithErrors(test, errors) {
const runData = this._dataByTestId.get(test.id);
let result;
if (runData) {
result = runData.result;
} else {
result = test._appendTestResult();
this._reporter.onTestBegin?.(test, result);
}
result.errors = [...errors];
result.error = result.errors[0];
result.status = errors.length ? "failed" : "skipped";
this._reportTestEnd(test, result);
this._failedTests.add(test);
}
_massSkipTestsFromRemaining(testIds, errors) {
for (const test of this._remainingByTestId.values()) {
if (!testIds.has(test.id))
continue;
if (!this._failureTracker.hasReachedMaxFailures()) {
this._failTestWithErrors(test, errors);
errors = [];
}
this._remainingByTestId.delete(test.id);
}
if (errors.length) {
this._failureTracker.onWorkerError();
for (const error of errors)
this._reporter.onError?.(error);
}
}
_onDone(params) {
if (!this._remainingByTestId.size && !this._failedTests.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.unexpectedExitError) {
this._finished({ didFail: false });
return;
}
for (const testId of params.fatalUnknownTestIds || []) {
const test = this._remainingByTestId.get(testId);
if (test) {
this._remainingByTestId.delete(testId);
this._failTestWithErrors(test, [{ message: `Test not found in the worker process. Make sure test title does not change.` }]);
}
}
if (params.fatalErrors.length) {
this._massSkipTestsFromRemaining(new Set(this._remainingByTestId.keys()), params.fatalErrors);
}
this._massSkipTestsFromRemaining(new Set(params.skipTestsDueToSetupFailure), []);
if (params.unexpectedExitError) {
if (this._currentlyRunning)
this._massSkipTestsFromRemaining(/* @__PURE__ */ new Set([this._currentlyRunning.test.id]), [params.unexpectedExitError]);
else
this._massSkipTestsFromRemaining(new Set(this._remainingByTestId.keys()), [params.unexpectedExitError]);
}
const retryCandidates = /* @__PURE__ */ new Set();
const serialSuitesWithFailures = /* @__PURE__ */ new Set();
for (const failedTest of this._failedTests) {
if (this._failedWithNonRetriableError.has(failedTest))
continue;
retryCandidates.add(failedTest);
let outermostSerialSuite;
for (let parent = failedTest.parent; parent; parent = parent.parent) {
if (parent._parallelMode === "serial")
outermostSerialSuite = parent;
}
if (outermostSerialSuite && !this._failedWithNonRetriableError.has(outermostSerialSuite))
serialSuitesWithFailures.add(outermostSerialSuite);
}
const testsBelongingToSomeSerialSuiteWithFailures = [...this._remainingByTestId.values()].filter((test) => {
let parent = test.parent;
while (parent && !serialSuitesWithFailures.has(parent))
parent = parent.parent;
return !!parent;
});
this._massSkipTestsFromRemaining(new Set(testsBelongingToSomeSerialSuiteWithFailures.map((test) => test.id)), []);
for (const serialSuite of serialSuitesWithFailures) {
serialSuite.allTests().forEach((test) => retryCandidates.add(test));
}
const remaining = [...this._remainingByTestId.values()];
for (const test of retryCandidates) {
if (test.results.length < test.retries + 1)
remaining.push(test);
}
const newJob = remaining.length ? { ...this.job, tests: remaining } : void 0;
this._finished({ didFail: true, newJob });
}
onExit(data) {
const unexpectedExitError = data.unexpectedly ? {
message: `Error: worker process exited unexpectedly (code=${data.code}, signal=${data.signal})`
} : void 0;
this._onDone({ skipTestsDueToSetupFailure: [], fatalErrors: [], unexpectedExitError });
}
_finished(result) {
import_utils.eventsHelper.removeEventListeners(this._listeners);
this.jobResult.resolve(result);
}
runInWorker(worker) {
this._parallelIndex = worker.parallelIndex;
this._workerIndex = worker.workerIndex;
const runPayload = {
file: this.job.requireFile,
entries: this.job.tests.map((test) => {
return { testId: test.id, retry: test.results.length };
})
};
worker.runTestGroup(runPayload);
const resumeAfterStepError = worker.resumeAfterStepError.bind(worker);
this._listeners = [
import_utils.eventsHelper.addEventListener(worker, "testBegin", this._onTestBegin.bind(this)),
import_utils.eventsHelper.addEventListener(worker, "testEnd", this._onTestEnd.bind(this)),
import_utils.eventsHelper.addEventListener(worker, "stepBegin", this._onStepBegin.bind(this)),
import_utils.eventsHelper.addEventListener(worker, "stepEnd", this._onStepEnd.bind(this)),
import_utils.eventsHelper.addEventListener(worker, "stepRecoverFromError", this._onStepRecoverFromError.bind(this, resumeAfterStepError)),
import_utils.eventsHelper.addEventListener(worker, "attach", this._onAttach.bind(this)),
import_utils.eventsHelper.addEventListener(worker, "done", this._onDone.bind(this)),
import_utils.eventsHelper.addEventListener(worker, "exit", this.onExit.bind(this))
];
}
skipWholeJob() {
const allTestsSkipped = this.job.tests.every((test) => test.expectedStatus === "skipped");
if (allTestsSkipped && !this._failureTracker.hasReachedMaxFailures()) {
for (const test of this.job.tests) {
const result = test._appendTestResult();
this._reporter.onTestBegin?.(test, result);
result.status = "skipped";
this._reportTestEnd(test, result);
}
return true;
}
return false;
}
currentlyRunning() {
return this._currentlyRunning;
}
_reportTestEnd(test, result) {
this._reporter.onTestEnd?.(test, result);
const hadMaxFailures = this._failureTracker.hasReachedMaxFailures();
this._failureTracker.onTestEnd(test, result);
if (this._failureTracker.hasReachedMaxFailures()) {
this._stopCallback();
if (!hadMaxFailures)
this._reporter.onError?.({ message: import_utils2.colors.red(`Testing stopped early after ${this._failureTracker.maxFailures()} maximum allowed failures.`) });
}
}
}
function chunkFromParams(params) {
if (typeof params.text === "string")
return params.text;
return Buffer.from(params.buffer, "base64");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Dispatcher
});

76
node_modules/playwright/lib/runner/failureTracker.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var failureTracker_exports = {};
__export(failureTracker_exports, {
FailureTracker: () => FailureTracker
});
module.exports = __toCommonJS(failureTracker_exports);
class FailureTracker {
constructor(_config) {
this._config = _config;
this._failureCount = 0;
this._hasWorkerErrors = false;
}
canRecoverFromStepError() {
return !!this._recoverFromStepErrorHandler;
}
setRecoverFromStepErrorHandler(recoverFromStepErrorHandler) {
this._recoverFromStepErrorHandler = recoverFromStepErrorHandler;
}
onRootSuite(rootSuite) {
this._rootSuite = rootSuite;
}
onTestEnd(test, result) {
if (test.outcome() === "unexpected" && test.results.length > test.retries)
++this._failureCount;
}
recoverFromStepError(stepId, error, resumeAfterStepError) {
if (!this._recoverFromStepErrorHandler) {
resumeAfterStepError({ stepId, status: "failed" });
return;
}
void this._recoverFromStepErrorHandler(stepId, error).then(resumeAfterStepError).catch(() => {
});
}
onWorkerError() {
this._hasWorkerErrors = true;
}
hasReachedMaxFailures() {
return this.maxFailures() > 0 && this._failureCount >= this.maxFailures();
}
hasWorkerErrors() {
return this._hasWorkerErrors;
}
result() {
return this._hasWorkerErrors || this.hasReachedMaxFailures() || this.hasFailedTests() || this._config.failOnFlakyTests && this.hasFlakyTests() ? "failed" : "passed";
}
hasFailedTests() {
return this._rootSuite?.allTests().some((test) => !test.ok());
}
hasFlakyTests() {
return this._rootSuite?.allTests().some((test) => test.outcome() === "flaky");
}
maxFailures() {
return this._config.config.maxFailures;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
FailureTracker
});

77
node_modules/playwright/lib/runner/lastRun.js generated vendored Normal file
View File

@@ -0,0 +1,77 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var lastRun_exports = {};
__export(lastRun_exports, {
LastRunReporter: () => LastRunReporter
});
module.exports = __toCommonJS(lastRun_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_projectUtils = require("./projectUtils");
class LastRunReporter {
constructor(config) {
this._config = config;
const [project] = (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
if (project)
this._lastRunFile = import_path.default.join(project.project.outputDir, ".last-run.json");
}
async filterLastFailed() {
if (!this._lastRunFile)
return;
try {
const lastRunInfo = JSON.parse(await import_fs.default.promises.readFile(this._lastRunFile, "utf8"));
const failedTestIds = new Set(lastRunInfo.failedTests);
this._config.postShardTestFilters.push((test) => failedTestIds.has(test.id));
} catch {
}
}
version() {
return "v2";
}
printsToStdio() {
return false;
}
onBegin(suite) {
this._suite = suite;
}
async onEnd(result) {
if (!this._lastRunFile || this._config.cliListOnly)
return;
const lastRunInfo = {
status: result.status,
failedTests: this._suite?.allTests().filter((t) => !t.ok()).map((t) => t.id) || []
};
await import_fs.default.promises.mkdir(import_path.default.dirname(this._lastRunFile), { recursive: true });
await import_fs.default.promises.writeFile(this._lastRunFile, JSON.stringify(lastRunInfo, void 0, 2));
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
LastRunReporter
});

297
node_modules/playwright/lib/runner/loadUtils.js generated vendored Normal file
View File

@@ -0,0 +1,297 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var loadUtils_exports = {};
__export(loadUtils_exports, {
collectProjectsAndTestFiles: () => collectProjectsAndTestFiles,
createRootSuite: () => createRootSuite,
loadFileSuites: () => loadFileSuites,
loadGlobalHook: () => loadGlobalHook,
loadReporter: () => loadReporter
});
module.exports = __toCommonJS(loadUtils_exports);
var import_path = __toESM(require("path"));
var import_loaderHost = require("./loaderHost");
var import_util = require("../util");
var import_projectUtils = require("./projectUtils");
var import_testGroups = require("./testGroups");
var import_suiteUtils = require("../common/suiteUtils");
var import_test = require("../common/test");
var import_compilationCache = require("../transform/compilationCache");
var import_transform = require("../transform/transform");
var import_utilsBundle = require("../utilsBundle");
async function collectProjectsAndTestFiles(testRun, doNotRunTestsOutsideProjectFilter) {
const config = testRun.config;
const fsCache = /* @__PURE__ */ new Map();
const sourceMapCache = /* @__PURE__ */ new Map();
const cliFileMatcher = config.cliArgs.length ? (0, import_util.createFileMatcherFromArguments)(config.cliArgs) : null;
const allFilesForProject = /* @__PURE__ */ new Map();
const filteredProjects = (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
for (const project of filteredProjects) {
const files = await (0, import_projectUtils.collectFilesForProject)(project, fsCache);
allFilesForProject.set(project, files);
}
const filesToRunByProject = /* @__PURE__ */ new Map();
for (const [project, files] of allFilesForProject) {
const matchedFiles = files.filter((file) => {
const hasMatchingSources = sourceMapSources(file, sourceMapCache).some((source) => {
if (cliFileMatcher && !cliFileMatcher(source))
return false;
return true;
});
return hasMatchingSources;
});
const filteredFiles = matchedFiles.filter(Boolean);
filesToRunByProject.set(project, filteredFiles);
}
const projectClosure = (0, import_projectUtils.buildProjectsClosure)([...filesToRunByProject.keys()]);
for (const [project, type] of projectClosure) {
if (type === "dependency") {
const treatProjectAsEmpty = doNotRunTestsOutsideProjectFilter && !filteredProjects.includes(project);
const files = treatProjectAsEmpty ? [] : allFilesForProject.get(project) || await (0, import_projectUtils.collectFilesForProject)(project, fsCache);
filesToRunByProject.set(project, files);
}
}
testRun.projectFiles = filesToRunByProject;
testRun.projectSuites = /* @__PURE__ */ new Map();
}
async function loadFileSuites(testRun, mode, errors) {
const config = testRun.config;
const allTestFiles = /* @__PURE__ */ new Set();
for (const files of testRun.projectFiles.values())
files.forEach((file) => allTestFiles.add(file));
const fileSuiteByFile = /* @__PURE__ */ new Map();
const loaderHost = mode === "out-of-process" ? new import_loaderHost.OutOfProcessLoaderHost(config) : new import_loaderHost.InProcessLoaderHost(config);
if (await loaderHost.start(errors)) {
for (const file of allTestFiles) {
const fileSuite = await loaderHost.loadTestFile(file, errors);
fileSuiteByFile.set(file, fileSuite);
errors.push(...createDuplicateTitlesErrors(config, fileSuite));
}
await loaderHost.stop();
}
for (const file of allTestFiles) {
for (const dependency of (0, import_compilationCache.dependenciesForTestFile)(file)) {
if (allTestFiles.has(dependency)) {
const importer = import_path.default.relative(config.config.rootDir, file);
const importee = import_path.default.relative(config.config.rootDir, dependency);
errors.push({
message: `Error: test file "${importer}" should not import test file "${importee}"`,
location: { file, line: 1, column: 1 }
});
}
}
}
for (const [project, files] of testRun.projectFiles) {
const suites = files.map((file) => fileSuiteByFile.get(file)).filter(Boolean);
testRun.projectSuites.set(project, suites);
}
}
async function createRootSuite(testRun, errors, shouldFilterOnly) {
const config = testRun.config;
const rootSuite = new import_test.Suite("", "root");
const projectSuites = /* @__PURE__ */ new Map();
const filteredProjectSuites = /* @__PURE__ */ new Map();
{
const cliFileFilters = (0, import_util.createFileFiltersFromArguments)(config.cliArgs);
const grepMatcher = config.cliGrep ? (0, import_util.createTitleMatcher)((0, import_util.forceRegExp)(config.cliGrep)) : () => true;
const grepInvertMatcher = config.cliGrepInvert ? (0, import_util.createTitleMatcher)((0, import_util.forceRegExp)(config.cliGrepInvert)) : () => false;
const cliTitleMatcher = (title) => !grepInvertMatcher(title) && grepMatcher(title);
for (const [project, fileSuites] of testRun.projectSuites) {
const projectSuite = createProjectSuite(project, fileSuites);
projectSuites.set(project, projectSuite);
const filteredProjectSuite = filterProjectSuite(projectSuite, { cliFileFilters, cliTitleMatcher, testFilters: config.preOnlyTestFilters });
filteredProjectSuites.set(project, filteredProjectSuite);
}
}
if (shouldFilterOnly) {
const filteredRoot = new import_test.Suite("", "root");
for (const filteredProjectSuite of filteredProjectSuites.values())
filteredRoot._addSuite(filteredProjectSuite);
(0, import_suiteUtils.filterOnly)(filteredRoot);
for (const [project, filteredProjectSuite] of filteredProjectSuites) {
if (!filteredRoot.suites.includes(filteredProjectSuite))
filteredProjectSuites.delete(project);
}
}
const projectClosure = (0, import_projectUtils.buildProjectsClosure)([...filteredProjectSuites.keys()], (project) => filteredProjectSuites.get(project)._hasTests());
for (const [project, type] of projectClosure) {
if (type === "top-level") {
project.project.repeatEach = project.fullConfig.configCLIOverrides.repeatEach ?? project.project.repeatEach;
rootSuite._addSuite(buildProjectSuite(project, filteredProjectSuites.get(project)));
}
}
if (config.config.forbidOnly) {
const onlyTestsAndSuites = rootSuite._getOnlyItems();
if (onlyTestsAndSuites.length > 0) {
const configFilePath = config.config.configFile ? import_path.default.relative(config.config.rootDir, config.config.configFile) : void 0;
errors.push(...createForbidOnlyErrors(onlyTestsAndSuites, config.configCLIOverrides.forbidOnly, configFilePath));
}
}
if (config.config.shard) {
const testGroups = [];
for (const projectSuite of rootSuite.suites) {
testGroups.push(...(0, import_testGroups.createTestGroups)(projectSuite, config.config.shard.total));
}
const testGroupsInThisShard = (0, import_testGroups.filterForShard)(config.config.shard, testGroups);
const testsInThisShard = /* @__PURE__ */ new Set();
for (const group of testGroupsInThisShard) {
for (const test of group.tests)
testsInThisShard.add(test);
}
(0, import_suiteUtils.filterTestsRemoveEmptySuites)(rootSuite, (test) => testsInThisShard.has(test));
}
if (config.postShardTestFilters.length)
(0, import_suiteUtils.filterTestsRemoveEmptySuites)(rootSuite, (test) => config.postShardTestFilters.every((filter) => filter(test)));
{
const projectClosure2 = new Map((0, import_projectUtils.buildProjectsClosure)(rootSuite.suites.map((suite) => suite._fullProject)));
for (const [project, level] of projectClosure2.entries()) {
if (level === "dependency")
rootSuite._prependSuite(buildProjectSuite(project, projectSuites.get(project)));
}
}
return rootSuite;
}
function createProjectSuite(project, fileSuites) {
const projectSuite = new import_test.Suite(project.project.name, "project");
for (const fileSuite of fileSuites)
projectSuite._addSuite((0, import_suiteUtils.bindFileSuiteToProject)(project, fileSuite));
const grepMatcher = (0, import_util.createTitleMatcher)(project.project.grep);
const grepInvertMatcher = project.project.grepInvert ? (0, import_util.createTitleMatcher)(project.project.grepInvert) : null;
(0, import_suiteUtils.filterTestsRemoveEmptySuites)(projectSuite, (test) => {
const grepTitle = test._grepTitleWithTags();
if (grepInvertMatcher?.(grepTitle))
return false;
return grepMatcher(grepTitle);
});
return projectSuite;
}
function filterProjectSuite(projectSuite, options) {
if (!options.cliFileFilters.length && !options.cliTitleMatcher && !options.testFilters.length)
return projectSuite;
const result = projectSuite._deepClone();
if (options.cliFileFilters.length)
(0, import_suiteUtils.filterByFocusedLine)(result, options.cliFileFilters);
(0, import_suiteUtils.filterTestsRemoveEmptySuites)(result, (test) => {
if (!options.testFilters.every((filter) => filter(test)))
return false;
if (options.cliTitleMatcher && !options.cliTitleMatcher(test._grepTitleWithTags()))
return false;
return true;
});
return result;
}
function buildProjectSuite(project, projectSuite) {
const result = new import_test.Suite(project.project.name, "project");
result._fullProject = project;
if (project.fullyParallel)
result._parallelMode = "parallel";
for (const fileSuite of projectSuite.suites) {
result._addSuite(fileSuite);
for (let repeatEachIndex = 1; repeatEachIndex < project.project.repeatEach; repeatEachIndex++) {
const clone = fileSuite._deepClone();
(0, import_suiteUtils.applyRepeatEachIndex)(project, clone, repeatEachIndex);
result._addSuite(clone);
}
}
return result;
}
function createForbidOnlyErrors(onlyTestsAndSuites, forbidOnlyCLIFlag, configFilePath) {
const errors = [];
for (const testOrSuite of onlyTestsAndSuites) {
const title = testOrSuite.titlePath().slice(2).join(" ");
const configFilePathName = configFilePath ? `'${configFilePath}'` : "the Playwright configuration file";
const forbidOnlySource = forbidOnlyCLIFlag ? `'--forbid-only' CLI flag` : `'forbidOnly' option in ${configFilePathName}`;
const error = {
message: `Error: item focused with '.only' is not allowed due to the ${forbidOnlySource}: "${title}"`,
location: testOrSuite.location
};
errors.push(error);
}
return errors;
}
function createDuplicateTitlesErrors(config, fileSuite) {
const errors = [];
const testsByFullTitle = /* @__PURE__ */ new Map();
for (const test of fileSuite.allTests()) {
const fullTitle = test.titlePath().slice(1).join(" \u203A ");
const existingTest = testsByFullTitle.get(fullTitle);
if (existingTest) {
const error = {
message: `Error: duplicate test title "${fullTitle}", first declared in ${buildItemLocation(config.config.rootDir, existingTest)}`,
location: test.location
};
errors.push(error);
}
testsByFullTitle.set(fullTitle, test);
}
return errors;
}
function buildItemLocation(rootDir, testOrSuite) {
if (!testOrSuite.location)
return "";
return `${import_path.default.relative(rootDir, testOrSuite.location.file)}:${testOrSuite.location.line}`;
}
async function requireOrImportDefaultFunction(file, expectConstructor) {
let func = await (0, import_transform.requireOrImport)(file);
if (func && typeof func === "object" && "default" in func)
func = func["default"];
if (typeof func !== "function")
throw (0, import_util.errorWithFile)(file, `file must export a single ${expectConstructor ? "class" : "function"}.`);
return func;
}
function loadGlobalHook(config, file) {
return requireOrImportDefaultFunction(import_path.default.resolve(config.config.rootDir, file), false);
}
function loadReporter(config, file) {
return requireOrImportDefaultFunction(config ? import_path.default.resolve(config.config.rootDir, file) : file, true);
}
function sourceMapSources(file, cache) {
let sources = [file];
if (!file.endsWith(".js"))
return sources;
if (cache.has(file))
return cache.get(file);
try {
const sourceMap = import_utilsBundle.sourceMapSupport.retrieveSourceMap(file);
const sourceMapData = typeof sourceMap?.map === "string" ? JSON.parse(sourceMap.map) : sourceMap?.map;
if (sourceMapData?.sources)
sources = sourceMapData.sources.map((source) => import_path.default.resolve(import_path.default.dirname(file), source));
} finally {
cache.set(file, sources);
return sources;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
collectProjectsAndTestFiles,
createRootSuite,
loadFileSuites,
loadGlobalHook,
loadReporter
});

89
node_modules/playwright/lib/runner/loaderHost.js generated vendored Normal file
View File

@@ -0,0 +1,89 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var loaderHost_exports = {};
__export(loaderHost_exports, {
InProcessLoaderHost: () => InProcessLoaderHost,
OutOfProcessLoaderHost: () => OutOfProcessLoaderHost
});
module.exports = __toCommonJS(loaderHost_exports);
var import_processHost = require("./processHost");
var import_esmLoaderHost = require("../common/esmLoaderHost");
var import_ipc = require("../common/ipc");
var import_poolBuilder = require("../common/poolBuilder");
var import_test = require("../common/test");
var import_testLoader = require("../common/testLoader");
var import_compilationCache = require("../transform/compilationCache");
class InProcessLoaderHost {
constructor(config) {
this._config = config;
this._poolBuilder = import_poolBuilder.PoolBuilder.createForLoader();
}
async start(errors) {
return true;
}
async loadTestFile(file, testErrors) {
const result = await (0, import_testLoader.loadTestFile)(file, this._config.config.rootDir, testErrors);
this._poolBuilder.buildPools(result, testErrors);
return result;
}
async stop() {
await (0, import_esmLoaderHost.incorporateCompilationCache)();
}
}
class OutOfProcessLoaderHost {
constructor(config) {
this._config = config;
this._processHost = new import_processHost.ProcessHost(require.resolve("../loader/loaderMain.js"), "loader", {});
}
async start(errors) {
const startError = await this._processHost.startRunner((0, import_ipc.serializeConfig)(this._config, false));
if (startError) {
errors.push({
message: `Test loader process failed to start with code "${startError.code}" and signal "${startError.signal}"`
});
return false;
}
return true;
}
async loadTestFile(file, testErrors) {
const result = await this._processHost.sendMessage({ method: "loadTestFile", params: { file } });
testErrors.push(...result.testErrors);
return import_test.Suite._deepParse(result.fileSuite);
}
async stop() {
const result = await this._processHost.sendMessage({ method: "getCompilationCacheFromLoader" });
(0, import_compilationCache.addToCompilationCache)(result);
await this._processHost.stop();
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
InProcessLoaderHost,
OutOfProcessLoaderHost
});

161
node_modules/playwright/lib/runner/processHost.js generated vendored Normal file
View File

@@ -0,0 +1,161 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var processHost_exports = {};
__export(processHost_exports, {
ProcessHost: () => ProcessHost
});
module.exports = __toCommonJS(processHost_exports);
var import_child_process = __toESM(require("child_process"));
var import_events = require("events");
var import_utils = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
class ProcessHost extends import_events.EventEmitter {
constructor(runnerScript, processName, env) {
super();
this._didSendStop = false;
this._processDidExit = false;
this._didExitAndRanOnExit = false;
this._lastMessageId = 0;
this._callbacks = /* @__PURE__ */ new Map();
this._producedEnv = {};
this._runnerScript = runnerScript;
this._processName = processName;
this._extraEnv = env;
}
async startRunner(runnerParams, options = {}) {
(0, import_utils.assert)(!this.process, "Internal error: starting the same process twice");
this.process = import_child_process.default.fork(require.resolve("../common/process"), {
detached: false,
env: {
...process.env,
...this._extraEnv
},
stdio: [
"ignore",
options.onStdOut ? "pipe" : "inherit",
options.onStdErr && !process.env.PW_RUNNER_DEBUG ? "pipe" : "inherit",
"ipc"
]
});
this.process.on("exit", async (code, signal) => {
this._processDidExit = true;
await this.onExit();
this._didExitAndRanOnExit = true;
this.emit("exit", { unexpectedly: !this._didSendStop, code, signal });
});
this.process.on("error", (e) => {
});
this.process.on("message", (message) => {
if (import_utilsBundle.debug.enabled("pw:test:protocol"))
(0, import_utilsBundle.debug)("pw:test:protocol")("\u25C0 RECV " + JSON.stringify(message));
if (message.method === "__env_produced__") {
const producedEnv = message.params;
this._producedEnv = Object.fromEntries(producedEnv.map((e) => [e[0], e[1] ?? void 0]));
} else if (message.method === "__dispatch__") {
const { id, error: error2, method, params, result } = message.params;
if (id && this._callbacks.has(id)) {
const { resolve, reject } = this._callbacks.get(id);
this._callbacks.delete(id);
if (error2) {
const errorObject = new Error(error2.message);
errorObject.stack = error2.stack;
reject(errorObject);
} else {
resolve(result);
}
} else {
this.emit(method, params);
}
} else {
this.emit(message.method, message.params);
}
});
if (options.onStdOut)
this.process.stdout?.on("data", options.onStdOut);
if (options.onStdErr)
this.process.stderr?.on("data", options.onStdErr);
const error = await new Promise((resolve) => {
this.process.once("exit", (code, signal) => resolve({ unexpectedly: true, code, signal }));
this.once("ready", () => resolve(void 0));
});
if (error)
return error;
const processParams = {
processName: this._processName,
timeOrigin: (0, import_utils.timeOrigin)()
};
this.send({
method: "__init__",
params: {
processParams,
runnerScript: this._runnerScript,
runnerParams
}
});
}
sendMessage(message) {
const id = ++this._lastMessageId;
this.send({
method: "__dispatch__",
params: { id, ...message }
});
return new Promise((resolve, reject) => {
this._callbacks.set(id, { resolve, reject });
});
}
sendMessageNoReply(message) {
this.sendMessage(message).catch(() => {
});
}
async onExit() {
}
async stop() {
if (!this._processDidExit && !this._didSendStop) {
this.send({ method: "__stop__" });
this._didSendStop = true;
}
if (!this._didExitAndRanOnExit)
await new Promise((f) => this.once("exit", f));
}
didSendStop() {
return this._didSendStop;
}
producedEnv() {
return this._producedEnv;
}
send(message) {
if (import_utilsBundle.debug.enabled("pw:test:protocol"))
(0, import_utilsBundle.debug)("pw:test:protocol")("SEND \u25BA " + JSON.stringify(message));
this.process?.send(message);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ProcessHost
});

235
node_modules/playwright/lib/runner/projectUtils.js generated vendored Normal file
View File

@@ -0,0 +1,235 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var projectUtils_exports = {};
__export(projectUtils_exports, {
buildDependentProjects: () => buildDependentProjects,
buildProjectsClosure: () => buildProjectsClosure,
buildTeardownToSetupsMap: () => buildTeardownToSetupsMap,
collectFilesForProject: () => collectFilesForProject,
filterProjects: () => filterProjects
});
module.exports = __toCommonJS(projectUtils_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_util = require("util");
var import_utils = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_util2 = require("../util");
const readFileAsync = (0, import_util.promisify)(import_fs.default.readFile);
const readDirAsync = (0, import_util.promisify)(import_fs.default.readdir);
function wildcardPatternToRegExp(pattern) {
return new RegExp("^" + pattern.split("*").map(import_utils.escapeRegExp).join(".*") + "$", "ig");
}
function filterProjects(projects, projectNames) {
if (!projectNames)
return [...projects];
const projectNamesToFind = /* @__PURE__ */ new Set();
const unmatchedProjectNames = /* @__PURE__ */ new Map();
const patterns = /* @__PURE__ */ new Set();
for (const name of projectNames) {
const lowerCaseName = name.toLocaleLowerCase();
if (lowerCaseName.includes("*")) {
patterns.add(wildcardPatternToRegExp(lowerCaseName));
} else {
projectNamesToFind.add(lowerCaseName);
unmatchedProjectNames.set(lowerCaseName, name);
}
}
const result = projects.filter((project) => {
const lowerCaseName = project.project.name.toLocaleLowerCase();
if (projectNamesToFind.has(lowerCaseName)) {
unmatchedProjectNames.delete(lowerCaseName);
return true;
}
for (const regex of patterns) {
regex.lastIndex = 0;
if (regex.test(lowerCaseName))
return true;
}
return false;
});
if (unmatchedProjectNames.size) {
const unknownProjectNames = Array.from(unmatchedProjectNames.values()).map((n) => `"${n}"`).join(", ");
throw new Error(`Project(s) ${unknownProjectNames} not found. Available projects: ${projects.map((p) => `"${p.project.name}"`).join(", ")}`);
}
if (!result.length) {
const allProjects = projects.map((p) => `"${p.project.name}"`).join(", ");
throw new Error(`No projects matched. Available projects: ${allProjects}`);
}
return result;
}
function buildTeardownToSetupsMap(projects) {
const result = /* @__PURE__ */ new Map();
for (const project of projects) {
if (project.teardown) {
const setups = result.get(project.teardown) || [];
setups.push(project);
result.set(project.teardown, setups);
}
}
return result;
}
function buildProjectsClosure(projects, hasTests) {
const result = /* @__PURE__ */ new Map();
const visit = (depth, project) => {
if (depth > 100) {
const error = new Error("Circular dependency detected between projects.");
error.stack = "";
throw error;
}
if (depth === 0 && hasTests && !hasTests(project))
return;
if (result.get(project) !== "dependency")
result.set(project, depth ? "dependency" : "top-level");
for (const dep of project.deps)
visit(depth + 1, dep);
if (project.teardown)
visit(depth + 1, project.teardown);
};
for (const p of projects)
visit(0, p);
return result;
}
function buildDependentProjects(forProjects, projects) {
const reverseDeps = new Map(projects.map((p) => [p, []]));
for (const project of projects) {
for (const dep of project.deps)
reverseDeps.get(dep).push(project);
}
const result = /* @__PURE__ */ new Set();
const visit = (depth, project) => {
if (depth > 100) {
const error = new Error("Circular dependency detected between projects.");
error.stack = "";
throw error;
}
result.add(project);
for (const reverseDep of reverseDeps.get(project))
visit(depth + 1, reverseDep);
if (project.teardown)
visit(depth + 1, project.teardown);
};
for (const forProject of forProjects)
visit(0, forProject);
return result;
}
async function collectFilesForProject(project, fsCache = /* @__PURE__ */ new Map()) {
const extensions = /* @__PURE__ */ new Set([".js", ".ts", ".mjs", ".mts", ".cjs", ".cts", ".jsx", ".tsx", ".mjsx", ".mtsx", ".cjsx", ".ctsx"]);
const testFileExtension = (file) => extensions.has(import_path.default.extname(file));
const allFiles = await cachedCollectFiles(project.project.testDir, project.respectGitIgnore, fsCache);
const testMatch = (0, import_util2.createFileMatcher)(project.project.testMatch);
const testIgnore = (0, import_util2.createFileMatcher)(project.project.testIgnore);
const testFiles = allFiles.filter((file) => {
if (!testFileExtension(file))
return false;
const isTest = !testIgnore(file) && testMatch(file);
if (!isTest)
return false;
return true;
});
return testFiles;
}
async function cachedCollectFiles(testDir, respectGitIgnore, fsCache) {
const key = testDir + ":" + respectGitIgnore;
let result = fsCache.get(key);
if (!result) {
result = await collectFiles(testDir, respectGitIgnore);
fsCache.set(key, result);
}
return result;
}
async function collectFiles(testDir, respectGitIgnore) {
if (!import_fs.default.existsSync(testDir))
return [];
if (!import_fs.default.statSync(testDir).isDirectory())
return [];
const checkIgnores = (entryPath, rules, isDirectory, parentStatus) => {
let status = parentStatus;
for (const rule of rules) {
const ruleIncludes = rule.negate;
if (status === "included" === ruleIncludes)
continue;
const relative = import_path.default.relative(rule.dir, entryPath);
if (rule.match("/" + relative) || rule.match(relative)) {
status = ruleIncludes ? "included" : "ignored";
} else if (isDirectory && (rule.match("/" + relative + "/") || rule.match(relative + "/"))) {
status = ruleIncludes ? "included" : "ignored";
} else if (isDirectory && ruleIncludes && (rule.match("/" + relative, true) || rule.match(relative, true))) {
status = "ignored-but-recurse";
}
}
return status;
};
const files = [];
const visit = async (dir, rules, status) => {
const entries = await readDirAsync(dir, { withFileTypes: true });
entries.sort((a, b) => a.name.localeCompare(b.name));
if (respectGitIgnore) {
const gitignore = entries.find((e) => e.isFile() && e.name === ".gitignore");
if (gitignore) {
const content = await readFileAsync(import_path.default.join(dir, gitignore.name), "utf8");
const newRules = content.split(/\r?\n/).map((s) => {
s = s.trim();
if (!s)
return;
const rule = new import_utilsBundle.minimatch.Minimatch(s, { matchBase: true, dot: true, flipNegate: true });
if (rule.comment)
return;
rule.dir = dir;
return rule;
}).filter((rule) => !!rule);
rules = [...rules, ...newRules];
}
}
for (const entry of entries) {
if (entry.name === "." || entry.name === "..")
continue;
if (entry.isFile() && entry.name === ".gitignore")
continue;
if (entry.isDirectory() && entry.name === "node_modules")
continue;
const entryPath = import_path.default.join(dir, entry.name);
const entryStatus = checkIgnores(entryPath, rules, entry.isDirectory(), status);
if (entry.isDirectory() && entryStatus !== "ignored")
await visit(entryPath, rules, entryStatus);
else if (entry.isFile() && entryStatus === "included")
files.push(entryPath);
}
};
await visit(testDir, [], "included");
return files;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
buildDependentProjects,
buildProjectsClosure,
buildTeardownToSetupsMap,
collectFilesForProject,
filterProjects
});

189
node_modules/playwright/lib/runner/rebase.js generated vendored Normal file
View File

@@ -0,0 +1,189 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var rebase_exports = {};
__export(rebase_exports, {
addSuggestedRebaseline: () => addSuggestedRebaseline,
applySuggestedRebaselines: () => applySuggestedRebaselines,
clearSuggestedRebaselines: () => clearSuggestedRebaselines
});
module.exports = __toCommonJS(rebase_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_projectUtils = require("./projectUtils");
var import_babelBundle = require("../transform/babelBundle");
const t = import_babelBundle.types;
const suggestedRebaselines = new import_utils.MultiMap();
function addSuggestedRebaseline(location, suggestedRebaseline) {
suggestedRebaselines.set(location.file, { location, code: suggestedRebaseline });
}
function clearSuggestedRebaselines() {
suggestedRebaselines.clear();
}
async function applySuggestedRebaselines(config, reporter) {
if (config.config.updateSnapshots === "none")
return;
if (!suggestedRebaselines.size)
return;
const [project] = (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
if (!project)
return;
const patches = [];
const files = [];
const gitCache = /* @__PURE__ */ new Map();
const patchFile = import_path.default.join(project.project.outputDir, "rebaselines.patch");
for (const fileName of [...suggestedRebaselines.keys()].sort()) {
const source = await import_fs.default.promises.readFile(fileName, "utf8");
const lines = source.split("\n");
const replacements = suggestedRebaselines.get(fileName);
const fileNode = (0, import_babelBundle.babelParse)(source, fileName, true);
const ranges = [];
(0, import_babelBundle.traverse)(fileNode, {
CallExpression: (path2) => {
const node = path2.node;
if (node.arguments.length < 1)
return;
if (!t.isMemberExpression(node.callee))
return;
const argument = node.arguments[0];
if (!t.isStringLiteral(argument) && !t.isTemplateLiteral(argument))
return;
const prop = node.callee.property;
if (!prop.loc || !argument.start || !argument.end)
return;
for (const replacement of replacements) {
if (prop.loc.start.line !== replacement.location.line)
continue;
if (prop.loc.start.column + 1 !== replacement.location.column)
continue;
const indent = lines[prop.loc.start.line - 1].match(/^\s*/)[0];
const newText = replacement.code.replace(/\{indent\}/g, indent);
ranges.push({ start: argument.start, end: argument.end, oldText: source.substring(argument.start, argument.end), newText });
break;
}
}
});
ranges.sort((a, b) => b.start - a.start);
let result = source;
for (const range of ranges)
result = result.substring(0, range.start) + range.newText + result.substring(range.end);
const relativeName = import_path.default.relative(process.cwd(), fileName);
files.push(relativeName);
if (config.config.updateSourceMethod === "overwrite") {
await import_fs.default.promises.writeFile(fileName, result);
} else if (config.config.updateSourceMethod === "3way") {
await import_fs.default.promises.writeFile(fileName, applyPatchWithConflictMarkers(source, result));
} else {
const gitFolder = findGitRoot(import_path.default.dirname(fileName), gitCache);
const relativeToGit = import_path.default.relative(gitFolder || process.cwd(), fileName);
patches.push(createPatch(relativeToGit, source, result));
}
}
const fileList = files.map((file) => " " + import_utils2.colors.dim(file)).join("\n");
reporter.onStdErr(`
New baselines created for:
${fileList}
`);
if (config.config.updateSourceMethod === "patch") {
await import_fs.default.promises.mkdir(import_path.default.dirname(patchFile), { recursive: true });
await import_fs.default.promises.writeFile(patchFile, patches.join("\n"));
reporter.onStdErr(`
` + import_utils2.colors.cyan("git apply " + import_path.default.relative(process.cwd(), patchFile)) + "\n");
}
}
function createPatch(fileName, before, after) {
const file = fileName.replace(/\\/g, "/");
const text = import_utilsBundle.diff.createPatch(file, before, after, void 0, void 0, { context: 3 });
return [
"diff --git a/" + file + " b/" + file,
"--- a/" + file,
"+++ b/" + file,
...text.split("\n").slice(4)
].join("\n");
}
function findGitRoot(dir, cache) {
const result = cache.get(dir);
if (result !== void 0)
return result;
const gitPath = import_path.default.join(dir, ".git");
if (import_fs.default.existsSync(gitPath) && import_fs.default.lstatSync(gitPath).isDirectory()) {
cache.set(dir, dir);
return dir;
}
const parentDir = import_path.default.dirname(dir);
if (dir === parentDir) {
cache.set(dir, null);
return null;
}
const parentResult = findGitRoot(parentDir, cache);
cache.set(dir, parentResult);
return parentResult;
}
function applyPatchWithConflictMarkers(oldText, newText) {
const diffResult = import_utilsBundle.diff.diffLines(oldText, newText);
let result = "";
let conflict = false;
diffResult.forEach((part) => {
if (part.added) {
if (conflict) {
result += part.value;
result += ">>>>>>> SNAPSHOT\n";
conflict = false;
} else {
result += "<<<<<<< HEAD\n";
result += part.value;
result += "=======\n";
conflict = true;
}
} else if (part.removed) {
result += "<<<<<<< HEAD\n";
result += part.value;
result += "=======\n";
conflict = true;
} else {
if (conflict) {
result += ">>>>>>> SNAPSHOT\n";
conflict = false;
}
result += part.value;
}
});
if (conflict)
result += ">>>>>>> SNAPSHOT\n";
return result;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
addSuggestedRebaseline,
applySuggestedRebaselines,
clearSuggestedRebaselines
});

137
node_modules/playwright/lib/runner/reporters.js generated vendored Normal file
View File

@@ -0,0 +1,137 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var reporters_exports = {};
__export(reporters_exports, {
createErrorCollectingReporter: () => createErrorCollectingReporter,
createReporterForTestServer: () => createReporterForTestServer,
createReporters: () => createReporters
});
module.exports = __toCommonJS(reporters_exports);
var import_utils = require("playwright-core/lib/utils");
var import_loadUtils = require("./loadUtils");
var import_base = require("../reporters/base");
var import_blob = require("../reporters/blob");
var import_dot = __toESM(require("../reporters/dot"));
var import_empty = __toESM(require("../reporters/empty"));
var import_github = __toESM(require("../reporters/github"));
var import_html = __toESM(require("../reporters/html"));
var import_json = __toESM(require("../reporters/json"));
var import_junit = __toESM(require("../reporters/junit"));
var import_line = __toESM(require("../reporters/line"));
var import_list = __toESM(require("../reporters/list"));
var import_listModeReporter = __toESM(require("../reporters/listModeReporter"));
var import_reporterV2 = require("../reporters/reporterV2");
async function createReporters(config, mode, isTestServer, descriptions) {
const defaultReporters = {
blob: import_blob.BlobReporter,
dot: mode === "list" ? import_listModeReporter.default : import_dot.default,
line: mode === "list" ? import_listModeReporter.default : import_line.default,
list: mode === "list" ? import_listModeReporter.default : import_list.default,
github: import_github.default,
json: import_json.default,
junit: import_junit.default,
null: import_empty.default,
html: import_html.default
};
const reporters = [];
descriptions ??= config.config.reporter;
if (config.configCLIOverrides.additionalReporters)
descriptions = [...descriptions, ...config.configCLIOverrides.additionalReporters];
const runOptions = reporterOptions(config, mode, isTestServer);
for (const r of descriptions) {
const [name, arg] = r;
const options = { ...runOptions, ...arg };
if (name in defaultReporters) {
reporters.push(new defaultReporters[name](options));
} else {
const reporterConstructor = await (0, import_loadUtils.loadReporter)(config, name);
reporters.push((0, import_reporterV2.wrapReporterAsV2)(new reporterConstructor(options)));
}
}
if (process.env.PW_TEST_REPORTER) {
const reporterConstructor = await (0, import_loadUtils.loadReporter)(config, process.env.PW_TEST_REPORTER);
reporters.push((0, import_reporterV2.wrapReporterAsV2)(new reporterConstructor(runOptions)));
}
const someReporterPrintsToStdio = reporters.some((r) => r.printsToStdio ? r.printsToStdio() : true);
if (reporters.length && !someReporterPrintsToStdio) {
if (mode === "list")
reporters.unshift(new import_listModeReporter.default());
else if (mode !== "merge")
reporters.unshift(!process.env.CI ? new import_line.default() : new import_dot.default());
}
return reporters;
}
async function createReporterForTestServer(file, messageSink) {
const reporterConstructor = await (0, import_loadUtils.loadReporter)(null, file);
return (0, import_reporterV2.wrapReporterAsV2)(new reporterConstructor({
_send: messageSink
}));
}
function createErrorCollectingReporter(screen) {
const errors = [];
return {
version: () => "v2",
onError(error) {
errors.push(error);
screen.stderr?.write((0, import_base.formatError)(screen, error).message + "\n");
},
errors: () => errors
};
}
function reporterOptions(config, mode, isTestServer) {
return {
configDir: config.configDir,
_mode: mode,
_isTestServer: isTestServer,
_commandHash: computeCommandHash(config)
};
}
function computeCommandHash(config) {
const parts = [];
if (config.cliProjectFilter)
parts.push(...config.cliProjectFilter);
const command = {};
if (config.cliArgs.length)
command.cliArgs = config.cliArgs;
if (config.cliGrep)
command.cliGrep = config.cliGrep;
if (config.cliGrepInvert)
command.cliGrepInvert = config.cliGrepInvert;
if (config.cliOnlyChanged)
command.cliOnlyChanged = config.cliOnlyChanged;
if (Object.keys(command).length)
parts.push((0, import_utils.calculateSha1)(JSON.stringify(command)).substring(0, 7));
return parts.join("-");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createErrorCollectingReporter,
createReporterForTestServer,
createReporters
});

96
node_modules/playwright/lib/runner/sigIntWatcher.js generated vendored Normal file
View File

@@ -0,0 +1,96 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var sigIntWatcher_exports = {};
__export(sigIntWatcher_exports, {
SigIntWatcher: () => SigIntWatcher
});
module.exports = __toCommonJS(sigIntWatcher_exports);
class SigIntWatcher {
constructor() {
this._hadSignal = false;
let sigintCallback;
this._sigintPromise = new Promise((f) => sigintCallback = f);
this._sigintHandler = () => {
FixedNodeSIGINTHandler.off(this._sigintHandler);
this._hadSignal = true;
sigintCallback();
};
FixedNodeSIGINTHandler.on(this._sigintHandler);
}
promise() {
return this._sigintPromise;
}
hadSignal() {
return this._hadSignal;
}
disarm() {
FixedNodeSIGINTHandler.off(this._sigintHandler);
}
}
class FixedNodeSIGINTHandler {
static {
this._handlers = [];
}
static {
this._ignoreNextSIGINTs = false;
}
static {
this._handlerInstalled = false;
}
static {
this._dispatch = () => {
if (this._ignoreNextSIGINTs)
return;
this._ignoreNextSIGINTs = true;
setTimeout(() => {
this._ignoreNextSIGINTs = false;
if (!this._handlers.length)
this._uninstall();
}, 1e3);
for (const handler of this._handlers)
handler();
};
}
static _install() {
if (!this._handlerInstalled) {
this._handlerInstalled = true;
process.on("SIGINT", this._dispatch);
}
}
static _uninstall() {
if (this._handlerInstalled) {
this._handlerInstalled = false;
process.off("SIGINT", this._dispatch);
}
}
static on(handler) {
this._handlers.push(handler);
if (this._handlers.length === 1)
this._install();
}
static off(handler) {
this._handlers = this._handlers.filter((h) => h !== handler);
if (!this._ignoreNextSIGINTs && !this._handlers.length)
this._uninstall();
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SigIntWatcher
});

127
node_modules/playwright/lib/runner/taskRunner.js generated vendored Normal file
View File

@@ -0,0 +1,127 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var taskRunner_exports = {};
__export(taskRunner_exports, {
TaskRunner: () => TaskRunner
});
module.exports = __toCommonJS(taskRunner_exports);
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_sigIntWatcher = require("./sigIntWatcher");
var import_util = require("../util");
class TaskRunner {
constructor(reporter, globalTimeoutForError) {
this._tasks = [];
this._hasErrors = false;
this._interrupted = false;
this._isTearDown = false;
this._reporter = reporter;
this._globalTimeoutForError = globalTimeoutForError;
}
addTask(task) {
this._tasks.push(task);
}
async run(context, deadline, cancelPromise) {
const { status, cleanup } = await this.runDeferCleanup(context, deadline, cancelPromise);
const teardownStatus = await cleanup();
return status === "passed" ? teardownStatus : status;
}
async runDeferCleanup(context, deadline, cancelPromise = new import_utils.ManualPromise()) {
const sigintWatcher = new import_sigIntWatcher.SigIntWatcher();
const timeoutWatcher = new TimeoutWatcher(deadline);
const teardownRunner = new TaskRunner(this._reporter, this._globalTimeoutForError);
teardownRunner._isTearDown = true;
let currentTaskName;
const taskLoop = async () => {
for (const task of this._tasks) {
currentTaskName = task.title;
if (this._interrupted)
break;
(0, import_utilsBundle.debug)("pw:test:task")(`"${task.title}" started`);
const errors = [];
const softErrors = [];
try {
teardownRunner._tasks.unshift({ title: `teardown for ${task.title}`, setup: task.teardown });
await task.setup?.(context, errors, softErrors);
} catch (e) {
(0, import_utilsBundle.debug)("pw:test:task")(`error in "${task.title}": `, e);
errors.push((0, import_util.serializeError)(e));
} finally {
for (const error of [...softErrors, ...errors])
this._reporter.onError?.(error);
if (errors.length) {
if (!this._isTearDown)
this._interrupted = true;
this._hasErrors = true;
}
}
(0, import_utilsBundle.debug)("pw:test:task")(`"${task.title}" finished`);
}
};
await Promise.race([
taskLoop(),
cancelPromise,
sigintWatcher.promise(),
timeoutWatcher.promise
]);
sigintWatcher.disarm();
timeoutWatcher.disarm();
this._interrupted = true;
let status = "passed";
if (sigintWatcher.hadSignal() || cancelPromise?.isDone()) {
status = "interrupted";
} else if (timeoutWatcher.timedOut()) {
this._reporter.onError?.({ message: import_utils2.colors.red(`Timed out waiting ${this._globalTimeoutForError / 1e3}s for the ${currentTaskName} to run`) });
status = "timedout";
} else if (this._hasErrors) {
status = "failed";
}
cancelPromise?.resolve();
const cleanup = () => teardownRunner.runDeferCleanup(context, deadline).then((r) => r.status);
return { status, cleanup };
}
}
class TimeoutWatcher {
constructor(deadline) {
this._timedOut = false;
this.promise = new import_utils.ManualPromise();
if (!deadline)
return;
if (deadline - (0, import_utils.monotonicTime)() <= 0) {
this._timedOut = true;
this.promise.resolve();
return;
}
this._timer = setTimeout(() => {
this._timedOut = true;
this.promise.resolve();
}, deadline - (0, import_utils.monotonicTime)());
}
timedOut() {
return this._timedOut;
}
disarm() {
clearTimeout(this._timer);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TaskRunner
});

399
node_modules/playwright/lib/runner/tasks.js generated vendored Normal file
View File

@@ -0,0 +1,399 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var tasks_exports = {};
__export(tasks_exports, {
TestRun: () => TestRun,
createApplyRebaselinesTask: () => createApplyRebaselinesTask,
createClearCacheTask: () => createClearCacheTask,
createGlobalSetupTasks: () => createGlobalSetupTasks,
createListFilesTask: () => createListFilesTask,
createLoadTask: () => createLoadTask,
createPluginSetupTasks: () => createPluginSetupTasks,
createReportBeginTask: () => createReportBeginTask,
createRunTestsTasks: () => createRunTestsTasks,
createStartDevServerTask: () => createStartDevServerTask,
runTasks: () => runTasks,
runTasksDeferCleanup: () => runTasksDeferCleanup
});
module.exports = __toCommonJS(tasks_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_util = require("util");
var import_utils = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_dispatcher = require("./dispatcher");
var import_failureTracker = require("./failureTracker");
var import_loadUtils = require("./loadUtils");
var import_projectUtils = require("./projectUtils");
var import_rebase = require("./rebase");
var import_taskRunner = require("./taskRunner");
var import_vcs = require("./vcs");
var import_test = require("../common/test");
var import_testGroups = require("../runner/testGroups");
var import_compilationCache = require("../transform/compilationCache");
var import_util2 = require("../util");
const readDirAsync = (0, import_util.promisify)(import_fs.default.readdir);
class TestRun {
constructor(config, reporter) {
this.rootSuite = void 0;
this.phases = [];
this.projectFiles = /* @__PURE__ */ new Map();
this.projectSuites = /* @__PURE__ */ new Map();
this.config = config;
this.reporter = reporter;
this.failureTracker = new import_failureTracker.FailureTracker(config);
}
}
async function runTasks(testRun, tasks, globalTimeout, cancelPromise) {
const deadline = globalTimeout ? (0, import_utils.monotonicTime)() + globalTimeout : 0;
const taskRunner = new import_taskRunner.TaskRunner(testRun.reporter, globalTimeout || 0);
for (const task of tasks)
taskRunner.addTask(task);
testRun.reporter.onConfigure(testRun.config.config);
const status = await taskRunner.run(testRun, deadline, cancelPromise);
return await finishTaskRun(testRun, status);
}
async function runTasksDeferCleanup(testRun, tasks) {
const taskRunner = new import_taskRunner.TaskRunner(testRun.reporter, 0);
for (const task of tasks)
taskRunner.addTask(task);
testRun.reporter.onConfigure(testRun.config.config);
const { status, cleanup } = await taskRunner.runDeferCleanup(testRun, 0);
return { status: await finishTaskRun(testRun, status), cleanup };
}
async function finishTaskRun(testRun, status) {
if (status === "passed")
status = testRun.failureTracker.result();
const modifiedResult = await testRun.reporter.onEnd({ status });
if (modifiedResult && modifiedResult.status)
status = modifiedResult.status;
await testRun.reporter.onExit();
return status;
}
function createGlobalSetupTasks(config) {
const tasks = [];
if (!config.configCLIOverrides.preserveOutputDir)
tasks.push(createRemoveOutputDirsTask());
tasks.push(
...createPluginSetupTasks(config),
...config.globalTeardowns.map((file) => createGlobalTeardownTask(file, config)).reverse(),
...config.globalSetups.map((file) => createGlobalSetupTask(file, config))
);
return tasks;
}
function createRunTestsTasks(config) {
return [
createPhasesTask(),
createReportBeginTask(),
...config.plugins.map((plugin) => createPluginBeginTask(plugin)),
createRunTestsTask()
];
}
function createClearCacheTask(config) {
return {
title: "clear cache",
setup: async () => {
await (0, import_util2.removeDirAndLogToConsole)(import_compilationCache.cacheDir);
for (const plugin of config.plugins)
await plugin.instance?.clearCache?.();
}
};
}
function createReportBeginTask() {
return {
title: "report begin",
setup: async (testRun) => {
testRun.reporter.onBegin?.(testRun.rootSuite);
},
teardown: async ({}) => {
}
};
}
function createPluginSetupTasks(config) {
return config.plugins.map((plugin) => ({
title: "plugin setup",
setup: async ({ reporter }) => {
if (typeof plugin.factory === "function")
plugin.instance = await plugin.factory();
else
plugin.instance = plugin.factory;
await plugin.instance?.setup?.(config.config, config.configDir, reporter);
},
teardown: async () => {
await plugin.instance?.teardown?.();
}
}));
}
function createPluginBeginTask(plugin) {
return {
title: "plugin begin",
setup: async (testRun) => {
await plugin.instance?.begin?.(testRun.rootSuite);
},
teardown: async () => {
await plugin.instance?.end?.();
}
};
}
function createGlobalSetupTask(file, config) {
let title = "global setup";
if (config.globalSetups.length > 1)
title += ` (${file})`;
let globalSetupResult;
return {
title,
setup: async ({ config: config2 }) => {
const setupHook = await (0, import_loadUtils.loadGlobalHook)(config2, file);
globalSetupResult = await setupHook(config2.config);
},
teardown: async () => {
if (typeof globalSetupResult === "function")
await globalSetupResult();
}
};
}
function createGlobalTeardownTask(file, config) {
let title = "global teardown";
if (config.globalTeardowns.length > 1)
title += ` (${file})`;
return {
title,
teardown: async ({ config: config2 }) => {
const teardownHook = await (0, import_loadUtils.loadGlobalHook)(config2, file);
await teardownHook(config2.config);
}
};
}
function createRemoveOutputDirsTask() {
return {
title: "clear output",
setup: async ({ config }) => {
const outputDirs = /* @__PURE__ */ new Set();
const projects = (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
projects.forEach((p) => outputDirs.add(p.project.outputDir));
await Promise.all(Array.from(outputDirs).map((outputDir) => (0, import_utils.removeFolders)([outputDir]).then(async ([error]) => {
if (!error)
return;
if (error.code === "EBUSY") {
const entries = await readDirAsync(outputDir).catch((e) => []);
await Promise.all(entries.map((entry) => (0, import_utils.removeFolders)([import_path.default.join(outputDir, entry)])));
} else {
throw error;
}
})));
}
};
}
function createListFilesTask() {
return {
title: "load tests",
setup: async (testRun, errors) => {
testRun.rootSuite = await (0, import_loadUtils.createRootSuite)(testRun, errors, false);
testRun.failureTracker.onRootSuite(testRun.rootSuite);
await (0, import_loadUtils.collectProjectsAndTestFiles)(testRun, false);
for (const [project, files] of testRun.projectFiles) {
const projectSuite = new import_test.Suite(project.project.name, "project");
projectSuite._fullProject = project;
testRun.rootSuite._addSuite(projectSuite);
const suites = files.map((file) => {
const title = import_path.default.relative(testRun.config.config.rootDir, file);
const suite = new import_test.Suite(title, "file");
suite.location = { file, line: 0, column: 0 };
projectSuite._addSuite(suite);
return suite;
});
testRun.projectSuites.set(project, suites);
}
}
};
}
function createLoadTask(mode, options) {
return {
title: "load tests",
setup: async (testRun, errors, softErrors) => {
await (0, import_loadUtils.collectProjectsAndTestFiles)(testRun, !!options.doNotRunDepsOutsideProjectFilter);
await (0, import_loadUtils.loadFileSuites)(testRun, mode, options.failOnLoadErrors ? errors : softErrors);
if (testRun.config.cliOnlyChanged || options.populateDependencies) {
for (const plugin of testRun.config.plugins)
await plugin.instance?.populateDependencies?.();
}
if (testRun.config.cliOnlyChanged) {
const changedFiles = await (0, import_vcs.detectChangedTestFiles)(testRun.config.cliOnlyChanged, testRun.config.configDir);
testRun.config.preOnlyTestFilters.push((test) => changedFiles.has(test.location.file));
}
testRun.rootSuite = await (0, import_loadUtils.createRootSuite)(testRun, options.failOnLoadErrors ? errors : softErrors, !!options.filterOnly);
testRun.failureTracker.onRootSuite(testRun.rootSuite);
if (options.failOnLoadErrors && !testRun.rootSuite.allTests().length && !testRun.config.cliPassWithNoTests && !testRun.config.config.shard && !testRun.config.cliOnlyChanged) {
if (testRun.config.cliArgs.length) {
throw new Error([
`No tests found.`,
`Make sure that arguments are regular expressions matching test files.`,
`You may need to escape symbols like "$" or "*" and quote the arguments.`
].join("\n"));
}
throw new Error(`No tests found`);
}
}
};
}
function createApplyRebaselinesTask() {
return {
title: "apply rebaselines",
setup: async () => {
(0, import_rebase.clearSuggestedRebaselines)();
},
teardown: async ({ config, reporter }) => {
await (0, import_rebase.applySuggestedRebaselines)(config, reporter);
}
};
}
function createPhasesTask() {
return {
title: "create phases",
setup: async (testRun) => {
let maxConcurrentTestGroups = 0;
const processed = /* @__PURE__ */ new Set();
const projectToSuite = new Map(testRun.rootSuite.suites.map((suite) => [suite._fullProject, suite]));
const allProjects = [...projectToSuite.keys()];
const teardownToSetups = (0, import_projectUtils.buildTeardownToSetupsMap)(allProjects);
const teardownToSetupsDependents = /* @__PURE__ */ new Map();
for (const [teardown, setups] of teardownToSetups) {
const closure = (0, import_projectUtils.buildDependentProjects)(setups, allProjects);
closure.delete(teardown);
teardownToSetupsDependents.set(teardown, [...closure]);
}
for (let i = 0; i < projectToSuite.size; i++) {
const phaseProjects = [];
for (const project of projectToSuite.keys()) {
if (processed.has(project))
continue;
const projectsThatShouldFinishFirst = [...project.deps, ...teardownToSetupsDependents.get(project) || []];
if (projectsThatShouldFinishFirst.find((p) => !processed.has(p)))
continue;
phaseProjects.push(project);
}
for (const project of phaseProjects)
processed.add(project);
if (phaseProjects.length) {
let testGroupsInPhase = 0;
const phase = { dispatcher: new import_dispatcher.Dispatcher(testRun.config, testRun.reporter, testRun.failureTracker), projects: [] };
testRun.phases.push(phase);
for (const project of phaseProjects) {
const projectSuite = projectToSuite.get(project);
const testGroups = (0, import_testGroups.createTestGroups)(projectSuite, testRun.config.config.workers);
phase.projects.push({ project, projectSuite, testGroups });
testGroupsInPhase += Math.min(project.workers ?? Number.MAX_SAFE_INTEGER, testGroups.length);
}
(0, import_utilsBundle.debug)("pw:test:task")(`created phase #${testRun.phases.length} with ${phase.projects.map((p) => p.project.project.name).sort()} projects, ${testGroupsInPhase} testGroups`);
maxConcurrentTestGroups = Math.max(maxConcurrentTestGroups, testGroupsInPhase);
}
}
testRun.config.config.metadata.actualWorkers = Math.min(testRun.config.config.workers, maxConcurrentTestGroups);
}
};
}
function createRunTestsTask() {
return {
title: "test suite",
setup: async ({ phases, failureTracker }) => {
const successfulProjects = /* @__PURE__ */ new Set();
const extraEnvByProjectId = /* @__PURE__ */ new Map();
const teardownToSetups = (0, import_projectUtils.buildTeardownToSetupsMap)(phases.map((phase) => phase.projects.map((p) => p.project)).flat());
for (const { dispatcher, projects } of phases) {
const phaseTestGroups = [];
for (const { project, testGroups } of projects) {
let extraEnv = {};
for (const dep of project.deps)
extraEnv = { ...extraEnv, ...extraEnvByProjectId.get(dep.id) };
for (const setup of teardownToSetups.get(project) || [])
extraEnv = { ...extraEnv, ...extraEnvByProjectId.get(setup.id) };
extraEnvByProjectId.set(project.id, extraEnv);
const hasFailedDeps = project.deps.some((p) => !successfulProjects.has(p));
if (!hasFailedDeps)
phaseTestGroups.push(...testGroups);
}
if (phaseTestGroups.length) {
await dispatcher.run(phaseTestGroups, extraEnvByProjectId);
await dispatcher.stop();
for (const [projectId, envProduced] of dispatcher.producedEnvByProjectId()) {
const extraEnv = extraEnvByProjectId.get(projectId) || {};
extraEnvByProjectId.set(projectId, { ...extraEnv, ...envProduced });
}
}
if (!failureTracker.hasWorkerErrors()) {
for (const { project, projectSuite } of projects) {
const hasFailedDeps = project.deps.some((p) => !successfulProjects.has(p));
if (!hasFailedDeps && !projectSuite.allTests().some((test) => !test.ok()))
successfulProjects.add(project);
}
}
}
},
teardown: async ({ phases }) => {
for (const { dispatcher } of phases.reverse())
await dispatcher.stop();
}
};
}
function createStartDevServerTask() {
return {
title: "start dev server",
setup: async ({ config }, errors, softErrors) => {
if (config.plugins.some((plugin) => !!plugin.devServerCleanup)) {
errors.push({ message: `DevServer is already running` });
return;
}
for (const plugin of config.plugins)
plugin.devServerCleanup = await plugin.instance?.startDevServer?.();
if (!config.plugins.some((plugin) => !!plugin.devServerCleanup))
errors.push({ message: `DevServer is not available in the package you are using. Did you mean to use component testing?` });
},
teardown: async ({ config }) => {
for (const plugin of config.plugins) {
await plugin.devServerCleanup?.();
plugin.devServerCleanup = void 0;
}
}
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TestRun,
createApplyRebaselinesTask,
createClearCacheTask,
createGlobalSetupTasks,
createListFilesTask,
createLoadTask,
createPluginSetupTasks,
createReportBeginTask,
createRunTestsTasks,
createStartDevServerTask,
runTasks,
runTasksDeferCleanup
});

117
node_modules/playwright/lib/runner/testGroups.js generated vendored Normal file
View File

@@ -0,0 +1,117 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testGroups_exports = {};
__export(testGroups_exports, {
createTestGroups: () => createTestGroups,
filterForShard: () => filterForShard
});
module.exports = __toCommonJS(testGroups_exports);
function createTestGroups(projectSuite, expectedParallelism) {
const groups = /* @__PURE__ */ new Map();
const createGroup = (test) => {
return {
workerHash: test._workerHash,
requireFile: test._requireFile,
repeatEachIndex: test.repeatEachIndex,
projectId: test._projectId,
tests: []
};
};
for (const test of projectSuite.allTests()) {
let withWorkerHash = groups.get(test._workerHash);
if (!withWorkerHash) {
withWorkerHash = /* @__PURE__ */ new Map();
groups.set(test._workerHash, withWorkerHash);
}
let withRequireFile = withWorkerHash.get(test._requireFile);
if (!withRequireFile) {
withRequireFile = {
general: createGroup(test),
parallel: /* @__PURE__ */ new Map(),
parallelWithHooks: createGroup(test)
};
withWorkerHash.set(test._requireFile, withRequireFile);
}
let insideParallel = false;
let outerMostSequentialSuite;
let hasAllHooks = false;
for (let parent = test.parent; parent; parent = parent.parent) {
if (parent._parallelMode === "serial" || parent._parallelMode === "default")
outerMostSequentialSuite = parent;
insideParallel = insideParallel || parent._parallelMode === "parallel";
hasAllHooks = hasAllHooks || parent._hooks.some((hook) => hook.type === "beforeAll" || hook.type === "afterAll");
}
if (insideParallel) {
if (hasAllHooks && !outerMostSequentialSuite) {
withRequireFile.parallelWithHooks.tests.push(test);
} else {
const key = outerMostSequentialSuite || test;
let group = withRequireFile.parallel.get(key);
if (!group) {
group = createGroup(test);
withRequireFile.parallel.set(key, group);
}
group.tests.push(test);
}
} else {
withRequireFile.general.tests.push(test);
}
}
const result = [];
for (const withWorkerHash of groups.values()) {
for (const withRequireFile of withWorkerHash.values()) {
if (withRequireFile.general.tests.length)
result.push(withRequireFile.general);
result.push(...withRequireFile.parallel.values());
const parallelWithHooksGroupSize = Math.ceil(withRequireFile.parallelWithHooks.tests.length / expectedParallelism);
let lastGroup;
for (const test of withRequireFile.parallelWithHooks.tests) {
if (!lastGroup || lastGroup.tests.length >= parallelWithHooksGroupSize) {
lastGroup = createGroup(test);
result.push(lastGroup);
}
lastGroup.tests.push(test);
}
}
}
return result;
}
function filterForShard(shard, testGroups) {
let shardableTotal = 0;
for (const group of testGroups)
shardableTotal += group.tests.length;
const shardSize = Math.floor(shardableTotal / shard.total);
const extraOne = shardableTotal - shardSize * shard.total;
const currentShard = shard.current - 1;
const from = shardSize * currentShard + Math.min(extraOne, currentShard);
const to = from + shardSize + (currentShard < extraOne ? 1 : 0);
let current = 0;
const result = /* @__PURE__ */ new Set();
for (const group of testGroups) {
if (current >= from && current < to)
result.add(group);
current += group.tests.length;
}
return result;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createTestGroups,
filterForShard
});

402
node_modules/playwright/lib/runner/testRunner.js generated vendored Normal file
View File

@@ -0,0 +1,402 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testRunner_exports = {};
__export(testRunner_exports, {
TestRunner: () => TestRunner,
TestRunnerEvent: () => TestRunnerEvent,
runAllTestsWithConfig: () => runAllTestsWithConfig
});
module.exports = __toCommonJS(testRunner_exports);
var import_events = __toESM(require("events"));
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_server = require("playwright-core/lib/server");
var import_utils = require("playwright-core/lib/utils");
var import_configLoader = require("../common/configLoader");
var import_fsWatcher = require("../fsWatcher");
var import_teleReceiver = require("../isomorphic/teleReceiver");
var import_gitCommitInfoPlugin = require("../plugins/gitCommitInfoPlugin");
var import_webServerPlugin = require("../plugins/webServerPlugin");
var import_base = require("../reporters/base");
var import_internalReporter = require("../reporters/internalReporter");
var import_compilationCache = require("../transform/compilationCache");
var import_util = require("../util");
var import_reporters = require("./reporters");
var import_tasks = require("./tasks");
var import_lastRun = require("./lastRun");
const TestRunnerEvent = {
TestFilesChanged: "testFilesChanged",
RecoverFromStepError: "recoverFromStepError"
};
class TestRunner extends import_events.default {
constructor(configLocation, configCLIOverrides) {
super();
this._watchedProjectDirs = /* @__PURE__ */ new Set();
this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
this._watchedTestDependencies = /* @__PURE__ */ new Set();
this._queue = Promise.resolve();
this._watchTestDirs = false;
this._populateDependenciesOnList = false;
this._recoverFromStepErrors = false;
this._resumeAfterStepErrors = /* @__PURE__ */ new Map();
this.configLocation = configLocation;
this._configCLIOverrides = configCLIOverrides;
this._watcher = new import_fsWatcher.Watcher((events) => {
const collector = /* @__PURE__ */ new Set();
events.forEach((f) => (0, import_compilationCache.collectAffectedTestFiles)(f.file, collector));
this.emit(TestRunnerEvent.TestFilesChanged, [...collector]);
});
}
async initialize(params) {
this._watchTestDirs = !!params.watchTestDirs;
this._populateDependenciesOnList = !!params.populateDependenciesOnList;
this._recoverFromStepErrors = !!params.recoverFromStepErrors;
}
resizeTerminal(params) {
process.stdout.columns = params.cols;
process.stdout.rows = params.rows;
process.stderr.columns = params.cols;
process.stderr.rows = params.rows;
}
hasSomeBrowsers() {
for (const browserName of ["chromium", "webkit", "firefox"]) {
try {
import_server.registry.findExecutable(browserName).executablePathOrDie("javascript");
return true;
} catch {
}
}
return false;
}
async installBrowsers() {
const executables = import_server.registry.defaultExecutables();
await import_server.registry.install(executables, false);
}
async runGlobalSetup(userReporters) {
await this.runGlobalTeardown();
const reporter = new import_internalReporter.InternalReporter(userReporters);
const config = await this._loadConfigOrReportError(reporter, this._configCLIOverrides);
if (!config)
return { status: "failed" };
const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
...(0, import_tasks.createGlobalSetupTasks)(config)
]);
if (status !== "passed")
await cleanup();
else
this._globalSetup = { cleanup };
return { status };
}
async runGlobalTeardown() {
const globalSetup = this._globalSetup;
const status = await globalSetup?.cleanup();
this._globalSetup = void 0;
return { status };
}
async startDevServer(userReporter, mode) {
await this.stopDevServer();
const reporter = new import_internalReporter.InternalReporter([userReporter]);
const config = await this._loadConfigOrReportError(reporter);
if (!config)
return { status: "failed" };
const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
...(0, import_tasks.createPluginSetupTasks)(config),
(0, import_tasks.createLoadTask)(mode, { failOnLoadErrors: true, filterOnly: false }),
(0, import_tasks.createStartDevServerTask)()
]);
if (status !== "passed")
await cleanup();
else
this._devServer = { cleanup };
return { status };
}
async stopDevServer() {
const devServer = this._devServer;
const status = await devServer?.cleanup();
this._devServer = void 0;
return { status };
}
async clearCache(userReporter) {
const reporter = new import_internalReporter.InternalReporter(userReporter ? [userReporter] : []);
const config = await this._loadConfigOrReportError(reporter);
if (!config)
return { status: "failed" };
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
...(0, import_tasks.createPluginSetupTasks)(config),
(0, import_tasks.createClearCacheTask)(config)
]);
return { status };
}
async listFiles(userReporter, projects) {
const reporter = new import_internalReporter.InternalReporter([userReporter]);
const config = await this._loadConfigOrReportError(reporter);
if (!config)
return { status: "failed" };
config.cliProjectFilter = projects?.length ? projects : void 0;
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
(0, import_tasks.createListFilesTask)(),
(0, import_tasks.createReportBeginTask)()
]);
return { status };
}
async listTests(userReporter, params) {
let result;
this._queue = this._queue.then(async () => {
const { config, status } = await this._innerListTests(userReporter, params);
if (config)
await this._updateWatchedDirs(config);
result = { status };
}).catch(printInternalError);
await this._queue;
return result;
}
async _innerListTests(userReporter, params) {
const overrides = {
...this._configCLIOverrides,
repeatEach: 1,
retries: 0
};
const reporter = new import_internalReporter.InternalReporter([userReporter]);
const config = await this._loadConfigOrReportError(reporter, overrides);
if (!config)
return { status: "failed" };
config.cliArgs = params.locations || [];
config.cliGrep = params.grep;
config.cliGrepInvert = params.grepInvert;
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
config.cliListOnly = true;
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
(0, import_tasks.createReportBeginTask)()
]);
return { config, status };
}
async _updateWatchedDirs(config) {
this._watchedProjectDirs = /* @__PURE__ */ new Set();
this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
for (const p of config.projects) {
this._watchedProjectDirs.add(p.project.testDir);
this._ignoredProjectOutputs.add(p.project.outputDir);
}
const result = await resolveCtDirs(config);
if (result) {
this._watchedProjectDirs.add(result.templateDir);
this._ignoredProjectOutputs.add(result.outDir);
}
if (this._watchTestDirs)
await this._updateWatcher(false);
}
async _updateWatcher(reportPending) {
await this._watcher.update([...this._watchedProjectDirs, ...this._watchedTestDependencies], [...this._ignoredProjectOutputs], reportPending);
}
async runTests(userReporter, params) {
let result = { status: "passed" };
this._queue = this._queue.then(async () => {
result = await this._innerRunTests(userReporter, params).catch((e) => {
printInternalError(e);
return { status: "failed" };
});
});
await this._queue;
return result;
}
async _innerRunTests(userReporter, params) {
await this.stopTests();
const overrides = {
...this._configCLIOverrides,
repeatEach: 1,
retries: 0,
preserveOutputDir: true,
reporter: params.reporters ? params.reporters.map((r) => [r]) : void 0,
use: {
...this._configCLIOverrides.use,
...params.trace === "on" ? { trace: { mode: "on", sources: false, _live: true } } : {},
...params.trace === "off" ? { trace: "off" } : {},
...params.video === "on" || params.video === "off" ? { video: params.video } : {},
...params.headed !== void 0 ? { headless: !params.headed } : {},
_optionContextReuseMode: params.reuseContext ? "when-possible" : void 0,
_optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : void 0
},
...params.updateSnapshots ? { updateSnapshots: params.updateSnapshots } : {},
...params.updateSourceMethod ? { updateSourceMethod: params.updateSourceMethod } : {},
...params.workers ? { workers: params.workers } : {}
};
if (params.trace === "on")
process.env.PW_LIVE_TRACE_STACKS = "1";
else
process.env.PW_LIVE_TRACE_STACKS = void 0;
const config = await this._loadConfigOrReportError(new import_internalReporter.InternalReporter([userReporter]), overrides);
if (!config)
return { status: "failed" };
config.cliListOnly = false;
config.cliPassWithNoTests = true;
config.cliArgs = params.locations || [];
config.cliGrep = params.grep;
config.cliGrepInvert = params.grepInvert;
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
config.preOnlyTestFilters = [];
if (params.testIds) {
const testIdSet = new Set(params.testIds);
config.preOnlyTestFilters.push((test) => testIdSet.has(test.id));
}
const configReporters = await (0, import_reporters.createReporters)(config, "test", true);
const reporter = new import_internalReporter.InternalReporter([...configReporters, userReporter]);
const stop = new import_utils.ManualPromise();
const tasks = [
(0, import_tasks.createApplyRebaselinesTask)(),
(0, import_tasks.createLoadTask)("out-of-process", { filterOnly: true, failOnLoadErrors: false, doNotRunDepsOutsideProjectFilter: true }),
...(0, import_tasks.createRunTestsTasks)(config)
];
const testRun = new import_tasks.TestRun(config, reporter);
testRun.failureTracker.setRecoverFromStepErrorHandler(this._recoverFromStepError.bind(this));
const run = (0, import_tasks.runTasks)(testRun, tasks, 0, stop).then(async (status) => {
this._testRun = void 0;
return status;
});
this._testRun = { run, stop };
return { status: await run };
}
async _recoverFromStepError(stepId, error) {
if (!this._recoverFromStepErrors)
return { stepId, status: "failed" };
const recoveryPromise = new import_utils.ManualPromise();
this._resumeAfterStepErrors.set(stepId, recoveryPromise);
if (!error?.message || !error?.location)
return { stepId, status: "failed" };
this.emit(TestRunnerEvent.RecoverFromStepError, stepId, error.message, error.location);
const recoveredResult = await recoveryPromise;
if (recoveredResult.stepId !== stepId)
return { stepId, status: "failed" };
return recoveredResult;
}
async resumeAfterStepError(params) {
const recoveryPromise = this._resumeAfterStepErrors.get(params.stepId);
if (recoveryPromise)
recoveryPromise.resolve(params);
}
async watch(fileNames) {
this._watchedTestDependencies = /* @__PURE__ */ new Set();
for (const fileName of fileNames) {
this._watchedTestDependencies.add(fileName);
(0, import_compilationCache.dependenciesForTestFile)(fileName).forEach((file) => this._watchedTestDependencies.add(file));
}
await this._updateWatcher(true);
}
async findRelatedTestFiles(files, userReporter) {
const errorReporter = (0, import_reporters.createErrorCollectingReporter)(import_base.internalScreen);
const reporter = new import_internalReporter.InternalReporter(userReporter ? [userReporter, errorReporter] : [errorReporter]);
const config = await this._loadConfigOrReportError(reporter);
if (!config)
return { errors: errorReporter.errors(), testFiles: [] };
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
...(0, import_tasks.createPluginSetupTasks)(config),
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false, populateDependencies: true })
]);
if (status !== "passed")
return { errors: errorReporter.errors(), testFiles: [] };
return { testFiles: (0, import_compilationCache.affectedTestFiles)(files) };
}
async stopTests() {
this._testRun?.stop?.resolve();
await this._testRun?.run;
this._resumeAfterStepErrors.clear();
}
async closeGracefully() {
(0, import_utils.gracefullyProcessExitDoNotHang)(0);
}
async _loadConfig(overrides) {
try {
const config = await (0, import_configLoader.loadConfig)(this.configLocation, overrides);
if (!this._plugins) {
(0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
(0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
this._plugins = config.plugins || [];
} else {
config.plugins.splice(0, config.plugins.length, ...this._plugins);
}
return { config };
} catch (e) {
return { config: null, error: (0, import_util.serializeError)(e) };
}
}
async _loadConfigOrReportError(reporter, overrides) {
const { config, error } = await this._loadConfig(overrides);
if (config)
return config;
reporter.onConfigure(import_teleReceiver.baseFullConfig);
reporter.onError(error);
await reporter.onEnd({ status: "failed" });
await reporter.onExit();
return null;
}
}
function printInternalError(e) {
console.error("Internal error:", e);
}
async function resolveCtDirs(config) {
const use = config.config.projects[0].use;
const relativeTemplateDir = use.ctTemplateDir || "playwright";
const templateDir = await import_fs.default.promises.realpath(import_path.default.normalize(import_path.default.join(config.configDir, relativeTemplateDir))).catch(() => void 0);
if (!templateDir)
return null;
const outDir = use.ctCacheDir ? import_path.default.resolve(config.configDir, use.ctCacheDir) : import_path.default.resolve(templateDir, ".cache");
return {
outDir,
templateDir
};
}
async function runAllTestsWithConfig(config) {
const listOnly = config.cliListOnly;
(0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
(0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
const reporters = await (0, import_reporters.createReporters)(config, listOnly ? "list" : "test", false);
const lastRun = new import_lastRun.LastRunReporter(config);
if (config.cliLastFailed)
await lastRun.filterLastFailed();
const reporter = new import_internalReporter.InternalReporter([...reporters, lastRun]);
const tasks = listOnly ? [
(0, import_tasks.createLoadTask)("in-process", { failOnLoadErrors: true, filterOnly: false }),
(0, import_tasks.createReportBeginTask)()
] : [
(0, import_tasks.createApplyRebaselinesTask)(),
...(0, import_tasks.createGlobalSetupTasks)(config),
(0, import_tasks.createLoadTask)("in-process", { filterOnly: true, failOnLoadErrors: true }),
...(0, import_tasks.createRunTestsTasks)(config)
];
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), tasks, config.config.globalTimeout);
await new Promise((resolve) => process.stdout.write("", () => resolve()));
await new Promise((resolve) => process.stderr.write("", () => resolve()));
return status;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TestRunner,
TestRunnerEvent,
runAllTestsWithConfig
});

270
node_modules/playwright/lib/runner/testServer.js generated vendored Normal file
View File

@@ -0,0 +1,270 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testServer_exports = {};
__export(testServer_exports, {
TestRunnerEvent: () => TestRunnerEvent,
TestServerDispatcher: () => TestServerDispatcher,
runTestServer: () => runTestServer,
runUIMode: () => runUIMode
});
module.exports = __toCommonJS(testServer_exports);
var import_util = __toESM(require("util"));
var import_server = require("playwright-core/lib/server");
var import_utils = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
var import_configLoader = require("../common/configLoader");
var import_list = __toESM(require("../reporters/list"));
var import_reporters = require("./reporters");
var import_sigIntWatcher = require("./sigIntWatcher");
var import_testRunner = require("./testRunner");
const originalDebugLog = import_utilsBundle.debug.log;
const originalStdoutWrite = process.stdout.write;
const originalStderrWrite = process.stderr.write;
class TestServer {
constructor(configLocation, configCLIOverrides) {
this._configLocation = configLocation;
this._configCLIOverrides = configCLIOverrides;
}
async start(options) {
this._dispatcher = new TestServerDispatcher(this._configLocation, this._configCLIOverrides);
return await (0, import_server.startTraceViewerServer)({ ...options, transport: this._dispatcher.transport });
}
async stop() {
await this._dispatcher?._setInterceptStdio(false);
await this._dispatcher?.runGlobalTeardown();
}
}
const TestRunnerEvent = {
TestFilesChanged: "testFilesChanged",
RecoverFromStepError: "recoverFromStepError"
};
class TestServerDispatcher {
constructor(configLocation, configCLIOverrides) {
this._serializer = require.resolve("./uiModeReporter");
this._closeOnDisconnect = false;
this._testRunner = new import_testRunner.TestRunner(configLocation, configCLIOverrides);
this.transport = {
onconnect: () => {
},
dispatch: (method, params) => this[method](params),
onclose: () => {
if (this._closeOnDisconnect)
(0, import_utils.gracefullyProcessExitDoNotHang)(0);
}
};
this._dispatchEvent = (method, params) => this.transport.sendEvent?.(method, params);
this._testRunner.on(TestRunnerEvent.TestFilesChanged, (testFiles) => this._dispatchEvent("testFilesChanged", { testFiles }));
this._testRunner.on(TestRunnerEvent.RecoverFromStepError, (stepId, message, location) => this._dispatchEvent("recoverFromStepError", { stepId, message, location }));
}
async _wireReporter(messageSink) {
return await (0, import_reporters.createReporterForTestServer)(this._serializer, messageSink);
}
async _collectingReporter() {
const report = [];
return {
reporter: await (0, import_reporters.createReporterForTestServer)(this._serializer, (e) => report.push(e)),
report
};
}
async initialize(params) {
this._serializer = params.serializer || require.resolve("./uiModeReporter");
this._closeOnDisconnect = !!params.closeOnDisconnect;
await this._setInterceptStdio(!!params.interceptStdio);
await this._testRunner.initialize({
watchTestDirs: !!params.watchTestDirs,
populateDependenciesOnList: !!params.populateDependenciesOnList,
recoverFromStepErrors: !!params.recoverFromStepErrors
});
}
async ping() {
}
async open(params) {
if ((0, import_utils.isUnderTest)())
return;
(0, import_utilsBundle.open)("vscode://file/" + params.location.file + ":" + params.location.line).catch((e) => console.error(e));
}
async resizeTerminal(params) {
this._testRunner.resizeTerminal(params);
}
async checkBrowsers() {
return { hasBrowsers: this._testRunner.hasSomeBrowsers() };
}
async installBrowsers() {
await this._testRunner.installBrowsers();
}
async runGlobalSetup(params) {
await this.runGlobalTeardown();
const { reporter, report } = await this._collectingReporter();
this._globalSetupReport = report;
const { status } = await this._testRunner.runGlobalSetup([reporter, new import_list.default()]);
return { report, status };
}
async runGlobalTeardown() {
const { status } = await this._testRunner.runGlobalTeardown();
const report = this._globalSetupReport || [];
this._globalSetupReport = void 0;
return { status, report };
}
async startDevServer(params) {
await this.stopDevServer({});
const { reporter, report } = await this._collectingReporter();
const { status } = await this._testRunner.startDevServer(reporter, "out-of-process");
return { report, status };
}
async stopDevServer(params) {
const { status } = await this._testRunner.stopDevServer();
const report = this._devServerReport || [];
this._devServerReport = void 0;
return { status, report };
}
async clearCache(params) {
await this._testRunner.clearCache();
}
async listFiles(params) {
const { reporter, report } = await this._collectingReporter();
const { status } = await this._testRunner.listFiles(reporter, params.projects);
return { report, status };
}
async listTests(params) {
const { reporter, report } = await this._collectingReporter();
const { status } = await this._testRunner.listTests(reporter, params);
return { report, status };
}
async runTests(params) {
const wireReporter = await this._wireReporter((e) => this._dispatchEvent("report", e));
const { status } = await this._testRunner.runTests(wireReporter, params);
return { status };
}
async resumeAfterStepError(params) {
await this._testRunner.resumeAfterStepError(params);
}
async watch(params) {
await this._testRunner.watch(params.fileNames);
}
async findRelatedTestFiles(params) {
return this._testRunner.findRelatedTestFiles(params.files);
}
async stopTests() {
await this._testRunner.stopTests();
}
async _setInterceptStdio(intercept) {
if (process.env.PWTEST_DEBUG)
return;
if (intercept) {
if (import_utilsBundle.debug.log === originalDebugLog) {
import_utilsBundle.debug.log = (...args) => {
const string = import_util.default.format(...args) + "\n";
return originalStderrWrite.apply(process.stderr, [string]);
};
}
const stdoutWrite = (chunk) => {
this._dispatchEvent("stdio", chunkToPayload("stdout", chunk));
return true;
};
const stderrWrite = (chunk) => {
this._dispatchEvent("stdio", chunkToPayload("stderr", chunk));
return true;
};
process.stdout.write = stdoutWrite;
process.stderr.write = stderrWrite;
} else {
import_utilsBundle.debug.log = originalDebugLog;
process.stdout.write = originalStdoutWrite;
process.stderr.write = originalStderrWrite;
}
}
async closeGracefully() {
await this._testRunner.closeGracefully();
}
}
async function runUIMode(configFile, configCLIOverrides, options) {
const configLocation = (0, import_configLoader.resolveConfigLocation)(configFile);
return await innerRunTestServer(configLocation, configCLIOverrides, options, async (server, cancelPromise) => {
await (0, import_server.installRootRedirect)(server, [], { ...options, webApp: "uiMode.html" });
if (options.host !== void 0 || options.port !== void 0) {
await (0, import_server.openTraceInBrowser)(server.urlPrefix("human-readable"));
} else {
const channel = await installedChromiumChannelForUI(configLocation, configCLIOverrides);
const page = await (0, import_server.openTraceViewerApp)(server.urlPrefix("precise"), "chromium", {
headless: (0, import_utils.isUnderTest)() && process.env.PWTEST_HEADED_FOR_TEST !== "1",
persistentContextOptions: {
handleSIGINT: false,
channel
}
});
page.on("close", () => cancelPromise.resolve());
}
});
}
async function installedChromiumChannelForUI(configLocation, configCLIOverrides) {
const config = await (0, import_configLoader.loadConfig)(configLocation, configCLIOverrides).catch((e) => null);
if (!config)
return void 0;
if (config.projects.some((p) => (!p.project.use.browserName || p.project.use.browserName === "chromium") && !p.project.use.channel))
return void 0;
for (const channel of ["chromium", "chrome", "msedge"]) {
if (config.projects.some((p) => p.project.use.channel === channel))
return channel;
}
return void 0;
}
async function runTestServer(configFile, configCLIOverrides, options) {
const configLocation = (0, import_configLoader.resolveConfigLocation)(configFile);
return await innerRunTestServer(configLocation, configCLIOverrides, options, async (server) => {
console.log("Listening on " + server.urlPrefix("precise").replace("http:", "ws:") + "/" + server.wsGuid());
});
}
async function innerRunTestServer(configLocation, configCLIOverrides, options, openUI) {
const testServer = new TestServer(configLocation, configCLIOverrides);
const cancelPromise = new import_utils.ManualPromise();
const sigintWatcher = new import_sigIntWatcher.SigIntWatcher();
process.stdin.on("close", () => (0, import_utils.gracefullyProcessExitDoNotHang)(0));
void sigintWatcher.promise().then(() => cancelPromise.resolve());
try {
const server = await testServer.start(options);
await openUI(server, cancelPromise);
await cancelPromise;
} finally {
await testServer.stop();
sigintWatcher.disarm();
}
return sigintWatcher.hadSignal() ? "interrupted" : "passed";
}
function chunkToPayload(type, chunk) {
if (chunk instanceof Uint8Array)
return { type, buffer: chunk.toString("base64") };
return { type, text: chunk };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TestRunnerEvent,
TestServerDispatcher,
runTestServer,
runUIMode
});

30
node_modules/playwright/lib/runner/uiModeReporter.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var uiModeReporter_exports = {};
__export(uiModeReporter_exports, {
default: () => uiModeReporter_default
});
module.exports = __toCommonJS(uiModeReporter_exports);
var import_teleEmitter = require("../reporters/teleEmitter");
class UIModeReporter extends import_teleEmitter.TeleReporterEmitter {
constructor(options) {
super(options._send, { omitBuffers: true });
}
}
var uiModeReporter_default = UIModeReporter;

72
node_modules/playwright/lib/runner/vcs.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var vcs_exports = {};
__export(vcs_exports, {
detectChangedTestFiles: () => detectChangedTestFiles
});
module.exports = __toCommonJS(vcs_exports);
var import_child_process = __toESM(require("child_process"));
var import_path = __toESM(require("path"));
var import_compilationCache = require("../transform/compilationCache");
async function detectChangedTestFiles(baseCommit, configDir) {
function gitFileList(command) {
try {
return import_child_process.default.execSync(
`git ${command}`,
{ encoding: "utf-8", stdio: "pipe", cwd: configDir }
).split("\n").filter(Boolean);
} catch (_error) {
const error = _error;
const unknownRevision = error.output.some((line) => line?.includes("unknown revision"));
if (unknownRevision) {
const isShallowClone = import_child_process.default.execSync("git rev-parse --is-shallow-repository", { encoding: "utf-8", stdio: "pipe", cwd: configDir }).trim() === "true";
if (isShallowClone) {
throw new Error([
`The repository is a shallow clone and does not have '${baseCommit}' available locally.`,
`Note that GitHub Actions checkout is shallow by default: https://github.com/actions/checkout`
].join("\n"));
}
}
throw new Error([
`Cannot detect changed files for --only-changed mode:`,
`git ${command}`,
"",
...error.output
].join("\n"));
}
}
const untrackedFiles = gitFileList(`ls-files --others --exclude-standard`).map((file) => import_path.default.join(configDir, file));
const [gitRoot] = gitFileList("rev-parse --show-toplevel");
const trackedFilesWithChanges = gitFileList(`diff ${baseCommit} --name-only`).map((file) => import_path.default.join(gitRoot, file));
return new Set((0, import_compilationCache.affectedTestFiles)([...untrackedFiles, ...trackedFilesWithChanges]));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
detectChangedTestFiles
});

447
node_modules/playwright/lib/runner/watchMode.js generated vendored Normal file
View File

@@ -0,0 +1,447 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var watchMode_exports = {};
__export(watchMode_exports, {
runWatchModeLoop: () => runWatchModeLoop
});
module.exports = __toCommonJS(watchMode_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_readline = __toESM(require("readline"));
var import_stream = require("stream");
var import_playwrightServer = require("playwright-core/lib/remote/playwrightServer");
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_base = require("../reporters/base");
var import_utilsBundle = require("../utilsBundle");
var import_testServer = require("./testServer");
var import_teleSuiteUpdater = require("../isomorphic/teleSuiteUpdater");
var import_testServerConnection = require("../isomorphic/testServerConnection");
var import_util = require("../util");
var import_babelBundle = require("../transform/babelBundle");
class InMemoryTransport extends import_stream.EventEmitter {
constructor(send) {
super();
this._send = send;
}
close() {
this.emit("close");
}
onclose(listener) {
this.on("close", listener);
}
onerror(listener) {
}
onmessage(listener) {
this.on("message", listener);
}
onopen(listener) {
this.on("open", listener);
}
send(data) {
this._send(data);
}
}
async function runWatchModeLoop(configLocation, initialOptions) {
const options = { ...initialOptions };
let bufferMode = false;
const testServerDispatcher = new import_testServer.TestServerDispatcher(configLocation, {});
const transport = new InMemoryTransport(
async (data) => {
const { id, method, params } = JSON.parse(data);
try {
const result2 = await testServerDispatcher.transport.dispatch(method, params);
transport.emit("message", JSON.stringify({ id, result: result2 }));
} catch (e) {
transport.emit("message", JSON.stringify({ id, error: String(e) }));
}
}
);
testServerDispatcher.transport.sendEvent = (method, params) => {
transport.emit("message", JSON.stringify({ method, params }));
};
const testServerConnection = new import_testServerConnection.TestServerConnection(transport);
transport.emit("open");
const teleSuiteUpdater = new import_teleSuiteUpdater.TeleSuiteUpdater({ pathSeparator: import_path.default.sep, onUpdate() {
} });
const dirtyTestFiles = /* @__PURE__ */ new Set();
const dirtyTestIds = /* @__PURE__ */ new Set();
let onDirtyTests = new import_utils.ManualPromise();
let queue = Promise.resolve();
const changedFiles = /* @__PURE__ */ new Set();
testServerConnection.onTestFilesChanged(({ testFiles }) => {
testFiles.forEach((file) => changedFiles.add(file));
queue = queue.then(async () => {
if (changedFiles.size === 0)
return;
const { report: report2 } = await testServerConnection.listTests({ locations: options.files, projects: options.projects, grep: options.grep });
teleSuiteUpdater.processListReport(report2);
for (const test of teleSuiteUpdater.rootSuite.allTests()) {
if (changedFiles.has(test.location.file)) {
dirtyTestFiles.add(test.location.file);
dirtyTestIds.add(test.id);
}
}
changedFiles.clear();
if (dirtyTestIds.size > 0) {
onDirtyTests.resolve("changed");
onDirtyTests = new import_utils.ManualPromise();
}
});
});
testServerConnection.onReport((report2) => teleSuiteUpdater.processTestReportEvent(report2));
testServerConnection.onRecoverFromStepError(({ stepId, message, location }) => {
process.stdout.write(`
Test error occurred.
`);
process.stdout.write("\n" + createErrorCodeframe(message, location) + "\n");
process.stdout.write(`
${import_utils2.colors.dim("Try recovering from the error. Press")} ${import_utils2.colors.bold("c")} ${import_utils2.colors.dim("to continue or")} ${import_utils2.colors.bold("t")} ${import_utils2.colors.dim("to throw the error")}
`);
readKeyPress((text) => {
if (text === "c") {
process.stdout.write(`
${import_utils2.colors.dim("Continuing after recovery...")}
`);
testServerConnection.resumeAfterStepError({ stepId, status: "recovered", value: void 0 }).catch(() => {
});
} else if (text === "t") {
process.stdout.write(`
${import_utils2.colors.dim("Throwing error...")}
`);
testServerConnection.resumeAfterStepError({ stepId, status: "failed" }).catch(() => {
});
}
return text;
});
});
await testServerConnection.initialize({
interceptStdio: false,
watchTestDirs: true,
populateDependenciesOnList: true,
recoverFromStepErrors: !process.env.PWTEST_RECOVERY_DISABLED
});
await testServerConnection.runGlobalSetup({});
const { report } = await testServerConnection.listTests({});
teleSuiteUpdater.processListReport(report);
const projectNames = teleSuiteUpdater.rootSuite.suites.map((s) => s.title);
let lastRun = { type: "regular" };
let result = "passed";
while (true) {
if (bufferMode)
printBufferPrompt(dirtyTestFiles, teleSuiteUpdater.config.rootDir);
else
printPrompt();
const waitForCommand = readCommand();
const command = await Promise.race([
onDirtyTests,
waitForCommand.result
]);
if (command === "changed")
waitForCommand.dispose();
if (bufferMode && command === "changed")
continue;
const shouldRunChangedFiles = bufferMode ? command === "run" : command === "changed";
if (shouldRunChangedFiles) {
if (dirtyTestIds.size === 0)
continue;
const testIds = [...dirtyTestIds];
dirtyTestIds.clear();
dirtyTestFiles.clear();
await runTests(options, testServerConnection, { testIds, title: "files changed" });
lastRun = { type: "changed", dirtyTestIds: testIds };
continue;
}
if (command === "run") {
await runTests(options, testServerConnection);
lastRun = { type: "regular" };
continue;
}
if (command === "project") {
const { selectedProjects } = await import_utilsBundle.enquirer.prompt({
type: "multiselect",
name: "selectedProjects",
message: "Select projects",
choices: projectNames
}).catch(() => ({ selectedProjects: null }));
if (!selectedProjects)
continue;
options.projects = selectedProjects.length ? selectedProjects : void 0;
await runTests(options, testServerConnection);
lastRun = { type: "regular" };
continue;
}
if (command === "file") {
const { filePattern } = await import_utilsBundle.enquirer.prompt({
type: "text",
name: "filePattern",
message: "Input filename pattern (regex)"
}).catch(() => ({ filePattern: null }));
if (filePattern === null)
continue;
if (filePattern.trim())
options.files = filePattern.split(" ");
else
options.files = void 0;
await runTests(options, testServerConnection);
lastRun = { type: "regular" };
continue;
}
if (command === "grep") {
const { testPattern } = await import_utilsBundle.enquirer.prompt({
type: "text",
name: "testPattern",
message: "Input test name pattern (regex)"
}).catch(() => ({ testPattern: null }));
if (testPattern === null)
continue;
if (testPattern.trim())
options.grep = testPattern;
else
options.grep = void 0;
await runTests(options, testServerConnection);
lastRun = { type: "regular" };
continue;
}
if (command === "failed") {
const failedTestIds = teleSuiteUpdater.rootSuite.allTests().filter((t) => !t.ok()).map((t) => t.id);
await runTests({}, testServerConnection, { title: "running failed tests", testIds: failedTestIds });
lastRun = { type: "failed", failedTestIds };
continue;
}
if (command === "repeat") {
if (lastRun.type === "regular") {
await runTests(options, testServerConnection, { title: "re-running tests" });
continue;
} else if (lastRun.type === "changed") {
await runTests(options, testServerConnection, { title: "re-running tests", testIds: lastRun.dirtyTestIds });
} else if (lastRun.type === "failed") {
await runTests({}, testServerConnection, { title: "re-running tests", testIds: lastRun.failedTestIds });
}
continue;
}
if (command === "toggle-show-browser") {
await toggleShowBrowser();
continue;
}
if (command === "toggle-buffer-mode") {
bufferMode = !bufferMode;
continue;
}
if (command === "exit")
break;
if (command === "interrupted") {
result = "interrupted";
break;
}
}
const teardown = await testServerConnection.runGlobalTeardown({});
return result === "passed" ? teardown.status : result;
}
function readKeyPress(handler) {
const promise = new import_utils.ManualPromise();
const rl = import_readline.default.createInterface({ input: process.stdin, escapeCodeTimeout: 50 });
import_readline.default.emitKeypressEvents(process.stdin, rl);
if (process.stdin.isTTY)
process.stdin.setRawMode(true);
const listener = import_utils.eventsHelper.addEventListener(process.stdin, "keypress", (text, key) => {
const result = handler(text, key);
if (result)
promise.resolve(result);
});
const dispose = () => {
import_utils.eventsHelper.removeEventListeners([listener]);
rl.close();
if (process.stdin.isTTY)
process.stdin.setRawMode(false);
};
void promise.finally(dispose);
return { result: promise, dispose };
}
const isInterrupt = (text, key) => text === "" || text === "\x1B" || key && key.name === "escape" || key && key.ctrl && key.name === "c";
async function runTests(watchOptions, testServerConnection, options) {
printConfiguration(watchOptions, options?.title);
const waitForDone = readKeyPress((text, key) => {
if (isInterrupt(text, key)) {
testServerConnection.stopTestsNoReply({});
return "done";
}
});
await testServerConnection.runTests({
grep: watchOptions.grep,
testIds: options?.testIds,
locations: watchOptions?.files,
projects: watchOptions.projects,
connectWsEndpoint,
reuseContext: connectWsEndpoint ? true : void 0,
workers: connectWsEndpoint ? 1 : void 0,
headed: connectWsEndpoint ? true : void 0
}).finally(() => waitForDone.dispose());
}
function readCommand() {
return readKeyPress((text, key) => {
if (isInterrupt(text, key))
return "interrupted";
if (process.platform !== "win32" && key && key.ctrl && key.name === "z") {
process.kill(process.ppid, "SIGTSTP");
process.kill(process.pid, "SIGTSTP");
}
const name = key?.name;
if (name === "q")
return "exit";
if (name === "h") {
process.stdout.write(`${(0, import_base.separator)(import_base.terminalScreen)}
Run tests
${import_utils2.colors.bold("enter")} ${import_utils2.colors.dim("run tests")}
${import_utils2.colors.bold("f")} ${import_utils2.colors.dim("run failed tests")}
${import_utils2.colors.bold("r")} ${import_utils2.colors.dim("repeat last run")}
${import_utils2.colors.bold("q")} ${import_utils2.colors.dim("quit")}
Change settings
${import_utils2.colors.bold("c")} ${import_utils2.colors.dim("set project")}
${import_utils2.colors.bold("p")} ${import_utils2.colors.dim("set file filter")}
${import_utils2.colors.bold("t")} ${import_utils2.colors.dim("set title filter")}
${import_utils2.colors.bold("s")} ${import_utils2.colors.dim("toggle show & reuse the browser")}
${import_utils2.colors.bold("b")} ${import_utils2.colors.dim("toggle buffer mode")}
`);
return;
}
switch (name) {
case "return":
return "run";
case "r":
return "repeat";
case "c":
return "project";
case "p":
return "file";
case "t":
return "grep";
case "f":
return "failed";
case "s":
return "toggle-show-browser";
case "b":
return "toggle-buffer-mode";
}
});
}
let showBrowserServer;
let connectWsEndpoint = void 0;
let seq = 1;
function printConfiguration(options, title) {
const packageManagerCommand = (0, import_utils.getPackageManagerExecCommand)();
const tokens = [];
tokens.push(`${packageManagerCommand} playwright test`);
if (options.projects)
tokens.push(...options.projects.map((p) => import_utils2.colors.blue(`--project ${p}`)));
if (options.grep)
tokens.push(import_utils2.colors.red(`--grep ${options.grep}`));
if (options.files)
tokens.push(...options.files.map((a) => import_utils2.colors.bold(a)));
if (title)
tokens.push(import_utils2.colors.dim(`(${title})`));
tokens.push(import_utils2.colors.dim(`#${seq++}`));
const lines = [];
const sep = (0, import_base.separator)(import_base.terminalScreen);
lines.push("\x1Bc" + sep);
lines.push(`${tokens.join(" ")}`);
lines.push(`${import_utils2.colors.dim("Show & reuse browser:")} ${import_utils2.colors.bold(showBrowserServer ? "on" : "off")}`);
process.stdout.write(lines.join("\n"));
}
function printBufferPrompt(dirtyTestFiles, rootDir) {
const sep = (0, import_base.separator)(import_base.terminalScreen);
process.stdout.write("\x1Bc");
process.stdout.write(`${sep}
`);
if (dirtyTestFiles.size === 0) {
process.stdout.write(`${import_utils2.colors.dim("Waiting for file changes. Press")} ${import_utils2.colors.bold("q")} ${import_utils2.colors.dim("to quit or")} ${import_utils2.colors.bold("h")} ${import_utils2.colors.dim("for more options.")}
`);
return;
}
process.stdout.write(`${import_utils2.colors.dim(`${dirtyTestFiles.size} test ${dirtyTestFiles.size === 1 ? "file" : "files"} changed:`)}
`);
for (const file of dirtyTestFiles)
process.stdout.write(` \xB7 ${import_path.default.relative(rootDir, file)}
`);
process.stdout.write(`
${import_utils2.colors.dim(`Press`)} ${import_utils2.colors.bold("enter")} ${import_utils2.colors.dim("to run")}, ${import_utils2.colors.bold("q")} ${import_utils2.colors.dim("to quit or")} ${import_utils2.colors.bold("h")} ${import_utils2.colors.dim("for more options.")}
`);
}
function printPrompt() {
const sep = (0, import_base.separator)(import_base.terminalScreen);
process.stdout.write(`
${sep}
${import_utils2.colors.dim("Waiting for file changes. Press")} ${import_utils2.colors.bold("enter")} ${import_utils2.colors.dim("to run tests")}, ${import_utils2.colors.bold("q")} ${import_utils2.colors.dim("to quit or")} ${import_utils2.colors.bold("h")} ${import_utils2.colors.dim("for more options.")}
`);
}
async function toggleShowBrowser() {
if (!showBrowserServer) {
showBrowserServer = new import_playwrightServer.PlaywrightServer({ mode: "extension", path: "/" + (0, import_utils.createGuid)(), maxConnections: 1 });
connectWsEndpoint = await showBrowserServer.listen();
process.stdout.write(`${import_utils2.colors.dim("Show & reuse browser:")} ${import_utils2.colors.bold("on")}
`);
} else {
await showBrowserServer?.close();
showBrowserServer = void 0;
connectWsEndpoint = void 0;
process.stdout.write(`${import_utils2.colors.dim("Show & reuse browser:")} ${import_utils2.colors.bold("off")}
`);
}
}
function createErrorCodeframe(message, location) {
let source;
try {
source = import_fs.default.readFileSync(location.file, "utf-8") + "\n//";
} catch (e) {
return;
}
return (0, import_babelBundle.codeFrameColumns)(
source,
{
start: {
line: location.line,
column: location.column
}
},
{
highlightCode: true,
linesAbove: 5,
linesBelow: 5,
message: (0, import_util.stripAnsiEscapes)(message).split("\n")[0] || void 0
}
);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
runWatchModeLoop
});

97
node_modules/playwright/lib/runner/workerHost.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var workerHost_exports = {};
__export(workerHost_exports, {
WorkerHost: () => WorkerHost
});
module.exports = __toCommonJS(workerHost_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_processHost = require("./processHost");
var import_ipc = require("../common/ipc");
var import_folders = require("../isomorphic/folders");
let lastWorkerIndex = 0;
class WorkerHost extends import_processHost.ProcessHost {
constructor(testGroup, parallelIndex, config, recoverFromStepErrors, extraEnv, outputDir) {
const workerIndex = lastWorkerIndex++;
super(require.resolve("../worker/workerMain.js"), `worker-${workerIndex}`, {
...extraEnv,
FORCE_COLOR: "1",
DEBUG_COLORS: process.env.DEBUG_COLORS === void 0 ? "1" : process.env.DEBUG_COLORS
});
this._didFail = false;
this.workerIndex = workerIndex;
this.parallelIndex = parallelIndex;
this._hash = testGroup.workerHash;
this._params = {
workerIndex: this.workerIndex,
parallelIndex,
repeatEachIndex: testGroup.repeatEachIndex,
projectId: testGroup.projectId,
config,
artifactsDir: import_path.default.join(outputDir, (0, import_folders.artifactsFolderName)(workerIndex)),
recoverFromStepErrors
};
}
async start() {
await import_fs.default.promises.mkdir(this._params.artifactsDir, { recursive: true });
return await this.startRunner(this._params, {
onStdOut: (chunk) => this.emit("stdOut", (0, import_ipc.stdioChunkToParams)(chunk)),
onStdErr: (chunk) => this.emit("stdErr", (0, import_ipc.stdioChunkToParams)(chunk))
});
}
async onExit() {
await (0, import_utils.removeFolders)([this._params.artifactsDir]);
}
async stop(didFail) {
if (didFail)
this._didFail = true;
await super.stop();
}
runTestGroup(runPayload) {
this.sendMessageNoReply({ method: "runTestGroup", params: runPayload });
}
resumeAfterStepError(result) {
this.sendMessageNoReply({ method: "resumeAfterStepError", params: result });
}
hash() {
return this._hash;
}
projectId() {
return this._params.projectId;
}
didFail() {
return this._didFail;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
WorkerHost
});

62
node_modules/playwright/lib/third_party/pirates.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var pirates_exports = {};
__export(pirates_exports, {
addHook: () => addHook
});
module.exports = __toCommonJS(pirates_exports);
var import_module = __toESM(require("module"));
var import_path = __toESM(require("path"));
function addHook(transformHook, shouldTransform, extensions) {
const extensionsToOverwrite = extensions.filter((e) => e !== ".cjs");
const allSupportedExtensions = new Set(extensions);
const loaders = import_module.default._extensions;
const jsLoader = loaders[".js"];
for (const extension of extensionsToOverwrite) {
let newLoader2 = function(mod, filename, ...loaderArgs) {
if (allSupportedExtensions.has(import_path.default.extname(filename)) && shouldTransform(filename)) {
let newCompile2 = function(code, file, ...ignoredArgs) {
mod._compile = oldCompile;
return oldCompile.call(this, transformHook(code, filename), file);
};
var newCompile = newCompile2;
const oldCompile = mod._compile;
mod._compile = newCompile2;
}
originalLoader.call(this, mod, filename, ...loaderArgs);
};
var newLoader = newLoader2;
const originalLoader = loaders[extension] || jsLoader;
loaders[extension] = newLoader2;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
addHook
});

View File

@@ -0,0 +1,103 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var tsconfig_loader_exports = {};
__export(tsconfig_loader_exports, {
loadTsConfig: () => loadTsConfig
});
module.exports = __toCommonJS(tsconfig_loader_exports);
var import_path = __toESM(require("path"));
var import_fs = __toESM(require("fs"));
var import_utilsBundle = require("../utilsBundle");
function loadTsConfig(configPath) {
try {
const references = [];
const config = innerLoadTsConfig(configPath, references);
return [config, ...references];
} catch (e) {
throw new Error(`Failed to load tsconfig file at ${configPath}:
${e.message}`);
}
}
function resolveConfigFile(baseConfigFile, referencedConfigFile) {
if (!referencedConfigFile.endsWith(".json"))
referencedConfigFile += ".json";
const currentDir = import_path.default.dirname(baseConfigFile);
let resolvedConfigFile = import_path.default.resolve(currentDir, referencedConfigFile);
if (referencedConfigFile.includes("/") && referencedConfigFile.includes(".") && !import_fs.default.existsSync(resolvedConfigFile))
resolvedConfigFile = import_path.default.join(currentDir, "node_modules", referencedConfigFile);
return resolvedConfigFile;
}
function innerLoadTsConfig(configFilePath, references, visited = /* @__PURE__ */ new Map()) {
if (visited.has(configFilePath))
return visited.get(configFilePath);
let result = {
tsConfigPath: configFilePath
};
visited.set(configFilePath, result);
if (!import_fs.default.existsSync(configFilePath))
return result;
const configString = import_fs.default.readFileSync(configFilePath, "utf-8");
const cleanedJson = StripBom(configString);
const parsedConfig = import_utilsBundle.json5.parse(cleanedJson);
const extendsArray = Array.isArray(parsedConfig.extends) ? parsedConfig.extends : parsedConfig.extends ? [parsedConfig.extends] : [];
for (const extendedConfig of extendsArray) {
const extendedConfigPath = resolveConfigFile(configFilePath, extendedConfig);
const base = innerLoadTsConfig(extendedConfigPath, references, visited);
Object.assign(result, base, { tsConfigPath: configFilePath });
}
if (parsedConfig.compilerOptions?.allowJs !== void 0)
result.allowJs = parsedConfig.compilerOptions.allowJs;
if (parsedConfig.compilerOptions?.paths !== void 0) {
result.paths = {
mapping: parsedConfig.compilerOptions.paths,
pathsBasePath: import_path.default.dirname(configFilePath)
};
}
if (parsedConfig.compilerOptions?.baseUrl !== void 0) {
result.absoluteBaseUrl = import_path.default.resolve(import_path.default.dirname(configFilePath), parsedConfig.compilerOptions.baseUrl);
}
for (const ref of parsedConfig.references || [])
references.push(innerLoadTsConfig(resolveConfigFile(configFilePath, ref.path), references, visited));
if (import_path.default.basename(configFilePath) === "jsconfig.json" && result.allowJs === void 0)
result.allowJs = true;
return result;
}
function StripBom(string) {
if (typeof string !== "string") {
throw new TypeError(`Expected a string, got ${typeof string}`);
}
if (string.charCodeAt(0) === 65279) {
return string.slice(1);
}
return string;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
loadTsConfig
});

43
node_modules/playwright/lib/transform/babelBundle.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var babelBundle_exports = {};
__export(babelBundle_exports, {
babelParse: () => babelParse,
babelTransform: () => babelTransform,
codeFrameColumns: () => codeFrameColumns,
declare: () => declare,
traverse: () => traverse,
types: () => types
});
module.exports = __toCommonJS(babelBundle_exports);
const codeFrameColumns = require("./babelBundleImpl").codeFrameColumns;
const declare = require("./babelBundleImpl").declare;
const types = require("./babelBundleImpl").types;
const traverse = require("./babelBundleImpl").traverse;
const babelTransform = require("./babelBundleImpl").babelTransform;
const babelParse = require("./babelBundleImpl").babelParse;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
babelParse,
babelTransform,
codeFrameColumns,
declare,
traverse,
types
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,255 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var compilationCache_exports = {};
__export(compilationCache_exports, {
addToCompilationCache: () => addToCompilationCache,
affectedTestFiles: () => affectedTestFiles,
belongsToNodeModules: () => belongsToNodeModules,
cacheDir: () => cacheDir,
collectAffectedTestFiles: () => collectAffectedTestFiles,
currentFileDepsCollector: () => currentFileDepsCollector,
dependenciesForTestFile: () => dependenciesForTestFile,
fileDependenciesForTest: () => fileDependenciesForTest,
getFromCompilationCache: () => getFromCompilationCache,
getUserData: () => getUserData,
installSourceMapSupport: () => installSourceMapSupport,
internalDependenciesForTestFile: () => internalDependenciesForTestFile,
serializeCompilationCache: () => serializeCompilationCache,
setExternalDependencies: () => setExternalDependencies,
startCollectingFileDeps: () => startCollectingFileDeps,
stopCollectingFileDeps: () => stopCollectingFileDeps
});
module.exports = __toCommonJS(compilationCache_exports);
var import_fs = __toESM(require("fs"));
var import_os = __toESM(require("os"));
var import_path = __toESM(require("path"));
var import_globals = require("../common/globals");
var import_utilsBundle = require("../utilsBundle");
const cacheDir = process.env.PWTEST_CACHE_DIR || (() => {
if (process.platform === "win32")
return import_path.default.join(import_os.default.tmpdir(), `playwright-transform-cache`);
return import_path.default.join(import_os.default.tmpdir(), `playwright-transform-cache-` + process.geteuid?.());
})();
const sourceMaps = /* @__PURE__ */ new Map();
const memoryCache = /* @__PURE__ */ new Map();
const fileDependencies = /* @__PURE__ */ new Map();
const externalDependencies = /* @__PURE__ */ new Map();
function installSourceMapSupport() {
Error.stackTraceLimit = 200;
import_utilsBundle.sourceMapSupport.install({
environment: "node",
handleUncaughtExceptions: false,
retrieveSourceMap(source) {
if (!sourceMaps.has(source))
return null;
const sourceMapPath = sourceMaps.get(source);
try {
return {
map: JSON.parse(import_fs.default.readFileSync(sourceMapPath, "utf-8")),
url: source
};
} catch {
return null;
}
}
});
}
function _innerAddToCompilationCacheAndSerialize(filename, entry) {
sourceMaps.set(entry.moduleUrl || filename, entry.sourceMapPath);
memoryCache.set(filename, entry);
return {
sourceMaps: [[entry.moduleUrl || filename, entry.sourceMapPath]],
memoryCache: [[filename, entry]],
fileDependencies: [],
externalDependencies: []
};
}
function getFromCompilationCache(filename, hash, moduleUrl) {
const cache = memoryCache.get(filename);
if (cache?.codePath) {
try {
return { cachedCode: import_fs.default.readFileSync(cache.codePath, "utf-8") };
} catch {
}
}
const cachePath = calculateCachePath(filename, hash);
const codePath = cachePath + ".js";
const sourceMapPath = cachePath + ".map";
const dataPath = cachePath + ".data";
try {
const cachedCode = import_fs.default.readFileSync(codePath, "utf8");
const serializedCache = _innerAddToCompilationCacheAndSerialize(filename, { codePath, sourceMapPath, dataPath, moduleUrl });
return { cachedCode, serializedCache };
} catch {
}
return {
addToCache: (code, map, data) => {
if ((0, import_globals.isWorkerProcess)())
return {};
import_fs.default.mkdirSync(import_path.default.dirname(cachePath), { recursive: true });
if (map)
import_fs.default.writeFileSync(sourceMapPath, JSON.stringify(map), "utf8");
if (data.size)
import_fs.default.writeFileSync(dataPath, JSON.stringify(Object.fromEntries(data.entries()), void 0, 2), "utf8");
import_fs.default.writeFileSync(codePath, code, "utf8");
const serializedCache = _innerAddToCompilationCacheAndSerialize(filename, { codePath, sourceMapPath, dataPath, moduleUrl });
return { serializedCache };
}
};
}
function serializeCompilationCache() {
return {
sourceMaps: [...sourceMaps.entries()],
memoryCache: [...memoryCache.entries()],
fileDependencies: [...fileDependencies.entries()].map(([filename, deps]) => [filename, [...deps]]),
externalDependencies: [...externalDependencies.entries()].map(([filename, deps]) => [filename, [...deps]])
};
}
function addToCompilationCache(payload) {
for (const entry of payload.sourceMaps)
sourceMaps.set(entry[0], entry[1]);
for (const entry of payload.memoryCache)
memoryCache.set(entry[0], entry[1]);
for (const entry of payload.fileDependencies) {
const existing = fileDependencies.get(entry[0]) || [];
fileDependencies.set(entry[0], /* @__PURE__ */ new Set([...entry[1], ...existing]));
}
for (const entry of payload.externalDependencies) {
const existing = externalDependencies.get(entry[0]) || [];
externalDependencies.set(entry[0], /* @__PURE__ */ new Set([...entry[1], ...existing]));
}
}
function calculateCachePath(filePath, hash) {
const fileName = import_path.default.basename(filePath, import_path.default.extname(filePath)).replace(/\W/g, "") + "_" + hash;
return import_path.default.join(cacheDir, hash[0] + hash[1], fileName);
}
let depsCollector;
function startCollectingFileDeps() {
depsCollector = /* @__PURE__ */ new Set();
}
function stopCollectingFileDeps(filename) {
if (!depsCollector)
return;
depsCollector.delete(filename);
for (const dep of depsCollector) {
if (belongsToNodeModules(dep))
depsCollector.delete(dep);
}
fileDependencies.set(filename, depsCollector);
depsCollector = void 0;
}
function currentFileDepsCollector() {
return depsCollector;
}
function setExternalDependencies(filename, deps) {
const depsSet = new Set(deps.filter((dep) => !belongsToNodeModules(dep) && dep !== filename));
externalDependencies.set(filename, depsSet);
}
function fileDependenciesForTest() {
return fileDependencies;
}
function collectAffectedTestFiles(changedFile, testFileCollector) {
const isTestFile = (file) => fileDependencies.has(file);
if (isTestFile(changedFile))
testFileCollector.add(changedFile);
for (const [testFile, deps] of fileDependencies) {
if (deps.has(changedFile))
testFileCollector.add(testFile);
}
for (const [importingFile, depsOfImportingFile] of externalDependencies) {
if (depsOfImportingFile.has(changedFile)) {
if (isTestFile(importingFile))
testFileCollector.add(importingFile);
for (const [testFile, depsOfTestFile] of fileDependencies) {
if (depsOfTestFile.has(importingFile))
testFileCollector.add(testFile);
}
}
}
}
function affectedTestFiles(changes) {
const result = /* @__PURE__ */ new Set();
for (const change of changes)
collectAffectedTestFiles(change, result);
return [...result];
}
function internalDependenciesForTestFile(filename) {
return fileDependencies.get(filename);
}
function dependenciesForTestFile(filename) {
const result = /* @__PURE__ */ new Set();
for (const testDependency of fileDependencies.get(filename) || []) {
result.add(testDependency);
for (const externalDependency of externalDependencies.get(testDependency) || [])
result.add(externalDependency);
}
for (const dep of externalDependencies.get(filename) || [])
result.add(dep);
return result;
}
const kPlaywrightInternalPrefix = import_path.default.resolve(__dirname, "../../../playwright");
function belongsToNodeModules(file) {
if (file.includes(`${import_path.default.sep}node_modules${import_path.default.sep}`))
return true;
if (file.startsWith(kPlaywrightInternalPrefix) && (file.endsWith(".js") || file.endsWith(".mjs")))
return true;
return false;
}
async function getUserData(pluginName) {
const result = /* @__PURE__ */ new Map();
for (const [fileName, cache] of memoryCache) {
if (!cache.dataPath)
continue;
if (!import_fs.default.existsSync(cache.dataPath))
continue;
const data = JSON.parse(await import_fs.default.promises.readFile(cache.dataPath, "utf8"));
if (data[pluginName])
result.set(fileName, data[pluginName]);
}
return result;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
addToCompilationCache,
affectedTestFiles,
belongsToNodeModules,
cacheDir,
collectAffectedTestFiles,
currentFileDepsCollector,
dependenciesForTestFile,
fileDependenciesForTest,
getFromCompilationCache,
getUserData,
installSourceMapSupport,
internalDependenciesForTestFile,
serializeCompilationCache,
setExternalDependencies,
startCollectingFileDeps,
stopCollectingFileDeps
});

104
node_modules/playwright/lib/transform/esmLoader.js generated vendored Normal file
View File

@@ -0,0 +1,104 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var import_fs = __toESM(require("fs"));
var import_url = __toESM(require("url"));
var import_compilationCache = require("./compilationCache");
var import_portTransport = require("./portTransport");
var import_transform = require("./transform");
var import_util = require("../util");
async function resolve(specifier, context, defaultResolve) {
if (context.parentURL && context.parentURL.startsWith("file://")) {
const filename = import_url.default.fileURLToPath(context.parentURL);
const resolved = (0, import_transform.resolveHook)(filename, specifier);
if (resolved !== void 0)
specifier = import_url.default.pathToFileURL(resolved).toString();
}
const result = await defaultResolve(specifier, context, defaultResolve);
if (result?.url && result.url.startsWith("file://"))
(0, import_compilationCache.currentFileDepsCollector)()?.add(import_url.default.fileURLToPath(result.url));
return result;
}
const kSupportedFormats = /* @__PURE__ */ new Map([
["commonjs", "commonjs"],
["module", "module"],
["commonjs-typescript", "commonjs"],
["module-typescript", "module"],
[null, null],
[void 0, void 0]
]);
async function load(moduleUrl, context, defaultLoad) {
if (!kSupportedFormats.has(context.format))
return defaultLoad(moduleUrl, context, defaultLoad);
if (!moduleUrl.startsWith("file://"))
return defaultLoad(moduleUrl, context, defaultLoad);
const filename = import_url.default.fileURLToPath(moduleUrl);
if (!(0, import_transform.shouldTransform)(filename))
return defaultLoad(moduleUrl, context, defaultLoad);
const code = import_fs.default.readFileSync(filename, "utf-8");
const transformed = (0, import_transform.transformHook)(code, filename, moduleUrl);
if (transformed.serializedCache) {
if (legacyWaitForSourceMaps)
await transport?.send("pushToCompilationCache", { cache: transformed.serializedCache });
else
transport?.post("pushToCompilationCache", { cache: transformed.serializedCache });
}
return {
format: kSupportedFormats.get(context.format) || ((0, import_util.fileIsModule)(filename) ? "module" : "commonjs"),
source: transformed.code,
shortCircuit: true
};
}
let transport;
let legacyWaitForSourceMaps = false;
function initialize(data) {
transport = createTransport(data?.port);
legacyWaitForSourceMaps = !!process.env.PLAYWRIGHT_WAIT_FOR_SOURCE_MAPS;
}
function createTransport(port) {
return new import_portTransport.PortTransport(port, async (method, params) => {
if (method === "setSingleTSConfig") {
(0, import_transform.setSingleTSConfig)(params.tsconfig);
return;
}
if (method === "setTransformConfig") {
(0, import_transform.setTransformConfig)(params.config);
return;
}
if (method === "addToCompilationCache") {
(0, import_compilationCache.addToCompilationCache)(params.cache);
return;
}
if (method === "getCompilationCache")
return { cache: (0, import_compilationCache.serializeCompilationCache)() };
if (method === "startCollectingFileDeps") {
(0, import_compilationCache.startCollectingFileDeps)();
return;
}
if (method === "stopCollectingFileDeps") {
(0, import_compilationCache.stopCollectingFileDeps)(params.file);
return;
}
});
}
module.exports = { initialize, load, resolve };

67
node_modules/playwright/lib/transform/portTransport.js generated vendored Normal file
View File

@@ -0,0 +1,67 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var portTransport_exports = {};
__export(portTransport_exports, {
PortTransport: () => PortTransport
});
module.exports = __toCommonJS(portTransport_exports);
class PortTransport {
constructor(port, handler) {
this._lastId = 0;
this._callbacks = /* @__PURE__ */ new Map();
this._port = port;
port.addEventListener("message", async (event) => {
const message = event.data;
const { id, ackId, method, params, result } = message;
if (ackId) {
const callback = this._callbacks.get(ackId);
this._callbacks.delete(ackId);
this._resetRef();
callback?.(result);
return;
}
const handlerResult = await handler(method, params);
if (id)
this._port.postMessage({ ackId: id, result: handlerResult });
});
this._resetRef();
}
post(method, params) {
this._port.postMessage({ method, params });
}
async send(method, params) {
return await new Promise((f) => {
const id = ++this._lastId;
this._callbacks.set(id, f);
this._resetRef();
this._port.postMessage({ id, method, params });
});
}
_resetRef() {
if (this._callbacks.size) {
this._port.ref();
} else {
this._port.unref();
}
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
PortTransport
});

293
node_modules/playwright/lib/transform/transform.js generated vendored Normal file
View File

@@ -0,0 +1,293 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var transform_exports = {};
__export(transform_exports, {
requireOrImport: () => requireOrImport,
resolveHook: () => resolveHook,
setSingleTSConfig: () => setSingleTSConfig,
setTransformConfig: () => setTransformConfig,
setTransformData: () => setTransformData,
shouldTransform: () => shouldTransform,
singleTSConfig: () => singleTSConfig,
transformConfig: () => transformConfig,
transformHook: () => transformHook,
wrapFunctionWithLocation: () => wrapFunctionWithLocation
});
module.exports = __toCommonJS(transform_exports);
var import_fs = __toESM(require("fs"));
var import_module = __toESM(require("module"));
var import_path = __toESM(require("path"));
var import_url = __toESM(require("url"));
var import_crypto = __toESM(require("crypto"));
var import_tsconfig_loader = require("../third_party/tsconfig-loader");
var import_util = require("../util");
var import_utilsBundle = require("../utilsBundle");
var import_compilationCache = require("./compilationCache");
var import_pirates = require("../third_party/pirates");
const version = require("../../package.json").version;
const cachedTSConfigs = /* @__PURE__ */ new Map();
let _transformConfig = {
babelPlugins: [],
external: []
};
let _externalMatcher = () => false;
function setTransformConfig(config) {
_transformConfig = config;
_externalMatcher = (0, import_util.createFileMatcher)(_transformConfig.external);
}
function transformConfig() {
return _transformConfig;
}
let _singleTSConfigPath;
let _singleTSConfig;
function setSingleTSConfig(value) {
_singleTSConfigPath = value;
}
function singleTSConfig() {
return _singleTSConfigPath;
}
function validateTsConfig(tsconfig) {
const pathsBase = tsconfig.absoluteBaseUrl ?? tsconfig.paths?.pathsBasePath;
const pathsFallback = tsconfig.absoluteBaseUrl ? [{ key: "*", values: ["*"] }] : [];
return {
allowJs: !!tsconfig.allowJs,
pathsBase,
paths: Object.entries(tsconfig.paths?.mapping || {}).map(([key, values]) => ({ key, values })).concat(pathsFallback)
};
}
function loadAndValidateTsconfigsForFile(file2) {
if (_singleTSConfigPath && !_singleTSConfig)
_singleTSConfig = (0, import_tsconfig_loader.loadTsConfig)(_singleTSConfigPath).map(validateTsConfig);
if (_singleTSConfig)
return _singleTSConfig;
return loadAndValidateTsconfigsForFolder(import_path.default.dirname(file2));
}
function loadAndValidateTsconfigsForFolder(folder) {
const foldersWithConfig = [];
let currentFolder = import_path.default.resolve(folder);
let result2;
while (true) {
const cached = cachedTSConfigs.get(currentFolder);
if (cached) {
result2 = cached;
break;
}
foldersWithConfig.push(currentFolder);
for (const name of ["tsconfig.json", "jsconfig.json"]) {
const configPath = import_path.default.join(currentFolder, name);
if (import_fs.default.existsSync(configPath)) {
const loaded = (0, import_tsconfig_loader.loadTsConfig)(configPath);
result2 = loaded.map(validateTsConfig);
break;
}
}
if (result2)
break;
const parentFolder = import_path.default.resolve(currentFolder, "../");
if (currentFolder === parentFolder)
break;
currentFolder = parentFolder;
}
result2 = result2 || [];
for (const folder2 of foldersWithConfig)
cachedTSConfigs.set(folder2, result2);
return result2;
}
const pathSeparator = process.platform === "win32" ? ";" : ":";
const builtins = new Set(import_module.default.builtinModules);
function resolveHook(filename, specifier) {
if (specifier.startsWith("node:") || builtins.has(specifier))
return;
if (!shouldTransform(filename))
return;
if (isRelativeSpecifier(specifier))
return (0, import_util.resolveImportSpecifierAfterMapping)(import_path.default.resolve(import_path.default.dirname(filename), specifier), false);
const isTypeScript = filename.endsWith(".ts") || filename.endsWith(".tsx");
const tsconfigs = loadAndValidateTsconfigsForFile(filename);
for (const tsconfig of tsconfigs) {
if (!isTypeScript && !tsconfig.allowJs)
continue;
let longestPrefixLength = -1;
let pathMatchedByLongestPrefix;
for (const { key, values } of tsconfig.paths) {
let matchedPartOfSpecifier = specifier;
const [keyPrefix, keySuffix] = key.split("*");
if (key.includes("*")) {
if (keyPrefix) {
if (!specifier.startsWith(keyPrefix))
continue;
matchedPartOfSpecifier = matchedPartOfSpecifier.substring(keyPrefix.length, matchedPartOfSpecifier.length);
}
if (keySuffix) {
if (!specifier.endsWith(keySuffix))
continue;
matchedPartOfSpecifier = matchedPartOfSpecifier.substring(0, matchedPartOfSpecifier.length - keySuffix.length);
}
} else {
if (specifier !== key)
continue;
matchedPartOfSpecifier = specifier;
}
if (keyPrefix.length <= longestPrefixLength)
continue;
for (const value of values) {
let candidate = value;
if (value.includes("*"))
candidate = candidate.replace("*", matchedPartOfSpecifier);
candidate = import_path.default.resolve(tsconfig.pathsBase, candidate);
const existing = (0, import_util.resolveImportSpecifierAfterMapping)(candidate, true);
if (existing) {
longestPrefixLength = keyPrefix.length;
pathMatchedByLongestPrefix = existing;
}
}
}
if (pathMatchedByLongestPrefix)
return pathMatchedByLongestPrefix;
}
if (import_path.default.isAbsolute(specifier)) {
return (0, import_util.resolveImportSpecifierAfterMapping)(specifier, false);
}
}
function shouldTransform(filename) {
if (_externalMatcher(filename))
return false;
return !(0, import_compilationCache.belongsToNodeModules)(filename);
}
let transformData;
function setTransformData(pluginName, value) {
transformData.set(pluginName, value);
}
function transformHook(originalCode, filename, moduleUrl) {
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));
const pluginsPrologue = _transformConfig.babelPlugins;
const pluginsEpilogue = hasPreprocessor ? [[process.env.PW_TEST_SOURCE_TRANSFORM]] : [];
const hash = calculateHash(originalCode, filename, !!moduleUrl, pluginsPrologue, pluginsEpilogue);
const { cachedCode, addToCache, serializedCache } = (0, import_compilationCache.getFromCompilationCache)(filename, hash, moduleUrl);
if (cachedCode !== void 0)
return { code: cachedCode, serializedCache };
process.env.BROWSERSLIST_IGNORE_OLD_DATA = "true";
const { babelTransform } = require("./babelBundle");
transformData = /* @__PURE__ */ new Map();
const babelResult = babelTransform(originalCode, filename, !!moduleUrl, pluginsPrologue, pluginsEpilogue);
if (!babelResult?.code)
return { code: originalCode, serializedCache };
const { code, map } = babelResult;
const added = addToCache(code, map, transformData);
return { code, serializedCache: added.serializedCache };
}
function calculateHash(content, filePath, isModule2, pluginsPrologue, pluginsEpilogue) {
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");
return hash;
}
async function requireOrImport(file) {
installTransformIfNeeded();
const isModule = (0, import_util.fileIsModule)(file);
const esmImport = () => eval(`import(${JSON.stringify(import_url.default.pathToFileURL(file))})`);
if (isModule) {
return await esmImport().finally(async () => {
await new Promise((resolve) => setTimeout(resolve, 0));
});
}
const result = require(file);
const depsCollector = (0, import_compilationCache.currentFileDepsCollector)();
if (depsCollector) {
const module2 = require.cache[file];
if (module2)
collectCJSDependencies(module2, depsCollector);
}
return result;
}
let transformInstalled = false;
function installTransformIfNeeded() {
if (transformInstalled)
return;
transformInstalled = true;
(0, import_compilationCache.installSourceMapSupport)();
const originalResolveFilename = import_module.default._resolveFilename;
function resolveFilename(specifier, parent, ...rest) {
if (parent) {
const resolved = resolveHook(parent.filename, specifier);
if (resolved !== void 0)
specifier = resolved;
}
return originalResolveFilename.call(this, specifier, parent, ...rest);
}
import_module.default._resolveFilename = resolveFilename;
(0, import_pirates.addHook)((code, filename) => {
return transformHook(code, filename).code;
}, shouldTransform, [".ts", ".tsx", ".js", ".jsx", ".mjs", ".mts", ".cjs", ".cts"]);
}
const collectCJSDependencies = (module2, dependencies) => {
module2.children.forEach((child) => {
if (!(0, import_compilationCache.belongsToNodeModules)(child.filename) && !dependencies.has(child.filename)) {
dependencies.add(child.filename);
collectCJSDependencies(child, dependencies);
}
});
};
function wrapFunctionWithLocation(func) {
return (...args) => {
const oldPrepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = (error, stackFrames) => {
const frame = import_utilsBundle.sourceMapSupport.wrapCallSite(stackFrames[1]);
const fileName = frame.getFileName();
const file2 = fileName && fileName.startsWith("file://") ? import_url.default.fileURLToPath(fileName) : fileName;
return {
file: file2,
line: frame.getLineNumber(),
column: frame.getColumnNumber()
};
};
const oldStackTraceLimit = Error.stackTraceLimit;
Error.stackTraceLimit = 2;
const obj = {};
Error.captureStackTrace(obj);
const location = obj.stack;
Error.stackTraceLimit = oldStackTraceLimit;
Error.prepareStackTrace = oldPrepareStackTrace;
return func(location, ...args);
};
}
function isRelativeSpecifier(specifier) {
return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
requireOrImport,
resolveHook,
setSingleTSConfig,
setTransformConfig,
setTransformData,
shouldTransform,
singleTSConfig,
transformConfig,
transformHook,
wrapFunctionWithLocation
});

407
node_modules/playwright/lib/util.js generated vendored Normal file
View File

@@ -0,0 +1,407 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var util_exports = {};
__export(util_exports, {
addSuffixToFilePath: () => addSuffixToFilePath,
ansiRegex: () => ansiRegex,
callLogText: () => callLogText,
createFileFiltersFromArguments: () => createFileFiltersFromArguments,
createFileMatcher: () => createFileMatcher,
createFileMatcherFromArguments: () => createFileMatcherFromArguments,
createTitleMatcher: () => createTitleMatcher,
debugTest: () => debugTest,
errorWithFile: () => errorWithFile,
expectTypes: () => expectTypes,
fileExistsAsync: () => fileExistsAsync,
fileIsModule: () => fileIsModule,
filterStackFile: () => filterStackFile,
filterStackTrace: () => filterStackTrace,
filteredStackTrace: () => filteredStackTrace,
forceRegExp: () => forceRegExp,
formatLocation: () => formatLocation,
getContainedPath: () => getContainedPath,
getPackageJsonPath: () => getPackageJsonPath,
mergeObjects: () => mergeObjects,
normalizeAndSaveAttachment: () => normalizeAndSaveAttachment,
relativeFilePath: () => relativeFilePath,
removeDirAndLogToConsole: () => removeDirAndLogToConsole,
resolveImportSpecifierAfterMapping: () => resolveImportSpecifierAfterMapping,
resolveReporterOutputPath: () => resolveReporterOutputPath,
sanitizeFilePathBeforeExtension: () => sanitizeFilePathBeforeExtension,
serializeError: () => serializeError,
stripAnsiEscapes: () => stripAnsiEscapes,
trimLongString: () => trimLongString,
windowsFilesystemFriendlyLength: () => windowsFilesystemFriendlyLength
});
module.exports = __toCommonJS(util_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_url = __toESM(require("url"));
var import_util = __toESM(require("util"));
var import_utils = require("playwright-core/lib/utils");
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
const PLAYWRIGHT_TEST_PATH = import_path.default.join(__dirname, "..");
const PLAYWRIGHT_CORE_PATH = import_path.default.dirname(require.resolve("playwright-core/package.json"));
function filterStackTrace(e) {
const name = e.name ? e.name + ": " : "";
const cause = e.cause instanceof Error ? filterStackTrace(e.cause) : void 0;
if (process.env.PWDEBUGIMPL)
return { message: name + e.message, stack: e.stack || "", cause };
const stackLines = (0, import_utils.stringifyStackFrames)(filteredStackTrace(e.stack?.split("\n") || []));
return {
message: name + e.message,
stack: `${name}${e.message}${stackLines.map((line) => "\n" + line).join("")}`,
cause
};
}
function filterStackFile(file) {
if (!process.env.PWDEBUGIMPL && file.startsWith(PLAYWRIGHT_TEST_PATH))
return false;
if (!process.env.PWDEBUGIMPL && file.startsWith(PLAYWRIGHT_CORE_PATH))
return false;
return true;
}
function filteredStackTrace(rawStack) {
const frames = [];
for (const line of rawStack) {
const frame = (0, import_utils.parseStackFrame)(line, import_path.default.sep, !!process.env.PWDEBUGIMPL);
if (!frame || !frame.file)
continue;
if (!filterStackFile(frame.file))
continue;
frames.push(frame);
}
return frames;
}
function serializeError(error) {
if (error instanceof Error)
return filterStackTrace(error);
return {
value: import_util.default.inspect(error)
};
}
function createFileFiltersFromArguments(args) {
return args.map((arg) => {
const match = /^(.*?):(\d+):?(\d+)?$/.exec(arg);
return {
re: forceRegExp(match ? match[1] : arg),
line: match ? parseInt(match[2], 10) : null,
column: match?.[3] ? parseInt(match[3], 10) : null
};
});
}
function createFileMatcherFromArguments(args) {
const filters = createFileFiltersFromArguments(args);
return createFileMatcher(filters.map((filter) => filter.re || filter.exact || ""));
}
function createFileMatcher(patterns) {
const reList = [];
const filePatterns = [];
for (const pattern of Array.isArray(patterns) ? patterns : [patterns]) {
if ((0, import_utils.isRegExp)(pattern)) {
reList.push(pattern);
} else {
if (!pattern.startsWith("**/"))
filePatterns.push("**/" + pattern);
else
filePatterns.push(pattern);
}
}
return (filePath) => {
for (const re of reList) {
re.lastIndex = 0;
if (re.test(filePath))
return true;
}
if (import_path.default.sep === "\\") {
const fileURL = import_url.default.pathToFileURL(filePath).href;
for (const re of reList) {
re.lastIndex = 0;
if (re.test(fileURL))
return true;
}
}
for (const pattern of filePatterns) {
if ((0, import_utilsBundle.minimatch)(filePath, pattern, { nocase: true, dot: true }))
return true;
}
return false;
};
}
function createTitleMatcher(patterns) {
const reList = Array.isArray(patterns) ? patterns : [patterns];
return (value) => {
for (const re of reList) {
re.lastIndex = 0;
if (re.test(value))
return true;
}
return false;
};
}
function mergeObjects(a, b, c) {
const result = { ...a };
for (const x of [b, c].filter(Boolean)) {
for (const [name, value] of Object.entries(x)) {
if (!Object.is(value, void 0))
result[name] = value;
}
}
return result;
}
function forceRegExp(pattern) {
const match = pattern.match(/^\/(.*)\/([gi]*)$/);
if (match)
return new RegExp(match[1], match[2]);
return new RegExp(pattern, "gi");
}
function relativeFilePath(file) {
if (!import_path.default.isAbsolute(file))
return file;
return import_path.default.relative(process.cwd(), file);
}
function formatLocation(location) {
return relativeFilePath(location.file) + ":" + location.line + ":" + location.column;
}
function errorWithFile(file, message) {
return new Error(`${relativeFilePath(file)}: ${message}`);
}
function expectTypes(receiver, types, matcherName) {
if (typeof receiver !== "object" || !types.includes(receiver.constructor.name)) {
const commaSeparated = types.slice();
const lastType = commaSeparated.pop();
const typesString = commaSeparated.length ? commaSeparated.join(", ") + " or " + lastType : lastType;
throw new Error(`${matcherName} can be only used with ${typesString} object${types.length > 1 ? "s" : ""}`);
}
}
const windowsFilesystemFriendlyLength = 60;
function trimLongString(s, length = 100) {
if (s.length <= length)
return s;
const hash = (0, import_utils.calculateSha1)(s);
const middle = `-${hash.substring(0, 5)}-`;
const start = Math.floor((length - middle.length) / 2);
const end = length - middle.length - start;
return s.substring(0, start) + middle + s.slice(-end);
}
function addSuffixToFilePath(filePath, suffix) {
const ext = import_path.default.extname(filePath);
const base = filePath.substring(0, filePath.length - ext.length);
return base + suffix + ext;
}
function sanitizeFilePathBeforeExtension(filePath, ext) {
ext ??= import_path.default.extname(filePath);
const base = filePath.substring(0, filePath.length - ext.length);
return (0, import_utils.sanitizeForFilePath)(base) + ext;
}
function getContainedPath(parentPath, subPath = "") {
const resolvedPath = import_path.default.resolve(parentPath, subPath);
if (resolvedPath === parentPath || resolvedPath.startsWith(parentPath + import_path.default.sep))
return resolvedPath;
return null;
}
const debugTest = (0, import_utilsBundle.debug)("pw:test");
const callLogText = (log) => {
if (!log || !log.some((l) => !!l))
return "";
return `
Call log:
${import_utilsBundle.colors.dim(log.join("\n"))}
`;
};
const folderToPackageJsonPath = /* @__PURE__ */ new Map();
function getPackageJsonPath(folderPath) {
const cached = folderToPackageJsonPath.get(folderPath);
if (cached !== void 0)
return cached;
const packageJsonPath = import_path.default.join(folderPath, "package.json");
if (import_fs.default.existsSync(packageJsonPath)) {
folderToPackageJsonPath.set(folderPath, packageJsonPath);
return packageJsonPath;
}
const parentFolder = import_path.default.dirname(folderPath);
if (folderPath === parentFolder) {
folderToPackageJsonPath.set(folderPath, "");
return "";
}
const result = getPackageJsonPath(parentFolder);
folderToPackageJsonPath.set(folderPath, result);
return result;
}
function resolveReporterOutputPath(defaultValue, configDir, configValue) {
if (configValue)
return import_path.default.resolve(configDir, configValue);
let basePath = getPackageJsonPath(configDir);
basePath = basePath ? import_path.default.dirname(basePath) : process.cwd();
return import_path.default.resolve(basePath, defaultValue);
}
async function normalizeAndSaveAttachment(outputPath, name, options = {}) {
if (options.path === void 0 && options.body === void 0)
return { name, contentType: "text/plain" };
if ((options.path !== void 0 ? 1 : 0) + (options.body !== void 0 ? 1 : 0) !== 1)
throw new Error(`Exactly one of "path" and "body" must be specified`);
if (options.path !== void 0) {
const hash = (0, import_utils.calculateSha1)(options.path);
if (!(0, import_utils.isString)(name))
throw new Error('"name" should be string.');
const sanitizedNamePrefix = (0, import_utils.sanitizeForFilePath)(name) + "-";
const dest = import_path.default.join(outputPath, "attachments", sanitizedNamePrefix + hash + import_path.default.extname(options.path));
await import_fs.default.promises.mkdir(import_path.default.dirname(dest), { recursive: true });
await import_fs.default.promises.copyFile(options.path, dest);
const contentType = options.contentType ?? (import_utilsBundle.mime.getType(import_path.default.basename(options.path)) || "application/octet-stream");
return { name, contentType, path: dest };
} else {
const contentType = options.contentType ?? (typeof options.body === "string" ? "text/plain" : "application/octet-stream");
return { name, contentType, body: typeof options.body === "string" ? Buffer.from(options.body) : options.body };
}
}
function fileIsModule(file) {
if (file.endsWith(".mjs") || file.endsWith(".mts"))
return true;
if (file.endsWith(".cjs") || file.endsWith(".cts"))
return false;
const folder = import_path.default.dirname(file);
return folderIsModule(folder);
}
function folderIsModule(folder) {
const packageJsonPath = getPackageJsonPath(folder);
if (!packageJsonPath)
return false;
return require(packageJsonPath).type === "module";
}
const packageJsonMainFieldCache = /* @__PURE__ */ new Map();
function getMainFieldFromPackageJson(packageJsonPath) {
if (!packageJsonMainFieldCache.has(packageJsonPath)) {
let mainField;
try {
mainField = JSON.parse(import_fs.default.readFileSync(packageJsonPath, "utf8")).main;
} catch {
}
packageJsonMainFieldCache.set(packageJsonPath, mainField);
}
return packageJsonMainFieldCache.get(packageJsonPath);
}
const kExtLookups = /* @__PURE__ */ new Map([
[".js", [".jsx", ".ts", ".tsx"]],
[".jsx", [".tsx"]],
[".cjs", [".cts"]],
[".mjs", [".mts"]],
["", [".js", ".ts", ".jsx", ".tsx", ".cjs", ".mjs", ".cts", ".mts"]]
]);
function resolveImportSpecifierExtension(resolved) {
if (fileExists(resolved))
return resolved;
for (const [ext, others] of kExtLookups) {
if (!resolved.endsWith(ext))
continue;
for (const other of others) {
const modified = resolved.substring(0, resolved.length - ext.length) + other;
if (fileExists(modified))
return modified;
}
break;
}
}
function resolveImportSpecifierAfterMapping(resolved, afterPathMapping) {
const resolvedFile = resolveImportSpecifierExtension(resolved);
if (resolvedFile)
return resolvedFile;
if (dirExists(resolved)) {
const packageJsonPath = import_path.default.join(resolved, "package.json");
if (afterPathMapping) {
const mainField = getMainFieldFromPackageJson(packageJsonPath);
const mainFieldResolved = mainField ? resolveImportSpecifierExtension(import_path.default.resolve(resolved, mainField)) : void 0;
return mainFieldResolved || resolveImportSpecifierExtension(import_path.default.join(resolved, "index"));
}
if (fileExists(packageJsonPath))
return resolved;
const dirImport = import_path.default.join(resolved, "index");
return resolveImportSpecifierExtension(dirImport);
}
}
function fileExists(resolved) {
return import_fs.default.statSync(resolved, { throwIfNoEntry: false })?.isFile();
}
async function fileExistsAsync(resolved) {
try {
const stat = await import_fs.default.promises.stat(resolved);
return stat.isFile();
} catch {
return false;
}
}
function dirExists(resolved) {
return import_fs.default.statSync(resolved, { throwIfNoEntry: false })?.isDirectory();
}
async function removeDirAndLogToConsole(dir) {
try {
if (!import_fs.default.existsSync(dir))
return;
console.log(`Removing ${await import_fs.default.promises.realpath(dir)}`);
await import_fs.default.promises.rm(dir, { recursive: true, force: true });
} catch {
}
}
const ansiRegex = new RegExp("([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~])))", "g");
function stripAnsiEscapes(str) {
return str.replace(ansiRegex, "");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
addSuffixToFilePath,
ansiRegex,
callLogText,
createFileFiltersFromArguments,
createFileMatcher,
createFileMatcherFromArguments,
createTitleMatcher,
debugTest,
errorWithFile,
expectTypes,
fileExistsAsync,
fileIsModule,
filterStackFile,
filterStackTrace,
filteredStackTrace,
forceRegExp,
formatLocation,
getContainedPath,
getPackageJsonPath,
mergeObjects,
normalizeAndSaveAttachment,
relativeFilePath,
removeDirAndLogToConsole,
resolveImportSpecifierAfterMapping,
resolveReporterOutputPath,
sanitizeFilePathBeforeExtension,
serializeError,
stripAnsiEscapes,
trimLongString,
windowsFilesystemFriendlyLength
});

43
node_modules/playwright/lib/utilsBundle.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var utilsBundle_exports = {};
__export(utilsBundle_exports, {
chokidar: () => chokidar,
enquirer: () => enquirer,
getEastAsianWidth: () => getEastAsianWidth,
json5: () => json5,
sourceMapSupport: () => sourceMapSupport,
stoppable: () => stoppable
});
module.exports = __toCommonJS(utilsBundle_exports);
const json5 = require("./utilsBundleImpl").json5;
const sourceMapSupport = require("./utilsBundleImpl").sourceMapSupport;
const stoppable = require("./utilsBundleImpl").stoppable;
const enquirer = require("./utilsBundleImpl").enquirer;
const chokidar = require("./utilsBundleImpl").chokidar;
const getEastAsianWidth = require("./utilsBundleImpl").getEastAsianWidth;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
chokidar,
enquirer,
getEastAsianWidth,
json5,
sourceMapSupport,
stoppable
});

100
node_modules/playwright/lib/utilsBundleImpl.js generated vendored Normal file

File diff suppressed because one or more lines are too long

250
node_modules/playwright/lib/worker/fixtureRunner.js generated vendored Normal file
View File

@@ -0,0 +1,250 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var fixtureRunner_exports = {};
__export(fixtureRunner_exports, {
FixtureRunner: () => FixtureRunner
});
module.exports = __toCommonJS(fixtureRunner_exports);
var import_utils = require("playwright-core/lib/utils");
var import_fixtures = require("../common/fixtures");
var import_util = require("../util");
class Fixture {
constructor(runner, registration) {
this.failed = false;
this._deps = /* @__PURE__ */ new Set();
this._usages = /* @__PURE__ */ new Set();
this.runner = runner;
this.registration = registration;
this.value = null;
const isUserFixture = this.registration.location && (0, import_util.filterStackFile)(this.registration.location.file);
const title = this.registration.customTitle || this.registration.name;
const location = isUserFixture ? this.registration.location : void 0;
this._stepInfo = { title: `Fixture ${(0, import_utils.escapeWithQuotes)(title, '"')}`, category: "fixture", location };
if (this.registration.box)
this._stepInfo.group = isUserFixture ? "configuration" : "internal";
this._setupDescription = {
title,
phase: "setup",
location,
slot: this.registration.timeout === void 0 ? void 0 : {
timeout: this.registration.timeout,
elapsed: 0
}
};
this._teardownDescription = { ...this._setupDescription, phase: "teardown" };
}
async setup(testInfo, runnable) {
this.runner.instanceForId.set(this.registration.id, this);
if (typeof this.registration.fn !== "function") {
this.value = this.registration.fn;
return;
}
await testInfo._runAsStep(this._stepInfo, async () => {
await testInfo._runWithTimeout({ ...runnable, fixture: this._setupDescription }, () => this._setupInternal(testInfo));
});
}
async _setupInternal(testInfo) {
const params = {};
for (const name of this.registration.deps) {
const registration = this.runner.pool.resolve(name, this.registration);
const dep = this.runner.instanceForId.get(registration.id);
if (!dep) {
this.failed = true;
return;
}
dep._usages.add(this);
this._deps.add(dep);
params[name] = dep.value;
if (dep.failed) {
this.failed = true;
return;
}
}
let called = false;
const useFuncStarted = new import_utils.ManualPromise();
const useFunc = async (value) => {
if (called)
throw new Error(`Cannot provide fixture value for the second time`);
called = true;
this.value = value;
this._useFuncFinished = new import_utils.ManualPromise();
useFuncStarted.resolve();
await this._useFuncFinished;
};
const workerInfo = { config: testInfo.config, parallelIndex: testInfo.parallelIndex, workerIndex: testInfo.workerIndex, project: testInfo.project };
const info = this.registration.scope === "worker" ? workerInfo : testInfo;
this._selfTeardownComplete = (async () => {
try {
await this.registration.fn(params, useFunc, info);
} catch (error) {
this.failed = true;
if (!useFuncStarted.isDone())
useFuncStarted.reject(error);
else
throw error;
}
})();
await useFuncStarted;
}
async teardown(testInfo, runnable) {
try {
const fixtureRunnable = { ...runnable, fixture: this._teardownDescription };
if (!testInfo._timeoutManager.isTimeExhaustedFor(fixtureRunnable)) {
await testInfo._runAsStep(this._stepInfo, async () => {
await testInfo._runWithTimeout(fixtureRunnable, () => this._teardownInternal());
});
}
} finally {
for (const dep of this._deps)
dep._usages.delete(this);
this.runner.instanceForId.delete(this.registration.id);
}
}
async _teardownInternal() {
if (typeof this.registration.fn !== "function")
return;
if (this._usages.size !== 0) {
console.error("Internal error: fixture integrity at", this._teardownDescription.title);
this._usages.clear();
}
if (this._useFuncFinished) {
this._useFuncFinished.resolve();
this._useFuncFinished = void 0;
await this._selfTeardownComplete;
}
}
_collectFixturesInTeardownOrder(scope, collector) {
if (this.registration.scope !== scope)
return;
for (const fixture of this._usages)
fixture._collectFixturesInTeardownOrder(scope, collector);
collector.add(this);
}
}
class FixtureRunner {
constructor() {
this.testScopeClean = true;
this.instanceForId = /* @__PURE__ */ new Map();
}
setPool(pool) {
if (!this.testScopeClean)
throw new Error("Did not teardown test scope");
if (this.pool && pool.digest !== this.pool.digest) {
throw new Error([
`Playwright detected inconsistent test.use() options.`,
`Most common mistakes that lead to this issue:`,
` - Calling test.use() outside of the test file, for example in a common helper.`,
` - One test file imports from another test file.`
].join("\n"));
}
this.pool = pool;
}
_collectFixturesInSetupOrder(registration, collector) {
if (collector.has(registration))
return;
for (const name of registration.deps) {
const dep = this.pool.resolve(name, registration);
this._collectFixturesInSetupOrder(dep, collector);
}
collector.add(registration);
}
async teardownScope(scope, testInfo, runnable) {
const fixtures = Array.from(this.instanceForId.values()).reverse();
const collector = /* @__PURE__ */ new Set();
for (const fixture of fixtures)
fixture._collectFixturesInTeardownOrder(scope, collector);
let firstError;
for (const fixture of collector) {
try {
await fixture.teardown(testInfo, runnable);
} catch (error) {
firstError = firstError ?? error;
}
}
if (scope === "test")
this.testScopeClean = true;
if (firstError)
throw firstError;
}
async resolveParametersForFunction(fn, testInfo, autoFixtures, runnable) {
const collector = /* @__PURE__ */ new Set();
const auto = [];
for (const registration of this.pool.autoFixtures()) {
let shouldRun = true;
if (autoFixtures === "all-hooks-only")
shouldRun = registration.scope === "worker" || registration.auto === "all-hooks-included";
else if (autoFixtures === "worker")
shouldRun = registration.scope === "worker";
if (shouldRun)
auto.push(registration);
}
auto.sort((r1, r2) => (r1.scope === "worker" ? 0 : 1) - (r2.scope === "worker" ? 0 : 1));
for (const registration of auto)
this._collectFixturesInSetupOrder(registration, collector);
const names = getRequiredFixtureNames(fn);
for (const name of names)
this._collectFixturesInSetupOrder(this.pool.resolve(name), collector);
for (const registration of collector)
await this._setupFixtureForRegistration(registration, testInfo, runnable);
const params = {};
for (const name of names) {
const registration = this.pool.resolve(name);
const fixture = this.instanceForId.get(registration.id);
if (!fixture || fixture.failed)
return null;
params[name] = fixture.value;
}
return params;
}
async resolveParametersAndRunFunction(fn, testInfo, autoFixtures, runnable) {
const params = await this.resolveParametersForFunction(fn, testInfo, autoFixtures, runnable);
if (params === null) {
return null;
}
await testInfo._runWithTimeout(runnable, () => fn(params, testInfo));
}
async _setupFixtureForRegistration(registration, testInfo, runnable) {
if (registration.scope === "test")
this.testScopeClean = false;
let fixture = this.instanceForId.get(registration.id);
if (fixture)
return fixture;
fixture = new Fixture(this, registration);
await fixture.setup(testInfo, runnable);
return fixture;
}
dependsOnWorkerFixturesOnly(fn, location) {
const names = getRequiredFixtureNames(fn, location);
for (const name of names) {
const registration = this.pool.resolve(name);
if (registration.scope !== "worker")
return false;
}
return true;
}
}
function getRequiredFixtureNames(fn, location) {
return (0, import_fixtures.fixtureParameterNames)(fn, location ?? { file: "<unknown>", line: 1, column: 1 }, (e) => {
throw new Error(`${(0, import_util.formatLocation)(e.location)}: ${e.message}`);
});
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
FixtureRunner
});

517
node_modules/playwright/lib/worker/testInfo.js generated vendored Normal file
View File

@@ -0,0 +1,517 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testInfo_exports = {};
__export(testInfo_exports, {
StepSkipError: () => StepSkipError,
TestInfoImpl: () => TestInfoImpl,
TestSkipError: () => TestSkipError,
TestStepInfoImpl: () => TestStepInfoImpl
});
module.exports = __toCommonJS(testInfo_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_timeoutManager = require("./timeoutManager");
var import_util = require("../util");
var import_testTracing = require("./testTracing");
var import_util2 = require("./util");
var import_transform = require("../transform/transform");
class TestInfoImpl {
constructor(configInternal, projectInternal, workerParams, test, retry, onStepBegin, onStepRecoverFromError, onStepEnd, onAttach) {
this._snapshotNames = { lastAnonymousSnapshotIndex: 0, lastNamedSnapshotIndex: {} };
this._ariaSnapshotNames = { lastAnonymousSnapshotIndex: 0, lastNamedSnapshotIndex: {} };
this._wasInterrupted = false;
this._lastStepId = 0;
this._steps = [];
this._stepMap = /* @__PURE__ */ new Map();
this._hasNonRetriableError = false;
this._hasUnhandledError = false;
this._allowSkips = false;
this.duration = 0;
this.annotations = [];
this.attachments = [];
this.status = "passed";
this.snapshotSuffix = "";
this.errors = [];
this.testId = test?.id ?? "";
this._onStepBegin = onStepBegin;
this._onStepRecoverFromError = onStepRecoverFromError;
this._onStepEnd = onStepEnd;
this._onAttach = onAttach;
this._startTime = (0, import_utils.monotonicTime)();
this._startWallTime = Date.now();
this._requireFile = test?._requireFile ?? "";
this._uniqueSymbol = Symbol("testInfoUniqueSymbol");
this.repeatEachIndex = workerParams.repeatEachIndex;
this.retry = retry;
this.workerIndex = workerParams.workerIndex;
this.parallelIndex = workerParams.parallelIndex;
this._projectInternal = projectInternal;
this.project = projectInternal.project;
this._configInternal = configInternal;
this.config = configInternal.config;
this.title = test?.title ?? "";
this.titlePath = test?.titlePath() ?? [];
this.file = test?.location.file ?? "";
this.line = test?.location.line ?? 0;
this.column = test?.location.column ?? 0;
this.tags = test?.tags ?? [];
this.fn = test?.fn ?? (() => {
});
this.expectedStatus = test?.expectedStatus ?? "skipped";
this._recoverFromStepErrorResults = workerParams.recoverFromStepErrors ? /* @__PURE__ */ new Map() : void 0;
this._timeoutManager = new import_timeoutManager.TimeoutManager(this.project.timeout);
if (configInternal.configCLIOverrides.debug)
this._setDebugMode();
this.outputDir = (() => {
const relativeTestFilePath = import_path.default.relative(this.project.testDir, this._requireFile.replace(/\.(spec|test)\.(js|ts|jsx|tsx|mjs|mts|cjs|cts)$/, ""));
const sanitizedRelativePath = relativeTestFilePath.replace(process.platform === "win32" ? new RegExp("\\\\", "g") : new RegExp("/", "g"), "-");
const fullTitleWithoutSpec = this.titlePath.slice(1).join(" ");
let testOutputDir = (0, import_util.trimLongString)(sanitizedRelativePath + "-" + (0, import_utils.sanitizeForFilePath)(fullTitleWithoutSpec), import_util.windowsFilesystemFriendlyLength);
if (projectInternal.id)
testOutputDir += "-" + (0, import_utils.sanitizeForFilePath)(projectInternal.id);
if (this.retry)
testOutputDir += "-retry" + this.retry;
if (this.repeatEachIndex)
testOutputDir += "-repeat" + this.repeatEachIndex;
return import_path.default.join(this.project.outputDir, testOutputDir);
})();
this.snapshotDir = (() => {
const relativeTestFilePath = import_path.default.relative(this.project.testDir, this._requireFile);
return import_path.default.join(this.project.snapshotDir, relativeTestFilePath + "-snapshots");
})();
this._attachmentsPush = this.attachments.push.bind(this.attachments);
this.attachments.push = (...attachments) => {
for (const a of attachments)
this._attach(a, this._parentStep()?.stepId);
return this.attachments.length;
};
this._tracing = new import_testTracing.TestTracing(this, workerParams.artifactsDir);
this.skip = (0, import_transform.wrapFunctionWithLocation)((location, ...args) => this._modifier("skip", location, args));
this.fixme = (0, import_transform.wrapFunctionWithLocation)((location, ...args) => this._modifier("fixme", location, args));
this.fail = (0, import_transform.wrapFunctionWithLocation)((location, ...args) => this._modifier("fail", location, args));
this.slow = (0, import_transform.wrapFunctionWithLocation)((location, ...args) => this._modifier("slow", location, args));
}
get error() {
return this.errors[0];
}
set error(e) {
if (e === void 0)
throw new Error("Cannot assign testInfo.error undefined value!");
this.errors[0] = e;
}
get timeout() {
return this._timeoutManager.defaultSlot().timeout;
}
set timeout(timeout) {
}
_deadlineForMatcher(timeout) {
const startTime = (0, import_utils.monotonicTime)();
const matcherDeadline = timeout ? startTime + timeout : import_timeoutManager.kMaxDeadline;
const testDeadline = this._timeoutManager.currentSlotDeadline() - 250;
const matcherMessage = `Timeout ${timeout}ms exceeded while waiting on the predicate`;
const testMessage = `Test timeout of ${this.timeout}ms exceeded`;
return { deadline: Math.min(testDeadline, matcherDeadline), timeoutMessage: testDeadline < matcherDeadline ? testMessage : matcherMessage };
}
static _defaultDeadlineForMatcher(timeout) {
return { deadline: timeout ? (0, import_utils.monotonicTime)() + timeout : 0, timeoutMessage: `Timeout ${timeout}ms exceeded while waiting on the predicate` };
}
_modifier(type, location, modifierArgs) {
if (typeof modifierArgs[1] === "function") {
throw new Error([
"It looks like you are calling test.skip() inside the test and pass a callback.",
"Pass a condition instead and optional description instead:",
`test('my test', async ({ page, isMobile }) => {`,
` test.skip(isMobile, 'This test is not applicable on mobile');`,
`});`
].join("\n"));
}
if (modifierArgs.length >= 1 && !modifierArgs[0])
return;
const description = modifierArgs[1];
this.annotations.push({ type, description, location });
if (type === "slow") {
this._timeoutManager.slow();
} else if (type === "skip" || type === "fixme") {
this.expectedStatus = "skipped";
throw new TestSkipError("Test is skipped: " + (description || ""));
} else if (type === "fail") {
if (this.expectedStatus !== "skipped")
this.expectedStatus = "failed";
}
}
_findLastPredefinedStep(steps) {
for (let i = steps.length - 1; i >= 0; i--) {
const child = this._findLastPredefinedStep(steps[i].steps);
if (child)
return child;
if ((steps[i].category === "hook" || steps[i].category === "fixture") && !steps[i].endWallTime)
return steps[i];
}
}
_parentStep() {
return (0, import_utils.currentZone)().data("stepZone") ?? this._findLastPredefinedStep(this._steps);
}
_addStep(data, parentStep) {
const stepId = `${data.category}@${++this._lastStepId}`;
if (data.category === "hook" || data.category === "fixture") {
parentStep = this._findLastPredefinedStep(this._steps);
} else {
if (!parentStep)
parentStep = this._parentStep();
}
const filteredStack = (0, import_util.filteredStackTrace)((0, import_utils.captureRawStack)());
let boxedStack = parentStep?.boxedStack;
let location = data.location;
if (!boxedStack && data.box) {
boxedStack = filteredStack.slice(1);
location = location || boxedStack[0];
}
location = location || filteredStack[0];
const step = {
...data,
stepId,
group: parentStep?.group ?? data.group,
boxedStack,
location,
steps: [],
attachmentIndices: [],
info: new TestStepInfoImpl(this, stepId, data.title, parentStep?.info),
recoverFromStepError: async (error) => {
if (!this._recoverFromStepErrorResults)
return { stepId, status: "failed" };
const payload = {
testId: this.testId,
stepId,
error: (0, import_util.serializeError)(error)
};
this._onStepRecoverFromError(payload);
const recoveryPromise = new import_utils.ManualPromise();
this._recoverFromStepErrorResults.set(stepId, recoveryPromise);
const recoveryResult = await recoveryPromise;
if (recoveryResult.stepId !== stepId)
return { stepId, status: "failed" };
return recoveryResult;
},
complete: (result) => {
if (step.endWallTime)
return;
step.endWallTime = Date.now();
if (result.error) {
if (typeof result.error === "object" && !result.error?.[stepSymbol])
result.error[stepSymbol] = step;
const error = (0, import_util2.testInfoError)(result.error);
if (step.boxedStack)
error.stack = `${error.message}
${(0, import_utils.stringifyStackFrames)(step.boxedStack).join("\n")}`;
step.error = error;
}
if (!step.error) {
for (const childStep of step.steps) {
if (childStep.error && childStep.infectParentStepsWithError) {
step.error = childStep.error;
step.infectParentStepsWithError = true;
break;
}
}
}
if (!step.group) {
const payload = {
testId: this.testId,
stepId,
wallTime: step.endWallTime,
error: step.error,
suggestedRebaseline: result.suggestedRebaseline,
annotations: step.info.annotations
};
this._onStepEnd(payload);
}
if (step.group !== "internal") {
const errorForTrace = step.error ? { name: "", message: step.error.message || "", stack: step.error.stack } : void 0;
const attachments = step.attachmentIndices.map((i) => this.attachments[i]);
this._tracing.appendAfterActionForStep(stepId, errorForTrace, attachments, step.info.annotations);
}
}
};
const parentStepList = parentStep ? parentStep.steps : this._steps;
parentStepList.push(step);
this._stepMap.set(stepId, step);
if (!step.group) {
const payload = {
testId: this.testId,
stepId,
parentStepId: parentStep ? parentStep.stepId : void 0,
title: step.title,
category: step.category,
wallTime: Date.now(),
location: step.location
};
this._onStepBegin(payload);
}
if (step.group !== "internal") {
this._tracing.appendBeforeActionForStep({
stepId,
parentId: parentStep?.stepId,
title: step.title,
category: step.category,
params: step.params,
stack: step.location ? [step.location] : [],
group: step.group
});
}
return step;
}
resumeAfterStepError(result) {
const recoveryPromise = this._recoverFromStepErrorResults?.get(result.stepId);
if (recoveryPromise)
recoveryPromise.resolve(result);
}
_interrupt() {
this._wasInterrupted = true;
this._timeoutManager.interrupt();
if (this.status === "passed")
this.status = "interrupted";
}
_failWithError(error) {
if (this.status === "passed" || this.status === "skipped")
this.status = error instanceof import_timeoutManager.TimeoutManagerError ? "timedOut" : "failed";
const serialized = (0, import_util2.testInfoError)(error);
const step = typeof error === "object" ? error?.[stepSymbol] : void 0;
if (step && step.boxedStack)
serialized.stack = `${error.name}: ${error.message}
${(0, import_utils.stringifyStackFrames)(step.boxedStack).join("\n")}`;
this.errors.push(serialized);
this._tracing.appendForError(serialized);
}
async _runAsStep(stepInfo, cb) {
const step = this._addStep(stepInfo);
try {
await cb();
step.complete({});
} catch (error) {
step.complete({ error });
throw error;
}
}
async _runWithTimeout(runnable, cb) {
try {
await this._timeoutManager.withRunnable(runnable, async () => {
try {
await cb();
} catch (e) {
if (this._allowSkips && e instanceof TestSkipError) {
if (this.status === "passed")
this.status = "skipped";
} else {
this._failWithError(e);
}
throw e;
}
});
} catch (error) {
if (!this._wasInterrupted && error instanceof import_timeoutManager.TimeoutManagerError)
this._failWithError(error);
throw error;
}
}
_isFailure() {
return this.status !== "skipped" && this.status !== this.expectedStatus;
}
_currentHookType() {
const type = this._timeoutManager.currentSlotType();
return ["beforeAll", "afterAll", "beforeEach", "afterEach"].includes(type) ? type : void 0;
}
_setDebugMode() {
this._timeoutManager.setIgnoreTimeouts();
}
// ------------ TestInfo methods ------------
async attach(name, options = {}) {
const step = this._addStep({
title: `Attach ${(0, import_utils.escapeWithQuotes)(name, '"')}`,
category: "test.attach"
});
this._attach(await (0, import_util.normalizeAndSaveAttachment)(this.outputPath(), name, options), step.stepId);
step.complete({});
}
_attach(attachment, stepId) {
const index = this._attachmentsPush(attachment) - 1;
if (stepId) {
this._stepMap.get(stepId).attachmentIndices.push(index);
} else {
const stepId2 = `attach@${(0, import_utils.createGuid)()}`;
this._tracing.appendBeforeActionForStep({ stepId: stepId2, title: `Attach ${(0, import_utils.escapeWithQuotes)(attachment.name, '"')}`, category: "test.attach", stack: [] });
this._tracing.appendAfterActionForStep(stepId2, void 0, [attachment]);
}
this._onAttach({
testId: this.testId,
name: attachment.name,
contentType: attachment.contentType,
path: attachment.path,
body: attachment.body?.toString("base64"),
stepId
});
}
outputPath(...pathSegments) {
const outputPath = this._getOutputPath(...pathSegments);
import_fs.default.mkdirSync(this.outputDir, { recursive: true });
return outputPath;
}
_getOutputPath(...pathSegments) {
const joinedPath = import_path.default.join(...pathSegments);
const outputPath = (0, import_util.getContainedPath)(this.outputDir, joinedPath);
if (outputPath)
return outputPath;
throw new Error(`The outputPath is not allowed outside of the parent directory. Please fix the defined path.
outputPath: ${joinedPath}`);
}
_fsSanitizedTestName() {
const fullTitleWithoutSpec = this.titlePath.slice(1).join(" ");
return (0, import_utils.sanitizeForFilePath)((0, import_util.trimLongString)(fullTitleWithoutSpec));
}
_resolveSnapshotPaths(kind, name, updateSnapshotIndex, anonymousExtension) {
const snapshotNames = kind === "aria" ? this._ariaSnapshotNames : this._snapshotNames;
const defaultExtensions = { "aria": ".aria.yml", "screenshot": ".png", "snapshot": ".txt" };
const ariaAwareExtname = (filePath) => kind === "aria" && filePath.endsWith(".aria.yml") ? ".aria.yml" : import_path.default.extname(filePath);
let subPath;
let ext;
let relativeOutputPath;
if (!name) {
const index = snapshotNames.lastAnonymousSnapshotIndex + 1;
if (updateSnapshotIndex === "updateSnapshotIndex")
snapshotNames.lastAnonymousSnapshotIndex = index;
const fullTitleWithoutSpec = [...this.titlePath.slice(1), index].join(" ");
ext = anonymousExtension ?? defaultExtensions[kind];
subPath = (0, import_util.sanitizeFilePathBeforeExtension)((0, import_util.trimLongString)(fullTitleWithoutSpec) + ext, ext);
relativeOutputPath = (0, import_util.sanitizeFilePathBeforeExtension)((0, import_util.trimLongString)(fullTitleWithoutSpec, import_util.windowsFilesystemFriendlyLength) + ext, ext);
} else {
if (Array.isArray(name)) {
subPath = import_path.default.join(...name);
relativeOutputPath = import_path.default.join(...name);
ext = ariaAwareExtname(subPath);
} else {
ext = ariaAwareExtname(name);
subPath = (0, import_util.sanitizeFilePathBeforeExtension)(name, ext);
relativeOutputPath = (0, import_util.sanitizeFilePathBeforeExtension)((0, import_util.trimLongString)(name, import_util.windowsFilesystemFriendlyLength), ext);
}
const index = (snapshotNames.lastNamedSnapshotIndex[relativeOutputPath] || 0) + 1;
if (updateSnapshotIndex === "updateSnapshotIndex")
snapshotNames.lastNamedSnapshotIndex[relativeOutputPath] = index;
if (index > 1)
relativeOutputPath = (0, import_util.addSuffixToFilePath)(relativeOutputPath, `-${index - 1}`);
}
const absoluteSnapshotPath = this._applyPathTemplate(kind, subPath, ext);
return { absoluteSnapshotPath, relativeOutputPath };
}
_applyPathTemplate(kind, relativePath, ext) {
const legacyTemplate = "{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{-projectName}{-snapshotSuffix}{ext}";
let template;
if (kind === "screenshot") {
template = this._projectInternal.expect?.toHaveScreenshot?.pathTemplate || this._projectInternal.snapshotPathTemplate || legacyTemplate;
} else if (kind === "aria") {
const ariaDefaultTemplate = "{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{ext}";
template = this._projectInternal.expect?.toMatchAriaSnapshot?.pathTemplate || this._projectInternal.snapshotPathTemplate || ariaDefaultTemplate;
} else {
template = this._projectInternal.snapshotPathTemplate || legacyTemplate;
}
const dir = import_path.default.dirname(relativePath);
const name = import_path.default.basename(relativePath, ext);
const relativeTestFilePath = import_path.default.relative(this.project.testDir, this._requireFile);
const parsedRelativeTestFilePath = import_path.default.parse(relativeTestFilePath);
const projectNamePathSegment = (0, import_utils.sanitizeForFilePath)(this.project.name);
const snapshotPath = template.replace(/\{(.)?testDir\}/g, "$1" + this.project.testDir).replace(/\{(.)?snapshotDir\}/g, "$1" + this.project.snapshotDir).replace(/\{(.)?snapshotSuffix\}/g, this.snapshotSuffix ? "$1" + this.snapshotSuffix : "").replace(/\{(.)?testFileDir\}/g, "$1" + parsedRelativeTestFilePath.dir).replace(/\{(.)?platform\}/g, "$1" + process.platform).replace(/\{(.)?projectName\}/g, projectNamePathSegment ? "$1" + projectNamePathSegment : "").replace(/\{(.)?testName\}/g, "$1" + this._fsSanitizedTestName()).replace(/\{(.)?testFileName\}/g, "$1" + parsedRelativeTestFilePath.base).replace(/\{(.)?testFilePath\}/g, "$1" + relativeTestFilePath).replace(/\{(.)?arg\}/g, "$1" + import_path.default.join(dir, name)).replace(/\{(.)?ext\}/g, ext ? "$1" + ext : "");
return import_path.default.normalize(import_path.default.resolve(this._configInternal.configDir, snapshotPath));
}
snapshotPath(...args) {
let name = args;
let kind = "snapshot";
const options = args[args.length - 1];
if (options && typeof options === "object") {
kind = options.kind ?? kind;
name = args.slice(0, -1);
}
if (!["snapshot", "screenshot", "aria"].includes(kind))
throw new Error(`testInfo.snapshotPath: unknown kind "${kind}", must be one of "snapshot", "screenshot" or "aria"`);
return this._resolveSnapshotPaths(kind, name.length <= 1 ? name[0] : name, "dontUpdateSnapshotIndex").absoluteSnapshotPath;
}
setTimeout(timeout) {
this._timeoutManager.setTimeout(timeout);
}
}
class TestStepInfoImpl {
constructor(testInfo, stepId, title, parentStep) {
this.annotations = [];
this._testInfo = testInfo;
this._stepId = stepId;
this._title = title;
this._parentStep = parentStep;
this.skip = (0, import_transform.wrapFunctionWithLocation)((location, ...args) => {
if (args.length > 0 && !args[0])
return;
const description = args[1];
this.annotations.push({ type: "skip", description, location });
throw new StepSkipError(description);
});
}
async _runStepBody(skip, body, location) {
if (skip) {
this.annotations.push({ type: "skip", location });
return void 0;
}
try {
return await body(this);
} catch (e) {
if (e instanceof StepSkipError)
return void 0;
throw e;
}
}
_attachToStep(attachment) {
this._testInfo._attach(attachment, this._stepId);
}
async attach(name, options) {
this._attachToStep(await (0, import_util.normalizeAndSaveAttachment)(this._testInfo.outputPath(), name, options));
}
get titlePath() {
const parent = this._parentStep ?? this._testInfo;
return [...parent.titlePath, this._title];
}
}
class TestSkipError extends Error {
}
class StepSkipError extends Error {
}
const stepSymbol = Symbol("step");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
StepSkipError,
TestInfoImpl,
TestSkipError,
TestStepInfoImpl
});

344
node_modules/playwright/lib/worker/testTracing.js generated vendored Normal file
View File

@@ -0,0 +1,344 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testTracing_exports = {};
__export(testTracing_exports, {
TestTracing: () => TestTracing,
testTraceEntryName: () => testTraceEntryName
});
module.exports = __toCommonJS(testTracing_exports);
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_utils = require("playwright-core/lib/utils");
var import_zipBundle = require("playwright-core/lib/zipBundle");
var import_util = require("../util");
const testTraceEntryName = "test.trace";
const version = 8;
let traceOrdinal = 0;
class TestTracing {
constructor(testInfo, artifactsDir) {
this._traceEvents = [];
this._temporaryTraceFiles = [];
this._didFinishTestFunctionAndAfterEachHooks = false;
this._testInfo = testInfo;
this._artifactsDir = artifactsDir;
this._tracesDir = import_path.default.join(this._artifactsDir, "traces");
this._contextCreatedEvent = {
version,
type: "context-options",
origin: "testRunner",
browserName: "",
options: {},
platform: process.platform,
wallTime: Date.now(),
monotonicTime: (0, import_utils.monotonicTime)(),
sdkLanguage: "javascript"
};
this._appendTraceEvent(this._contextCreatedEvent);
}
_shouldCaptureTrace() {
if (this._options?.mode === "on")
return true;
if (this._options?.mode === "retain-on-failure")
return true;
if (this._options?.mode === "on-first-retry" && this._testInfo.retry === 1)
return true;
if (this._options?.mode === "on-all-retries" && this._testInfo.retry > 0)
return true;
if (this._options?.mode === "retain-on-first-failure" && this._testInfo.retry === 0)
return true;
return false;
}
async startIfNeeded(value) {
const defaultTraceOptions = { screenshots: true, snapshots: true, sources: true, attachments: true, _live: false, mode: "off" };
if (!value) {
this._options = defaultTraceOptions;
} else if (typeof value === "string") {
this._options = { ...defaultTraceOptions, mode: value === "retry-with-trace" ? "on-first-retry" : value };
} else {
const mode = value.mode || "off";
this._options = { ...defaultTraceOptions, ...value, mode: mode === "retry-with-trace" ? "on-first-retry" : mode };
}
if (!this._shouldCaptureTrace()) {
this._options = void 0;
return;
}
if (!this._liveTraceFile && this._options._live) {
this._liveTraceFile = { file: import_path.default.join(this._tracesDir, `${this._testInfo.testId}-test.trace`), fs: new import_utils.SerializedFS() };
this._liveTraceFile.fs.mkdir(import_path.default.dirname(this._liveTraceFile.file));
const data = this._traceEvents.map((e) => JSON.stringify(e)).join("\n") + "\n";
this._liveTraceFile.fs.writeFile(this._liveTraceFile.file, data);
}
}
didFinishTestFunctionAndAfterEachHooks() {
this._didFinishTestFunctionAndAfterEachHooks = true;
}
artifactsDir() {
return this._artifactsDir;
}
tracesDir() {
return this._tracesDir;
}
traceTitle() {
return [import_path.default.relative(this._testInfo.project.testDir, this._testInfo.file) + ":" + this._testInfo.line, ...this._testInfo.titlePath.slice(1)].join(" \u203A ");
}
generateNextTraceRecordingName() {
const ordinalSuffix = traceOrdinal ? `-recording${traceOrdinal}` : "";
++traceOrdinal;
const retrySuffix = this._testInfo.retry ? `-retry${this._testInfo.retry}` : "";
return `${this._testInfo.testId}${retrySuffix}${ordinalSuffix}`;
}
_generateNextTraceRecordingPath() {
const file = import_path.default.join(this._artifactsDir, (0, import_utils.createGuid)() + ".zip");
this._temporaryTraceFiles.push(file);
return file;
}
traceOptions() {
return this._options;
}
maybeGenerateNextTraceRecordingPath() {
if (this._didFinishTestFunctionAndAfterEachHooks && this._shouldAbandonTrace())
return;
return this._generateNextTraceRecordingPath();
}
_shouldAbandonTrace() {
if (!this._options)
return true;
const testFailed = this._testInfo.status !== this._testInfo.expectedStatus;
return !testFailed && (this._options.mode === "retain-on-failure" || this._options.mode === "retain-on-first-failure");
}
async stopIfNeeded() {
if (!this._options)
return;
const error = await this._liveTraceFile?.fs.syncAndGetError();
if (error)
throw error;
if (this._shouldAbandonTrace()) {
for (const file of this._temporaryTraceFiles)
await import_fs.default.promises.unlink(file).catch(() => {
});
return;
}
const zipFile = new import_zipBundle.yazl.ZipFile();
if (!this._options?.attachments) {
for (const event of this._traceEvents) {
if (event.type === "after")
delete event.attachments;
}
}
if (this._options?.sources) {
const sourceFiles = /* @__PURE__ */ new Set();
for (const event of this._traceEvents) {
if (event.type === "before") {
for (const frame of event.stack || [])
sourceFiles.add(frame.file);
}
}
for (const sourceFile of sourceFiles) {
await import_fs.default.promises.readFile(sourceFile, "utf8").then((source) => {
zipFile.addBuffer(Buffer.from(source), "resources/src@" + (0, import_utils.calculateSha1)(sourceFile) + ".txt");
}).catch(() => {
});
}
}
const sha1s = /* @__PURE__ */ new Set();
for (const event of this._traceEvents.filter((e) => e.type === "after")) {
for (const attachment of event.attachments || []) {
let contentPromise;
if (attachment.path)
contentPromise = import_fs.default.promises.readFile(attachment.path).catch(() => void 0);
else if (attachment.base64)
contentPromise = Promise.resolve(Buffer.from(attachment.base64, "base64"));
const content = await contentPromise;
if (content === void 0)
continue;
const sha1 = (0, import_utils.calculateSha1)(content);
attachment.sha1 = sha1;
delete attachment.path;
delete attachment.base64;
if (sha1s.has(sha1))
continue;
sha1s.add(sha1);
zipFile.addBuffer(content, "resources/" + sha1);
}
}
const traceContent = Buffer.from(this._traceEvents.map((e) => JSON.stringify(e)).join("\n"));
zipFile.addBuffer(traceContent, testTraceEntryName);
await new Promise((f) => {
zipFile.end(void 0, () => {
zipFile.outputStream.pipe(import_fs.default.createWriteStream(this._generateNextTraceRecordingPath())).on("close", f);
});
});
const tracePath = this._testInfo.outputPath("trace.zip");
await mergeTraceFiles(tracePath, this._temporaryTraceFiles);
this._testInfo.attachments.push({ name: "trace", path: tracePath, contentType: "application/zip" });
}
appendForError(error) {
const rawStack = error.stack?.split("\n") || [];
const stack = rawStack ? (0, import_util.filteredStackTrace)(rawStack) : [];
this._appendTraceEvent({
type: "error",
message: this._formatError(error),
stack
});
}
_formatError(error) {
const parts = [error.message || String(error.value)];
if (error.cause)
parts.push("[cause]: " + this._formatError(error.cause));
return parts.join("\n");
}
appendStdioToTrace(type, chunk) {
this._appendTraceEvent({
type,
timestamp: (0, import_utils.monotonicTime)(),
text: typeof chunk === "string" ? chunk : void 0,
base64: typeof chunk === "string" ? void 0 : chunk.toString("base64")
});
}
appendBeforeActionForStep(options) {
this._appendTraceEvent({
type: "before",
callId: options.stepId,
stepId: options.stepId,
parentId: options.parentId,
startTime: (0, import_utils.monotonicTime)(),
class: "Test",
method: options.category,
title: options.title,
params: Object.fromEntries(Object.entries(options.params || {}).map(([name, value]) => [name, generatePreview(value)])),
stack: options.stack,
group: options.group
});
}
appendAfterActionForStep(callId, error, attachments = [], annotations) {
this._appendTraceEvent({
type: "after",
callId,
endTime: (0, import_utils.monotonicTime)(),
attachments: serializeAttachments(attachments),
annotations,
error
});
}
_appendTraceEvent(event) {
this._traceEvents.push(event);
if (this._liveTraceFile)
this._liveTraceFile.fs.appendFile(this._liveTraceFile.file, JSON.stringify(event) + "\n", true);
}
}
function serializeAttachments(attachments) {
if (attachments.length === 0)
return void 0;
return attachments.filter((a) => a.name !== "trace").map((a) => {
return {
name: a.name,
contentType: a.contentType,
path: a.path,
base64: a.body?.toString("base64")
};
});
}
function generatePreview(value, visited = /* @__PURE__ */ new Set()) {
if (visited.has(value))
return "";
visited.add(value);
if (typeof value === "string")
return value;
if (typeof value === "number")
return value.toString();
if (typeof value === "boolean")
return value.toString();
if (value === null)
return "null";
if (value === void 0)
return "undefined";
if (Array.isArray(value))
return "[" + value.map((v) => generatePreview(v, visited)).join(", ") + "]";
if (typeof value === "object")
return "Object";
return String(value);
}
async function mergeTraceFiles(fileName, temporaryTraceFiles) {
temporaryTraceFiles = temporaryTraceFiles.filter((file) => import_fs.default.existsSync(file));
if (temporaryTraceFiles.length === 1) {
await import_fs.default.promises.rename(temporaryTraceFiles[0], fileName);
return;
}
const mergePromise = new import_utils.ManualPromise();
const zipFile = new import_zipBundle.yazl.ZipFile();
const entryNames = /* @__PURE__ */ new Set();
zipFile.on("error", (error) => mergePromise.reject(error));
for (let i = temporaryTraceFiles.length - 1; i >= 0; --i) {
const tempFile = temporaryTraceFiles[i];
const promise = new import_utils.ManualPromise();
import_zipBundle.yauzl.open(tempFile, (err, inZipFile) => {
if (err) {
promise.reject(err);
return;
}
let pendingEntries = inZipFile.entryCount;
inZipFile.on("entry", (entry) => {
let entryName = entry.fileName;
if (entry.fileName === testTraceEntryName) {
} else if (entry.fileName.match(/trace\.[a-z]*$/)) {
entryName = i + "-" + entry.fileName;
}
if (entryNames.has(entryName)) {
if (--pendingEntries === 0)
promise.resolve();
return;
}
entryNames.add(entryName);
inZipFile.openReadStream(entry, (err2, readStream) => {
if (err2) {
promise.reject(err2);
return;
}
zipFile.addReadStream(readStream, entryName);
if (--pendingEntries === 0)
promise.resolve();
});
});
});
await promise;
}
zipFile.end(void 0, () => {
zipFile.outputStream.pipe(import_fs.default.createWriteStream(fileName)).on("close", () => {
void Promise.all(temporaryTraceFiles.map((tempFile) => import_fs.default.promises.unlink(tempFile))).then(() => {
mergePromise.resolve();
}).catch((error) => mergePromise.reject(error));
}).on("error", (error) => mergePromise.reject(error));
});
await mergePromise;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TestTracing,
testTraceEntryName
});

174
node_modules/playwright/lib/worker/timeoutManager.js generated vendored Normal file
View File

@@ -0,0 +1,174 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var timeoutManager_exports = {};
__export(timeoutManager_exports, {
TimeoutManager: () => TimeoutManager,
TimeoutManagerError: () => TimeoutManagerError,
kMaxDeadline: () => kMaxDeadline
});
module.exports = __toCommonJS(timeoutManager_exports);
var import_utils = require("playwright-core/lib/utils");
var import_utils2 = require("playwright-core/lib/utils");
var import_util = require("../util");
const kMaxDeadline = 2147483647;
class TimeoutManager {
constructor(timeout) {
this._ignoreTimeouts = false;
this._defaultSlot = { timeout, elapsed: 0 };
}
setIgnoreTimeouts() {
this._ignoreTimeouts = true;
if (this._running)
this._updateTimeout(this._running);
}
interrupt() {
if (this._running)
this._running.timeoutPromise.reject(this._createTimeoutError(this._running));
}
isTimeExhaustedFor(runnable) {
const slot = runnable.fixture?.slot || runnable.slot || this._defaultSlot;
return slot.timeout > 0 && slot.elapsed >= slot.timeout - 1;
}
async withRunnable(runnable, cb) {
if (this._running)
throw new Error(`Internal error: duplicate runnable`);
const running = this._running = {
runnable,
slot: runnable.fixture?.slot || runnable.slot || this._defaultSlot,
start: (0, import_utils.monotonicTime)(),
deadline: kMaxDeadline,
timer: void 0,
timeoutPromise: new import_utils.ManualPromise()
};
let debugTitle = "";
try {
if (import_util.debugTest.enabled) {
debugTitle = runnable.fixture ? `${runnable.fixture.phase} "${runnable.fixture.title}"` : runnable.type;
const location = runnable.location ? ` at "${(0, import_util.formatLocation)(runnable.location)}"` : ``;
(0, import_util.debugTest)(`started ${debugTitle}${location}`);
}
this._updateTimeout(running);
return await Promise.race([
cb(),
running.timeoutPromise
]);
} finally {
if (running.timer)
clearTimeout(running.timer);
running.timer = void 0;
running.slot.elapsed += (0, import_utils.monotonicTime)() - running.start;
this._running = void 0;
if (import_util.debugTest.enabled)
(0, import_util.debugTest)(`finished ${debugTitle}`);
}
}
_updateTimeout(running) {
if (running.timer)
clearTimeout(running.timer);
running.timer = void 0;
if (this._ignoreTimeouts || !running.slot.timeout) {
running.deadline = kMaxDeadline;
return;
}
running.deadline = running.start + (running.slot.timeout - running.slot.elapsed);
const timeout = running.deadline - (0, import_utils.monotonicTime)() + 1;
if (timeout <= 0)
running.timeoutPromise.reject(this._createTimeoutError(running));
else
running.timer = setTimeout(() => running.timeoutPromise.reject(this._createTimeoutError(running)), timeout);
}
defaultSlot() {
return this._defaultSlot;
}
slow() {
const slot = this._running ? this._running.slot : this._defaultSlot;
slot.timeout = slot.timeout * 3;
if (this._running)
this._updateTimeout(this._running);
}
setTimeout(timeout) {
const slot = this._running ? this._running.slot : this._defaultSlot;
slot.timeout = timeout;
if (this._running)
this._updateTimeout(this._running);
}
currentSlotDeadline() {
return this._running ? this._running.deadline : kMaxDeadline;
}
currentSlotType() {
return this._running ? this._running.runnable.type : "test";
}
_createTimeoutError(running) {
let message = "";
const timeout = running.slot.timeout;
const runnable = running.runnable;
switch (runnable.type) {
case "test": {
if (runnable.fixture) {
if (runnable.fixture.phase === "setup")
message = `Test timeout of ${timeout}ms exceeded while setting up "${runnable.fixture.title}".`;
else
message = `Tearing down "${runnable.fixture.title}" exceeded the test timeout of ${timeout}ms.`;
} else {
message = `Test timeout of ${timeout}ms exceeded.`;
}
break;
}
case "afterEach":
case "beforeEach":
message = `Test timeout of ${timeout}ms exceeded while running "${runnable.type}" hook.`;
break;
case "beforeAll":
case "afterAll":
message = `"${runnable.type}" hook timeout of ${timeout}ms exceeded.`;
break;
case "teardown": {
if (runnable.fixture)
message = `Worker teardown timeout of ${timeout}ms exceeded while ${runnable.fixture.phase === "setup" ? "setting up" : "tearing down"} "${runnable.fixture.title}".`;
else
message = `Worker teardown timeout of ${timeout}ms exceeded.`;
break;
}
case "skip":
case "slow":
case "fixme":
case "fail":
message = `"${runnable.type}" modifier timeout of ${timeout}ms exceeded.`;
break;
}
const fixtureWithSlot = runnable.fixture?.slot ? runnable.fixture : void 0;
if (fixtureWithSlot)
message = `Fixture "${fixtureWithSlot.title}" timeout of ${timeout}ms exceeded during ${fixtureWithSlot.phase}.`;
message = import_utils2.colors.red(message);
const location = (fixtureWithSlot || runnable).location;
const error = new TimeoutManagerError(message);
error.name = "";
error.stack = message + (location ? `
at ${location.file}:${location.line}:${location.column}` : "");
return error;
}
}
class TimeoutManagerError extends Error {
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TimeoutManager,
TimeoutManagerError,
kMaxDeadline
});

Some files were not shown because too many files have changed in this diff Show More