ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / runner / testRunner.js
Source Blame History 398 lines
f7eb47b… lmata 1 "use strict";
f7eb47b… lmata 2 var __create = Object.create;
f7eb47b… lmata 3 var __defProp = Object.defineProperty;
f7eb47b… lmata 4 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
f7eb47b… lmata 5 var __getOwnPropNames = Object.getOwnPropertyNames;
f7eb47b… lmata 6 var __getProtoOf = Object.getPrototypeOf;
f7eb47b… lmata 7 var __hasOwnProp = Object.prototype.hasOwnProperty;
f7eb47b… lmata 8 var __export = (target, all) => {
f7eb47b… lmata 9 for (var name in all)
f7eb47b… lmata 10 __defProp(target, name, { get: all[name], enumerable: true });
f7eb47b… lmata 11 };
f7eb47b… lmata 12 var __copyProps = (to, from, except, desc) => {
f7eb47b… lmata 13 if (from && typeof from === "object" || typeof from === "function") {
f7eb47b… lmata 14 for (let key of __getOwnPropNames(from))
f7eb47b… lmata 15 if (!__hasOwnProp.call(to, key) && key !== except)
f7eb47b… lmata 16 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
f7eb47b… lmata 17 }
f7eb47b… lmata 18 return to;
f7eb47b… lmata 19 };
f7eb47b… lmata 20 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
f7eb47b… lmata 21 // If the importer is in node compatibility mode or this is not an ESM
f7eb47b… lmata 22 // file that has been converted to a CommonJS file using a Babel-
f7eb47b… lmata 23 // compatible transform (i.e. "__esModule" has not been set), then set
f7eb47b… lmata 24 // "default" to the CommonJS "module.exports" for node compatibility.
f7eb47b… lmata 25 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
f7eb47b… lmata 26 mod
f7eb47b… lmata 27 ));
f7eb47b… lmata 28 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
f7eb47b… lmata 29 var testRunner_exports = {};
f7eb47b… lmata 30 __export(testRunner_exports, {
f7eb47b… lmata 31 TestRunner: () => TestRunner,
f7eb47b… lmata 32 TestRunnerEvent: () => TestRunnerEvent,
f7eb47b… lmata 33 runAllTestsWithConfig: () => runAllTestsWithConfig
f7eb47b… lmata 34 });
f7eb47b… lmata 35 module.exports = __toCommonJS(testRunner_exports);
f7eb47b… lmata 36 var import_events = __toESM(require("events"));
f7eb47b… lmata 37 var import_fs = __toESM(require("fs"));
f7eb47b… lmata 38 var import_path = __toESM(require("path"));
f7eb47b… lmata 39 var import_server = require("playwright-core/lib/server");
f7eb47b… lmata 40 var import_utils = require("playwright-core/lib/utils");
f7eb47b… lmata 41 var import_configLoader = require("../common/configLoader");
f7eb47b… lmata 42 var import_fsWatcher = require("../fsWatcher");
f7eb47b… lmata 43 var import_teleReceiver = require("../isomorphic/teleReceiver");
f7eb47b… lmata 44 var import_gitCommitInfoPlugin = require("../plugins/gitCommitInfoPlugin");
f7eb47b… lmata 45 var import_webServerPlugin = require("../plugins/webServerPlugin");
f7eb47b… lmata 46 var import_base = require("../reporters/base");
f7eb47b… lmata 47 var import_internalReporter = require("../reporters/internalReporter");
f7eb47b… lmata 48 var import_compilationCache = require("../transform/compilationCache");
f7eb47b… lmata 49 var import_util = require("../util");
f7eb47b… lmata 50 var import_reporters = require("./reporters");
f7eb47b… lmata 51 var import_tasks = require("./tasks");
f7eb47b… lmata 52 var import_lastRun = require("./lastRun");
f7eb47b… lmata 53 const TestRunnerEvent = {
f7eb47b… lmata 54 TestFilesChanged: "testFilesChanged",
f7eb47b… lmata 55 TestPaused: "testPaused"
f7eb47b… lmata 56 };
f7eb47b… lmata 57 class TestRunner extends import_events.default {
f7eb47b… lmata 58 constructor(configLocation, configCLIOverrides) {
f7eb47b… lmata 59 super();
f7eb47b… lmata 60 this._watchedProjectDirs = /* @__PURE__ */ new Set();
f7eb47b… lmata 61 this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
f7eb47b… lmata 62 this._watchedTestDependencies = /* @__PURE__ */ new Set();
f7eb47b… lmata 63 this._queue = Promise.resolve();
f7eb47b… lmata 64 this._watchTestDirs = false;
f7eb47b… lmata 65 this._populateDependenciesOnList = false;
f7eb47b… lmata 66 this._startingEnv = {};
f7eb47b… lmata 67 this.configLocation = configLocation;
f7eb47b… lmata 68 this._configCLIOverrides = configCLIOverrides;
f7eb47b… lmata 69 this._watcher = new import_fsWatcher.Watcher((events) => {
f7eb47b… lmata 70 const collector = /* @__PURE__ */ new Set();
f7eb47b… lmata 71 events.forEach((f) => (0, import_compilationCache.collectAffectedTestFiles)(f.file, collector));
f7eb47b… lmata 72 this.emit(TestRunnerEvent.TestFilesChanged, [...collector]);
f7eb47b… lmata 73 });
f7eb47b… lmata 74 }
f7eb47b… lmata 75 async initialize(params) {
f7eb47b… lmata 76 (0, import_utils.setPlaywrightTestProcessEnv)();
f7eb47b… lmata 77 this._watchTestDirs = !!params.watchTestDirs;
f7eb47b… lmata 78 this._populateDependenciesOnList = !!params.populateDependenciesOnList;
f7eb47b… lmata 79 this._startingEnv = { ...process.env };
f7eb47b… lmata 80 }
f7eb47b… lmata 81 resizeTerminal(params) {
f7eb47b… lmata 82 process.stdout.columns = params.cols;
f7eb47b… lmata 83 process.stdout.rows = params.rows;
f7eb47b… lmata 84 process.stderr.columns = params.cols;
f7eb47b… lmata 85 process.stderr.rows = params.rows;
f7eb47b… lmata 86 }
f7eb47b… lmata 87 hasSomeBrowsers() {
f7eb47b… lmata 88 for (const browserName of ["chromium", "webkit", "firefox"]) {
f7eb47b… lmata 89 try {
f7eb47b… lmata 90 import_server.registry.findExecutable(browserName).executablePathOrDie("javascript");
f7eb47b… lmata 91 return true;
f7eb47b… lmata 92 } catch {
f7eb47b… lmata 93 }
f7eb47b… lmata 94 }
f7eb47b… lmata 95 return false;
f7eb47b… lmata 96 }
f7eb47b… lmata 97 async installBrowsers() {
f7eb47b… lmata 98 const executables = import_server.registry.defaultExecutables();
f7eb47b… lmata 99 await import_server.registry.install(executables);
f7eb47b… lmata 100 }
f7eb47b… lmata 101 async loadConfig() {
f7eb47b… lmata 102 const { config, error } = await this._loadConfig(this._configCLIOverrides);
f7eb47b… lmata 103 if (config)
f7eb47b… lmata 104 return config;
f7eb47b… lmata 105 throw new Error("Failed to load config: " + (error ? error.message : "Unknown error"));
f7eb47b… lmata 106 }
f7eb47b… lmata 107 async runGlobalSetup(userReporters) {
f7eb47b… lmata 108 await this.runGlobalTeardown();
f7eb47b… lmata 109 const reporter = new import_internalReporter.InternalReporter(userReporters);
f7eb47b… lmata 110 const config = await this._loadConfigOrReportError(reporter, this._configCLIOverrides);
f7eb47b… lmata 111 if (!config)
f7eb47b… lmata 112 return { status: "failed", env: [] };
f7eb47b… lmata 113 const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
f7eb47b… lmata 114 ...(0, import_tasks.createGlobalSetupTasks)(config)
f7eb47b… lmata 115 ]);
f7eb47b… lmata 116 const env = [];
f7eb47b… lmata 117 for (const key of /* @__PURE__ */ new Set([...Object.keys(process.env), ...Object.keys(this._startingEnv)])) {
f7eb47b… lmata 118 if (this._startingEnv[key] !== process.env[key])
f7eb47b… lmata 119 env.push([key, process.env[key] ?? null]);
f7eb47b… lmata 120 }
f7eb47b… lmata 121 if (status !== "passed")
f7eb47b… lmata 122 await cleanup();
f7eb47b… lmata 123 else
f7eb47b… lmata 124 this._globalSetup = { cleanup };
f7eb47b… lmata 125 return { status, env };
f7eb47b… lmata 126 }
f7eb47b… lmata 127 async runGlobalTeardown() {
f7eb47b… lmata 128 const globalSetup = this._globalSetup;
f7eb47b… lmata 129 const status = await globalSetup?.cleanup();
f7eb47b… lmata 130 this._globalSetup = void 0;
f7eb47b… lmata 131 return { status };
f7eb47b… lmata 132 }
f7eb47b… lmata 133 async startDevServer(userReporter, mode) {
f7eb47b… lmata 134 await this.stopDevServer();
f7eb47b… lmata 135 const reporter = new import_internalReporter.InternalReporter([userReporter]);
f7eb47b… lmata 136 const config = await this._loadConfigOrReportError(reporter);
f7eb47b… lmata 137 if (!config)
f7eb47b… lmata 138 return { status: "failed" };
f7eb47b… lmata 139 const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
f7eb47b… lmata 140 ...(0, import_tasks.createPluginSetupTasks)(config),
f7eb47b… lmata 141 (0, import_tasks.createLoadTask)(mode, { failOnLoadErrors: true, filterOnly: false }),
f7eb47b… lmata 142 (0, import_tasks.createStartDevServerTask)()
f7eb47b… lmata 143 ]);
f7eb47b… lmata 144 if (status !== "passed")
f7eb47b… lmata 145 await cleanup();
f7eb47b… lmata 146 else
f7eb47b… lmata 147 this._devServer = { cleanup };
f7eb47b… lmata 148 return { status };
f7eb47b… lmata 149 }
f7eb47b… lmata 150 async stopDevServer() {
f7eb47b… lmata 151 const devServer = this._devServer;
f7eb47b… lmata 152 const status = await devServer?.cleanup();
f7eb47b… lmata 153 this._devServer = void 0;
f7eb47b… lmata 154 return { status };
f7eb47b… lmata 155 }
f7eb47b… lmata 156 async clearCache(userReporter) {
f7eb47b… lmata 157 const reporter = new import_internalReporter.InternalReporter(userReporter ? [userReporter] : []);
f7eb47b… lmata 158 const config = await this._loadConfigOrReportError(reporter);
f7eb47b… lmata 159 if (!config)
f7eb47b… lmata 160 return { status: "failed" };
f7eb47b… lmata 161 const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
f7eb47b… lmata 162 ...(0, import_tasks.createPluginSetupTasks)(config),
f7eb47b… lmata 163 (0, import_tasks.createClearCacheTask)(config)
f7eb47b… lmata 164 ]);
f7eb47b… lmata 165 return { status };
f7eb47b… lmata 166 }
f7eb47b… lmata 167 async listFiles(userReporter, projects) {
f7eb47b… lmata 168 const reporter = new import_internalReporter.InternalReporter([userReporter]);
f7eb47b… lmata 169 const config = await this._loadConfigOrReportError(reporter);
f7eb47b… lmata 170 if (!config)
f7eb47b… lmata 171 return { status: "failed" };
f7eb47b… lmata 172 config.cliProjectFilter = projects?.length ? projects : void 0;
f7eb47b… lmata 173 const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
f7eb47b… lmata 174 (0, import_tasks.createListFilesTask)(),
f7eb47b… lmata 175 (0, import_tasks.createReportBeginTask)()
f7eb47b… lmata 176 ]);
f7eb47b… lmata 177 return { status };
f7eb47b… lmata 178 }
f7eb47b… lmata 179 async listTests(userReporter, params) {
f7eb47b… lmata 180 let result;
f7eb47b… lmata 181 this._queue = this._queue.then(async () => {
f7eb47b… lmata 182 const { config, status } = await this._innerListTests(userReporter, params);
f7eb47b… lmata 183 if (config)
f7eb47b… lmata 184 await this._updateWatchedDirs(config);
f7eb47b… lmata 185 result = { status };
f7eb47b… lmata 186 }).catch(printInternalError);
f7eb47b… lmata 187 await this._queue;
f7eb47b… lmata 188 return result;
f7eb47b… lmata 189 }
f7eb47b… lmata 190 async _innerListTests(userReporter, params) {
f7eb47b… lmata 191 const overrides = {
f7eb47b… lmata 192 ...this._configCLIOverrides,
f7eb47b… lmata 193 repeatEach: 1,
f7eb47b… lmata 194 retries: 0
f7eb47b… lmata 195 };
f7eb47b… lmata 196 const reporter = new import_internalReporter.InternalReporter([userReporter]);
f7eb47b… lmata 197 const config = await this._loadConfigOrReportError(reporter, overrides);
f7eb47b… lmata 198 if (!config)
f7eb47b… lmata 199 return { status: "failed" };
f7eb47b… lmata 200 config.cliArgs = params.locations || [];
f7eb47b… lmata 201 config.cliGrep = params.grep;
f7eb47b… lmata 202 config.cliGrepInvert = params.grepInvert;
f7eb47b… lmata 203 config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
f7eb47b… lmata 204 config.cliListOnly = true;
f7eb47b… lmata 205 const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
f7eb47b… lmata 206 (0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
f7eb47b… lmata 207 (0, import_tasks.createReportBeginTask)()
f7eb47b… lmata 208 ]);
f7eb47b… lmata 209 return { config, status };
f7eb47b… lmata 210 }
f7eb47b… lmata 211 async _updateWatchedDirs(config) {
f7eb47b… lmata 212 this._watchedProjectDirs = /* @__PURE__ */ new Set();
f7eb47b… lmata 213 this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
f7eb47b… lmata 214 for (const p of config.projects) {
f7eb47b… lmata 215 this._watchedProjectDirs.add(p.project.testDir);
f7eb47b… lmata 216 this._ignoredProjectOutputs.add(p.project.outputDir);
f7eb47b… lmata 217 }
f7eb47b… lmata 218 const result = await resolveCtDirs(config);
f7eb47b… lmata 219 if (result) {
f7eb47b… lmata 220 this._watchedProjectDirs.add(result.templateDir);
f7eb47b… lmata 221 this._ignoredProjectOutputs.add(result.outDir);
f7eb47b… lmata 222 }
f7eb47b… lmata 223 if (this._watchTestDirs)
f7eb47b… lmata 224 await this._updateWatcher(false);
f7eb47b… lmata 225 }
f7eb47b… lmata 226 async _updateWatcher(reportPending) {
f7eb47b… lmata 227 await this._watcher.update([...this._watchedProjectDirs, ...this._watchedTestDependencies], [...this._ignoredProjectOutputs], reportPending);
f7eb47b… lmata 228 }
f7eb47b… lmata 229 async runTests(userReporter, params) {
f7eb47b… lmata 230 let result = { status: "passed" };
f7eb47b… lmata 231 this._queue = this._queue.then(async () => {
f7eb47b… lmata 232 result = await this._innerRunTests(userReporter, params).catch((e) => {
f7eb47b… lmata 233 printInternalError(e);
f7eb47b… lmata 234 return { status: "failed" };
f7eb47b… lmata 235 });
f7eb47b… lmata 236 });
f7eb47b… lmata 237 await this._queue;
f7eb47b… lmata 238 return result;
f7eb47b… lmata 239 }
f7eb47b… lmata 240 async _innerRunTests(userReporter, params) {
f7eb47b… lmata 241 await this.stopTests();
f7eb47b… lmata 242 const overrides = {
f7eb47b… lmata 243 ...this._configCLIOverrides,
f7eb47b… lmata 244 repeatEach: 1,
f7eb47b… lmata 245 retries: 0,
f7eb47b… lmata 246 timeout: params.timeout,
f7eb47b… lmata 247 preserveOutputDir: true,
f7eb47b… lmata 248 reporter: params.reporters ? params.reporters.map((r) => [r]) : void 0,
f7eb47b… lmata 249 use: {
f7eb47b… lmata 250 ...this._configCLIOverrides.use,
f7eb47b… lmata 251 ...params.trace === "on" ? { trace: { mode: "on", sources: false, _live: true } } : {},
f7eb47b… lmata 252 ...params.trace === "off" ? { trace: "off" } : {},
f7eb47b… lmata 253 ...params.video === "on" || params.video === "off" ? { video: params.video } : {},
f7eb47b… lmata 254 ...params.headed !== void 0 ? { headless: !params.headed } : {},
f7eb47b… lmata 255 _optionContextReuseMode: params.reuseContext ? "when-possible" : void 0,
f7eb47b… lmata 256 _optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : void 0,
f7eb47b… lmata 257 actionTimeout: params.actionTimeout
f7eb47b… lmata 258 },
f7eb47b… lmata 259 ...params.updateSnapshots ? { updateSnapshots: params.updateSnapshots } : {},
f7eb47b… lmata 260 ...params.updateSourceMethod ? { updateSourceMethod: params.updateSourceMethod } : {},
f7eb47b… lmata 261 ...params.runAgents ? { runAgents: params.runAgents } : {},
f7eb47b… lmata 262 ...params.workers ? { workers: params.workers } : {}
f7eb47b… lmata 263 };
f7eb47b… lmata 264 const config = await this._loadConfigOrReportError(new import_internalReporter.InternalReporter([userReporter]), overrides);
f7eb47b… lmata 265 if (!config)
f7eb47b… lmata 266 return { status: "failed" };
f7eb47b… lmata 267 config.cliListOnly = false;
f7eb47b… lmata 268 config.cliPassWithNoTests = true;
f7eb47b… lmata 269 config.cliArgs = params.locations;
f7eb47b… lmata 270 config.cliGrep = params.grep;
f7eb47b… lmata 271 config.cliGrepInvert = params.grepInvert;
f7eb47b… lmata 272 config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
f7eb47b… lmata 273 config.preOnlyTestFilters = [];
f7eb47b… lmata 274 if (params.testIds) {
f7eb47b… lmata 275 const testIdSet = new Set(params.testIds);
f7eb47b… lmata 276 config.preOnlyTestFilters.push((test) => testIdSet.has(test.id));
f7eb47b… lmata 277 }
f7eb47b… lmata 278 const configReporters = params.disableConfigReporters ? [] : await (0, import_reporters.createReporters)(config, "test");
f7eb47b… lmata 279 const reporter = new import_internalReporter.InternalReporter([...configReporters, userReporter]);
f7eb47b… lmata 280 const stop = new import_utils.ManualPromise();
f7eb47b… lmata 281 const tasks = [
f7eb47b… lmata 282 (0, import_tasks.createApplyRebaselinesTask)(),
f7eb47b… lmata 283 (0, import_tasks.createLoadTask)("out-of-process", { filterOnly: true, failOnLoadErrors: !!params.failOnLoadErrors, doNotRunDepsOutsideProjectFilter: params.doNotRunDepsOutsideProjectFilter }),
f7eb47b… lmata 284 ...(0, import_tasks.createRunTestsTasks)(config)
f7eb47b… lmata 285 ];
f7eb47b… lmata 286 const testRun = new import_tasks.TestRun(config, reporter, { pauseOnError: params.pauseOnError, pauseAtEnd: params.pauseAtEnd });
f7eb47b… lmata 287 testRun.failureTracker.onTestPaused = (params2) => this.emit(TestRunnerEvent.TestPaused, params2);
f7eb47b… lmata 288 const run = (0, import_tasks.runTasks)(testRun, tasks, 0, stop).then(async (status) => {
f7eb47b… lmata 289 this._testRun = void 0;
f7eb47b… lmata 290 return status;
f7eb47b… lmata 291 });
f7eb47b… lmata 292 this._testRun = { run, stop };
f7eb47b… lmata 293 return { status: await run };
f7eb47b… lmata 294 }
f7eb47b… lmata 295 async watch(fileNames) {
f7eb47b… lmata 296 this._watchedTestDependencies = /* @__PURE__ */ new Set();
f7eb47b… lmata 297 for (const fileName of fileNames) {
f7eb47b… lmata 298 this._watchedTestDependencies.add(fileName);
f7eb47b… lmata 299 (0, import_compilationCache.dependenciesForTestFile)(fileName).forEach((file) => this._watchedTestDependencies.add(file));
f7eb47b… lmata 300 }
f7eb47b… lmata 301 await this._updateWatcher(true);
f7eb47b… lmata 302 }
f7eb47b… lmata 303 async findRelatedTestFiles(files, userReporter) {
f7eb47b… lmata 304 const errorReporter = (0, import_reporters.createErrorCollectingReporter)(import_base.internalScreen);
f7eb47b… lmata 305 const reporter = new import_internalReporter.InternalReporter(userReporter ? [userReporter, errorReporter] : [errorReporter]);
f7eb47b… lmata 306 const config = await this._loadConfigOrReportError(reporter);
f7eb47b… lmata 307 if (!config)
f7eb47b… lmata 308 return { errors: errorReporter.errors(), testFiles: [] };
f7eb47b… lmata 309 const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
f7eb47b… lmata 310 ...(0, import_tasks.createPluginSetupTasks)(config),
f7eb47b… lmata 311 (0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false, populateDependencies: true })
f7eb47b… lmata 312 ]);
f7eb47b… lmata 313 if (status !== "passed")
f7eb47b… lmata 314 return { errors: errorReporter.errors(), testFiles: [] };
f7eb47b… lmata 315 return { testFiles: (0, import_compilationCache.affectedTestFiles)(files) };
f7eb47b… lmata 316 }
f7eb47b… lmata 317 async stopTests() {
f7eb47b… lmata 318 this._testRun?.stop?.resolve();
f7eb47b… lmata 319 await this._testRun?.run;
f7eb47b… lmata 320 }
f7eb47b… lmata 321 async closeGracefully() {
f7eb47b… lmata 322 (0, import_utils.gracefullyProcessExitDoNotHang)(0);
f7eb47b… lmata 323 }
f7eb47b… lmata 324 async stop() {
f7eb47b… lmata 325 await this.runGlobalTeardown();
f7eb47b… lmata 326 }
f7eb47b… lmata 327 async _loadConfig(overrides) {
f7eb47b… lmata 328 try {
f7eb47b… lmata 329 const config = await (0, import_configLoader.loadConfig)(this.configLocation, overrides);
f7eb47b… lmata 330 if (!this._plugins) {
f7eb47b… lmata 331 (0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
f7eb47b… lmata 332 (0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
f7eb47b… lmata 333 this._plugins = config.plugins || [];
f7eb47b… lmata 334 } else {
f7eb47b… lmata 335 config.plugins.splice(0, config.plugins.length, ...this._plugins);
f7eb47b… lmata 336 }
f7eb47b… lmata 337 return { config };
f7eb47b… lmata 338 } catch (e) {
f7eb47b… lmata 339 return { config: null, error: (0, import_util.serializeError)(e) };
f7eb47b… lmata 340 }
f7eb47b… lmata 341 }
f7eb47b… lmata 342 async _loadConfigOrReportError(reporter, overrides) {
f7eb47b… lmata 343 const { config, error } = await this._loadConfig(overrides);
f7eb47b… lmata 344 if (config)
f7eb47b… lmata 345 return config;
f7eb47b… lmata 346 reporter.onConfigure(import_teleReceiver.baseFullConfig);
f7eb47b… lmata 347 reporter.onError(error);
f7eb47b… lmata 348 await reporter.onEnd({ status: "failed" });
f7eb47b… lmata 349 await reporter.onExit();
f7eb47b… lmata 350 return null;
f7eb47b… lmata 351 }
f7eb47b… lmata 352 }
f7eb47b… lmata 353 function printInternalError(e) {
f7eb47b… lmata 354 console.error("Internal error:", e);
f7eb47b… lmata 355 }
f7eb47b… lmata 356 async function resolveCtDirs(config) {
f7eb47b… lmata 357 const use = config.config.projects[0].use;
f7eb47b… lmata 358 const relativeTemplateDir = use.ctTemplateDir || "playwright";
f7eb47b… lmata 359 const templateDir = await import_fs.default.promises.realpath(import_path.default.normalize(import_path.default.join(config.configDir, relativeTemplateDir))).catch(() => void 0);
f7eb47b… lmata 360 if (!templateDir)
f7eb47b… lmata 361 return null;
f7eb47b… lmata 362 const outDir = use.ctCacheDir ? import_path.default.resolve(config.configDir, use.ctCacheDir) : import_path.default.resolve(templateDir, ".cache");
f7eb47b… lmata 363 return {
f7eb47b… lmata 364 outDir,
f7eb47b… lmata 365 templateDir
f7eb47b… lmata 366 };
f7eb47b… lmata 367 }
f7eb47b… lmata 368 async function runAllTestsWithConfig(config) {
f7eb47b… lmata 369 (0, import_utils.setPlaywrightTestProcessEnv)();
f7eb47b… lmata 370 const listOnly = config.cliListOnly;
f7eb47b… lmata 371 (0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
f7eb47b… lmata 372 (0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
f7eb47b… lmata 373 const reporters = await (0, import_reporters.createReporters)(config, listOnly ? "list" : "test");
f7eb47b… lmata 374 const lastRun = new import_lastRun.LastRunReporter(config);
f7eb47b… lmata 375 if (config.cliLastFailed)
f7eb47b… lmata 376 await lastRun.filterLastFailed();
f7eb47b… lmata 377 const reporter = new import_internalReporter.InternalReporter([...reporters, lastRun]);
f7eb47b… lmata 378 const tasks = listOnly ? [
f7eb47b… lmata 379 (0, import_tasks.createLoadTask)("in-process", { failOnLoadErrors: true, filterOnly: false }),
f7eb47b… lmata 380 (0, import_tasks.createReportBeginTask)()
f7eb47b… lmata 381 ] : [
f7eb47b… lmata 382 (0, import_tasks.createApplyRebaselinesTask)(),
f7eb47b… lmata 383 ...(0, import_tasks.createGlobalSetupTasks)(config),
f7eb47b… lmata 384 (0, import_tasks.createLoadTask)("in-process", { filterOnly: true, failOnLoadErrors: true }),
f7eb47b… lmata 385 ...(0, import_tasks.createRunTestsTasks)(config)
f7eb47b… lmata 386 ];
f7eb47b… lmata 387 const testRun = new import_tasks.TestRun(config, reporter, { pauseAtEnd: config.configCLIOverrides.pause, pauseOnError: config.configCLIOverrides.pause });
f7eb47b… lmata 388 const status = await (0, import_tasks.runTasks)(testRun, tasks, config.config.globalTimeout);
f7eb47b… lmata 389 await new Promise((resolve) => process.stdout.write("", () => resolve()));
f7eb47b… lmata 390 await new Promise((resolve) => process.stderr.write("", () => resolve()));
f7eb47b… lmata 391 return status;
f7eb47b… lmata 392 }
f7eb47b… lmata 393 // Annotate the CommonJS export names for ESM import in node:
f7eb47b… lmata 394 0 && (module.exports = {
f7eb47b… lmata 395 TestRunner,
f7eb47b… lmata 396 TestRunnerEvent,
f7eb47b… lmata 397 runAllTestsWithConfig
f7eb47b… lmata 398 });

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button