First Commit
This commit is contained in:
274
node_modules/playwright/lib/common/config.js
generated
vendored
Normal file
274
node_modules/playwright/lib/common/config.js
generated
vendored
Normal 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
344
node_modules/playwright/lib/common/configLoader.js
generated
vendored
Normal 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
102
node_modules/playwright/lib/common/esmLoaderHost.js
generated
vendored
Normal 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
49
node_modules/playwright/lib/common/expectBundle.js
generated
vendored
Normal 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
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
302
node_modules/playwright/lib/common/fixtures.js
generated
vendored
Normal 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
58
node_modules/playwright/lib/common/globals.js
generated
vendored
Normal 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
60
node_modules/playwright/lib/common/ipc.js
generated
vendored
Normal 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
85
node_modules/playwright/lib/common/poolBuilder.js
generated
vendored
Normal 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
104
node_modules/playwright/lib/common/process.js
generated
vendored
Normal 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
140
node_modules/playwright/lib/common/suiteUtils.js
generated
vendored
Normal 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
321
node_modules/playwright/lib/common/test.js
generated
vendored
Normal 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
100
node_modules/playwright/lib/common/testLoader.js
generated
vendored
Normal 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
307
node_modules/playwright/lib/common/testType.js
generated
vendored
Normal 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
|
||||
});
|
Reference in New Issue
Block a user