playwright 1.54.1 → 1.56.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/ThirdPartyNotices.txt +2727 -434
- package/lib/agents/generateAgents.js +263 -0
- package/lib/agents/generator.md +102 -0
- package/lib/agents/healer.md +78 -0
- package/lib/agents/planner.md +135 -0
- package/lib/common/config.js +3 -1
- package/lib/common/configLoader.js +2 -1
- package/lib/common/expectBundle.js +3 -0
- package/lib/common/expectBundleImpl.js +51 -51
- package/lib/common/fixtures.js +1 -1
- package/lib/common/suiteUtils.js +0 -9
- package/lib/index.js +127 -115
- package/lib/isomorphic/testTree.js +35 -8
- package/lib/matchers/expect.js +6 -7
- package/lib/matchers/matcherHint.js +43 -15
- package/lib/matchers/matchers.js +10 -4
- package/lib/matchers/toBeTruthy.js +16 -14
- package/lib/matchers/toEqual.js +18 -13
- package/lib/matchers/toHaveURL.js +12 -27
- package/lib/matchers/toMatchAriaSnapshot.js +26 -31
- package/lib/matchers/toMatchSnapshot.js +15 -12
- package/lib/matchers/toMatchText.js +29 -35
- package/lib/mcp/browser/actions.d.js +16 -0
- package/lib/mcp/browser/browserContextFactory.js +296 -0
- package/lib/mcp/browser/browserServerBackend.js +76 -0
- package/lib/mcp/browser/codegen.js +66 -0
- package/lib/mcp/browser/config.js +383 -0
- package/lib/mcp/browser/context.js +284 -0
- package/lib/mcp/browser/response.js +228 -0
- package/lib/mcp/browser/sessionLog.js +160 -0
- package/lib/mcp/browser/tab.js +277 -0
- package/lib/mcp/browser/tools/common.js +63 -0
- package/lib/mcp/browser/tools/console.js +44 -0
- package/lib/mcp/browser/tools/dialogs.js +60 -0
- package/lib/mcp/browser/tools/evaluate.js +70 -0
- package/lib/mcp/browser/tools/files.js +58 -0
- package/lib/mcp/browser/tools/form.js +74 -0
- package/lib/mcp/browser/tools/install.js +69 -0
- package/lib/mcp/browser/tools/keyboard.js +85 -0
- package/lib/mcp/browser/tools/mouse.js +107 -0
- package/lib/mcp/browser/tools/navigate.js +62 -0
- package/lib/mcp/browser/tools/network.js +54 -0
- package/lib/mcp/browser/tools/pdf.js +59 -0
- package/lib/mcp/browser/tools/screenshot.js +88 -0
- package/lib/mcp/browser/tools/snapshot.js +182 -0
- package/lib/mcp/browser/tools/tabs.js +67 -0
- package/lib/mcp/browser/tools/tool.js +49 -0
- package/lib/mcp/browser/tools/tracing.js +74 -0
- package/lib/mcp/browser/tools/utils.js +100 -0
- package/lib/mcp/browser/tools/verify.js +154 -0
- package/lib/mcp/browser/tools/wait.js +63 -0
- package/lib/mcp/browser/tools.js +80 -0
- package/lib/mcp/browser/watchdog.js +44 -0
- package/lib/mcp/config.d.js +16 -0
- package/lib/mcp/extension/cdpRelay.js +351 -0
- package/lib/mcp/extension/extensionContextFactory.js +75 -0
- package/lib/mcp/extension/protocol.js +28 -0
- package/lib/mcp/index.js +61 -0
- package/lib/mcp/log.js +35 -0
- package/lib/mcp/program.js +96 -0
- package/lib/mcp/sdk/bundle.js +81 -0
- package/lib/mcp/sdk/exports.js +32 -0
- package/lib/mcp/sdk/http.js +180 -0
- package/lib/mcp/sdk/inProcessTransport.js +71 -0
- package/lib/mcp/sdk/mdb.js +208 -0
- package/lib/mcp/sdk/proxyBackend.js +128 -0
- package/lib/mcp/sdk/server.js +190 -0
- package/lib/mcp/sdk/tool.js +51 -0
- package/lib/mcp/test/browserBackend.js +98 -0
- package/lib/mcp/test/generatorTools.js +122 -0
- package/lib/mcp/test/plannerTools.js +46 -0
- package/lib/mcp/test/seed.js +72 -0
- package/lib/mcp/test/streams.js +39 -0
- package/lib/mcp/test/testBackend.js +97 -0
- package/lib/mcp/test/testContext.js +176 -0
- package/lib/mcp/test/testTool.js +30 -0
- package/lib/mcp/test/testTools.js +115 -0
- package/lib/mcpBundleImpl.js +41 -0
- package/lib/plugins/webServerPlugin.js +2 -0
- package/lib/program.js +77 -57
- package/lib/reporters/base.js +34 -29
- package/lib/reporters/dot.js +11 -11
- package/lib/reporters/github.js +2 -1
- package/lib/reporters/html.js +58 -41
- package/lib/reporters/internalReporter.js +2 -1
- package/lib/reporters/line.js +15 -15
- package/lib/reporters/list.js +24 -19
- package/lib/reporters/listModeReporter.js +69 -0
- package/lib/reporters/markdown.js +3 -3
- package/lib/reporters/merge.js +3 -1
- package/lib/reporters/teleEmitter.js +3 -1
- package/lib/runner/dispatcher.js +9 -2
- package/lib/runner/failureTracker.js +12 -2
- package/lib/runner/lastRun.js +7 -4
- package/lib/runner/loadUtils.js +46 -12
- package/lib/runner/projectUtils.js +8 -2
- package/lib/runner/reporters.js +7 -32
- package/lib/runner/tasks.js +20 -10
- package/lib/runner/testRunner.js +390 -0
- package/lib/runner/testServer.js +57 -276
- package/lib/runner/watchMode.js +5 -1
- package/lib/runner/workerHost.js +8 -6
- package/lib/transform/babelBundleImpl.js +179 -195
- package/lib/transform/compilationCache.js +22 -5
- package/lib/transform/transform.js +1 -1
- package/lib/util.js +12 -35
- package/lib/utilsBundleImpl.js +1 -1
- package/lib/worker/fixtureRunner.js +7 -2
- package/lib/worker/testInfo.js +76 -45
- package/lib/worker/testTracing.js +8 -7
- package/lib/worker/workerMain.js +12 -3
- package/package.json +10 -2
- package/types/test.d.ts +63 -44
- package/types/testReporter.d.ts +1 -1
- package/lib/runner/runner.js +0 -110
package/lib/runner/tasks.js
CHANGED
|
@@ -60,14 +60,15 @@ var import_compilationCache = require("../transform/compilationCache");
|
|
|
60
60
|
var import_util2 = require("../util");
|
|
61
61
|
const readDirAsync = (0, import_util.promisify)(import_fs.default.readdir);
|
|
62
62
|
class TestRun {
|
|
63
|
-
constructor(config, reporter) {
|
|
63
|
+
constructor(config, reporter, options) {
|
|
64
64
|
this.rootSuite = void 0;
|
|
65
65
|
this.phases = [];
|
|
66
66
|
this.projectFiles = /* @__PURE__ */ new Map();
|
|
67
67
|
this.projectSuites = /* @__PURE__ */ new Map();
|
|
68
|
+
this.topLevelProjects = [];
|
|
68
69
|
this.config = config;
|
|
69
70
|
this.reporter = reporter;
|
|
70
|
-
this.failureTracker = new import_failureTracker.FailureTracker(config);
|
|
71
|
+
this.failureTracker = new import_failureTracker.FailureTracker(config, options);
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
async function runTasks(testRun, tasks, globalTimeout, cancelPromise) {
|
|
@@ -98,7 +99,7 @@ async function finishTaskRun(testRun, status) {
|
|
|
98
99
|
}
|
|
99
100
|
function createGlobalSetupTasks(config) {
|
|
100
101
|
const tasks = [];
|
|
101
|
-
if (!config.configCLIOverrides.preserveOutputDir
|
|
102
|
+
if (!config.configCLIOverrides.preserveOutputDir)
|
|
102
103
|
tasks.push(createRemoveOutputDirsTask());
|
|
103
104
|
tasks.push(
|
|
104
105
|
...createPluginSetupTasks(config),
|
|
@@ -214,8 +215,9 @@ function createListFilesTask() {
|
|
|
214
215
|
return {
|
|
215
216
|
title: "load tests",
|
|
216
217
|
setup: async (testRun, errors) => {
|
|
217
|
-
|
|
218
|
-
testRun.
|
|
218
|
+
const { rootSuite, topLevelProjects } = await (0, import_loadUtils.createRootSuite)(testRun, errors, false);
|
|
219
|
+
testRun.rootSuite = rootSuite;
|
|
220
|
+
testRun.failureTracker.onRootSuite(rootSuite, topLevelProjects);
|
|
219
221
|
await (0, import_loadUtils.collectProjectsAndTestFiles)(testRun, false);
|
|
220
222
|
for (const [project, files] of testRun.projectFiles) {
|
|
221
223
|
const projectSuite = new import_test.Suite(project.project.name, "project");
|
|
@@ -243,14 +245,22 @@ function createLoadTask(mode, options) {
|
|
|
243
245
|
for (const plugin of testRun.config.plugins)
|
|
244
246
|
await plugin.instance?.populateDependencies?.();
|
|
245
247
|
}
|
|
246
|
-
let cliOnlyChangedMatcher = void 0;
|
|
247
248
|
if (testRun.config.cliOnlyChanged) {
|
|
248
249
|
const changedFiles = await (0, import_vcs.detectChangedTestFiles)(testRun.config.cliOnlyChanged, testRun.config.configDir);
|
|
249
|
-
|
|
250
|
+
testRun.config.preOnlyTestFilters.push((test) => changedFiles.has(test.location.file));
|
|
250
251
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
if (testRun.config.cliTestList) {
|
|
253
|
+
const testListFilter = await (0, import_loadUtils.loadTestList)(testRun.config, testRun.config.cliTestList);
|
|
254
|
+
testRun.config.preOnlyTestFilters.push(testListFilter);
|
|
255
|
+
}
|
|
256
|
+
if (testRun.config.cliTestListInvert) {
|
|
257
|
+
const testListInvertFilter = await (0, import_loadUtils.loadTestList)(testRun.config, testRun.config.cliTestListInvert);
|
|
258
|
+
testRun.config.preOnlyTestFilters.push((test) => !testListInvertFilter(test));
|
|
259
|
+
}
|
|
260
|
+
const { rootSuite, topLevelProjects } = await (0, import_loadUtils.createRootSuite)(testRun, options.failOnLoadErrors ? errors : softErrors, !!options.filterOnly);
|
|
261
|
+
testRun.rootSuite = rootSuite;
|
|
262
|
+
testRun.failureTracker.onRootSuite(rootSuite, topLevelProjects);
|
|
263
|
+
if (options.failOnLoadErrors && !testRun.rootSuite.allTests().length && !testRun.config.cliPassWithNoTests && !testRun.config.config.shard && !testRun.config.cliOnlyChanged && !testRun.config.cliTestList && !testRun.config.cliTestListInvert) {
|
|
254
264
|
if (testRun.config.cliArgs.length) {
|
|
255
265
|
throw new Error([
|
|
256
266
|
`No tests found.`,
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var testRunner_exports = {};
|
|
30
|
+
__export(testRunner_exports, {
|
|
31
|
+
TestRunner: () => TestRunner,
|
|
32
|
+
TestRunnerEvent: () => TestRunnerEvent,
|
|
33
|
+
runAllTestsWithConfig: () => runAllTestsWithConfig
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(testRunner_exports);
|
|
36
|
+
var import_events = __toESM(require("events"));
|
|
37
|
+
var import_fs = __toESM(require("fs"));
|
|
38
|
+
var import_path = __toESM(require("path"));
|
|
39
|
+
var import_server = require("playwright-core/lib/server");
|
|
40
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
41
|
+
var import_configLoader = require("../common/configLoader");
|
|
42
|
+
var import_fsWatcher = require("../fsWatcher");
|
|
43
|
+
var import_teleReceiver = require("../isomorphic/teleReceiver");
|
|
44
|
+
var import_gitCommitInfoPlugin = require("../plugins/gitCommitInfoPlugin");
|
|
45
|
+
var import_webServerPlugin = require("../plugins/webServerPlugin");
|
|
46
|
+
var import_base = require("../reporters/base");
|
|
47
|
+
var import_internalReporter = require("../reporters/internalReporter");
|
|
48
|
+
var import_compilationCache = require("../transform/compilationCache");
|
|
49
|
+
var import_util = require("../util");
|
|
50
|
+
var import_reporters = require("./reporters");
|
|
51
|
+
var import_tasks = require("./tasks");
|
|
52
|
+
var import_lastRun = require("./lastRun");
|
|
53
|
+
const TestRunnerEvent = {
|
|
54
|
+
TestFilesChanged: "testFilesChanged"
|
|
55
|
+
};
|
|
56
|
+
class TestRunner extends import_events.default {
|
|
57
|
+
constructor(configLocation, configCLIOverrides) {
|
|
58
|
+
super();
|
|
59
|
+
this._watchedProjectDirs = /* @__PURE__ */ new Set();
|
|
60
|
+
this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
|
|
61
|
+
this._watchedTestDependencies = /* @__PURE__ */ new Set();
|
|
62
|
+
this._queue = Promise.resolve();
|
|
63
|
+
this._watchTestDirs = false;
|
|
64
|
+
this._populateDependenciesOnList = false;
|
|
65
|
+
this.configLocation = configLocation;
|
|
66
|
+
this._configCLIOverrides = configCLIOverrides;
|
|
67
|
+
this._watcher = new import_fsWatcher.Watcher((events) => {
|
|
68
|
+
const collector = /* @__PURE__ */ new Set();
|
|
69
|
+
events.forEach((f) => (0, import_compilationCache.collectAffectedTestFiles)(f.file, collector));
|
|
70
|
+
this.emit(TestRunnerEvent.TestFilesChanged, [...collector]);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async initialize(params) {
|
|
74
|
+
(0, import_utils.setPlaywrightTestProcessEnv)();
|
|
75
|
+
this._watchTestDirs = !!params.watchTestDirs;
|
|
76
|
+
this._populateDependenciesOnList = !!params.populateDependenciesOnList;
|
|
77
|
+
}
|
|
78
|
+
resizeTerminal(params) {
|
|
79
|
+
process.stdout.columns = params.cols;
|
|
80
|
+
process.stdout.rows = params.rows;
|
|
81
|
+
process.stderr.columns = params.cols;
|
|
82
|
+
process.stderr.rows = params.rows;
|
|
83
|
+
}
|
|
84
|
+
hasSomeBrowsers() {
|
|
85
|
+
for (const browserName of ["chromium", "webkit", "firefox"]) {
|
|
86
|
+
try {
|
|
87
|
+
import_server.registry.findExecutable(browserName).executablePathOrDie("javascript");
|
|
88
|
+
return true;
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
async installBrowsers() {
|
|
95
|
+
const executables = import_server.registry.defaultExecutables();
|
|
96
|
+
await import_server.registry.install(executables, false);
|
|
97
|
+
}
|
|
98
|
+
async loadConfig() {
|
|
99
|
+
const { config, error } = await this._loadConfig(this._configCLIOverrides);
|
|
100
|
+
if (config)
|
|
101
|
+
return config;
|
|
102
|
+
throw new Error("Failed to load config: " + (error ? error.message : "Unknown error"));
|
|
103
|
+
}
|
|
104
|
+
async runGlobalSetup(userReporters) {
|
|
105
|
+
await this.runGlobalTeardown();
|
|
106
|
+
const reporter = new import_internalReporter.InternalReporter(userReporters);
|
|
107
|
+
const config = await this._loadConfigOrReportError(reporter, this._configCLIOverrides);
|
|
108
|
+
if (!config)
|
|
109
|
+
return { status: "failed" };
|
|
110
|
+
const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
|
|
111
|
+
...(0, import_tasks.createGlobalSetupTasks)(config)
|
|
112
|
+
]);
|
|
113
|
+
if (status !== "passed")
|
|
114
|
+
await cleanup();
|
|
115
|
+
else
|
|
116
|
+
this._globalSetup = { cleanup };
|
|
117
|
+
return { status };
|
|
118
|
+
}
|
|
119
|
+
async runGlobalTeardown() {
|
|
120
|
+
const globalSetup = this._globalSetup;
|
|
121
|
+
const status = await globalSetup?.cleanup();
|
|
122
|
+
this._globalSetup = void 0;
|
|
123
|
+
return { status };
|
|
124
|
+
}
|
|
125
|
+
async startDevServer(userReporter, mode) {
|
|
126
|
+
await this.stopDevServer();
|
|
127
|
+
const reporter = new import_internalReporter.InternalReporter([userReporter]);
|
|
128
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
129
|
+
if (!config)
|
|
130
|
+
return { status: "failed" };
|
|
131
|
+
const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
|
|
132
|
+
...(0, import_tasks.createPluginSetupTasks)(config),
|
|
133
|
+
(0, import_tasks.createLoadTask)(mode, { failOnLoadErrors: true, filterOnly: false }),
|
|
134
|
+
(0, import_tasks.createStartDevServerTask)()
|
|
135
|
+
]);
|
|
136
|
+
if (status !== "passed")
|
|
137
|
+
await cleanup();
|
|
138
|
+
else
|
|
139
|
+
this._devServer = { cleanup };
|
|
140
|
+
return { status };
|
|
141
|
+
}
|
|
142
|
+
async stopDevServer() {
|
|
143
|
+
const devServer = this._devServer;
|
|
144
|
+
const status = await devServer?.cleanup();
|
|
145
|
+
this._devServer = void 0;
|
|
146
|
+
return { status };
|
|
147
|
+
}
|
|
148
|
+
async clearCache(userReporter) {
|
|
149
|
+
const reporter = new import_internalReporter.InternalReporter(userReporter ? [userReporter] : []);
|
|
150
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
151
|
+
if (!config)
|
|
152
|
+
return { status: "failed" };
|
|
153
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
154
|
+
...(0, import_tasks.createPluginSetupTasks)(config),
|
|
155
|
+
(0, import_tasks.createClearCacheTask)(config)
|
|
156
|
+
]);
|
|
157
|
+
return { status };
|
|
158
|
+
}
|
|
159
|
+
async listFiles(userReporter, projects) {
|
|
160
|
+
const reporter = new import_internalReporter.InternalReporter([userReporter]);
|
|
161
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
162
|
+
if (!config)
|
|
163
|
+
return { status: "failed" };
|
|
164
|
+
config.cliProjectFilter = projects?.length ? projects : void 0;
|
|
165
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
166
|
+
(0, import_tasks.createListFilesTask)(),
|
|
167
|
+
(0, import_tasks.createReportBeginTask)()
|
|
168
|
+
]);
|
|
169
|
+
return { status };
|
|
170
|
+
}
|
|
171
|
+
async listTests(userReporter, params) {
|
|
172
|
+
let result;
|
|
173
|
+
this._queue = this._queue.then(async () => {
|
|
174
|
+
const { config, status } = await this._innerListTests(userReporter, params);
|
|
175
|
+
if (config)
|
|
176
|
+
await this._updateWatchedDirs(config);
|
|
177
|
+
result = { status };
|
|
178
|
+
}).catch(printInternalError);
|
|
179
|
+
await this._queue;
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
async _innerListTests(userReporter, params) {
|
|
183
|
+
const overrides = {
|
|
184
|
+
...this._configCLIOverrides,
|
|
185
|
+
repeatEach: 1,
|
|
186
|
+
retries: 0
|
|
187
|
+
};
|
|
188
|
+
const reporter = new import_internalReporter.InternalReporter([userReporter]);
|
|
189
|
+
const config = await this._loadConfigOrReportError(reporter, overrides);
|
|
190
|
+
if (!config)
|
|
191
|
+
return { status: "failed" };
|
|
192
|
+
config.cliArgs = params.locations || [];
|
|
193
|
+
config.cliGrep = params.grep;
|
|
194
|
+
config.cliGrepInvert = params.grepInvert;
|
|
195
|
+
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
|
|
196
|
+
config.cliListOnly = true;
|
|
197
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
198
|
+
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
|
|
199
|
+
(0, import_tasks.createReportBeginTask)()
|
|
200
|
+
]);
|
|
201
|
+
return { config, status };
|
|
202
|
+
}
|
|
203
|
+
async _updateWatchedDirs(config) {
|
|
204
|
+
this._watchedProjectDirs = /* @__PURE__ */ new Set();
|
|
205
|
+
this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
|
|
206
|
+
for (const p of config.projects) {
|
|
207
|
+
this._watchedProjectDirs.add(p.project.testDir);
|
|
208
|
+
this._ignoredProjectOutputs.add(p.project.outputDir);
|
|
209
|
+
}
|
|
210
|
+
const result = await resolveCtDirs(config);
|
|
211
|
+
if (result) {
|
|
212
|
+
this._watchedProjectDirs.add(result.templateDir);
|
|
213
|
+
this._ignoredProjectOutputs.add(result.outDir);
|
|
214
|
+
}
|
|
215
|
+
if (this._watchTestDirs)
|
|
216
|
+
await this._updateWatcher(false);
|
|
217
|
+
}
|
|
218
|
+
async _updateWatcher(reportPending) {
|
|
219
|
+
await this._watcher.update([...this._watchedProjectDirs, ...this._watchedTestDependencies], [...this._ignoredProjectOutputs], reportPending);
|
|
220
|
+
}
|
|
221
|
+
async runTests(userReporter, params) {
|
|
222
|
+
let result = { status: "passed" };
|
|
223
|
+
this._queue = this._queue.then(async () => {
|
|
224
|
+
result = await this._innerRunTests(userReporter, params).catch((e) => {
|
|
225
|
+
printInternalError(e);
|
|
226
|
+
return { status: "failed" };
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
await this._queue;
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
async _innerRunTests(userReporter, params) {
|
|
233
|
+
await this.stopTests();
|
|
234
|
+
const overrides = {
|
|
235
|
+
...this._configCLIOverrides,
|
|
236
|
+
repeatEach: 1,
|
|
237
|
+
retries: 0,
|
|
238
|
+
timeout: params.timeout,
|
|
239
|
+
preserveOutputDir: true,
|
|
240
|
+
reporter: params.reporters ? params.reporters.map((r) => [r]) : void 0,
|
|
241
|
+
use: {
|
|
242
|
+
...this._configCLIOverrides.use,
|
|
243
|
+
...params.trace === "on" ? { trace: { mode: "on", sources: false, _live: true } } : {},
|
|
244
|
+
...params.trace === "off" ? { trace: "off" } : {},
|
|
245
|
+
...params.video === "on" || params.video === "off" ? { video: params.video } : {},
|
|
246
|
+
...params.headed !== void 0 ? { headless: !params.headed } : {},
|
|
247
|
+
_optionContextReuseMode: params.reuseContext ? "when-possible" : void 0,
|
|
248
|
+
_optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : void 0
|
|
249
|
+
},
|
|
250
|
+
...params.updateSnapshots ? { updateSnapshots: params.updateSnapshots } : {},
|
|
251
|
+
...params.updateSourceMethod ? { updateSourceMethod: params.updateSourceMethod } : {},
|
|
252
|
+
...params.workers ? { workers: params.workers } : {}
|
|
253
|
+
};
|
|
254
|
+
if (params.trace === "on")
|
|
255
|
+
process.env.PW_LIVE_TRACE_STACKS = "1";
|
|
256
|
+
else
|
|
257
|
+
process.env.PW_LIVE_TRACE_STACKS = void 0;
|
|
258
|
+
const config = await this._loadConfigOrReportError(new import_internalReporter.InternalReporter([userReporter]), overrides);
|
|
259
|
+
if (!config)
|
|
260
|
+
return { status: "failed" };
|
|
261
|
+
config.cliListOnly = false;
|
|
262
|
+
config.cliPassWithNoTests = true;
|
|
263
|
+
config.cliArgs = params.locations || [];
|
|
264
|
+
config.cliGrep = params.grep;
|
|
265
|
+
config.cliGrepInvert = params.grepInvert;
|
|
266
|
+
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
|
|
267
|
+
config.preOnlyTestFilters = [];
|
|
268
|
+
if (params.testIds) {
|
|
269
|
+
const testIdSet = new Set(params.testIds);
|
|
270
|
+
config.preOnlyTestFilters.push((test) => testIdSet.has(test.id));
|
|
271
|
+
}
|
|
272
|
+
const configReporters = params.disableConfigReporters ? [] : await (0, import_reporters.createReporters)(config, "test", true);
|
|
273
|
+
const reporter = new import_internalReporter.InternalReporter([...configReporters, userReporter]);
|
|
274
|
+
const stop = new import_utils.ManualPromise();
|
|
275
|
+
const tasks = [
|
|
276
|
+
(0, import_tasks.createApplyRebaselinesTask)(),
|
|
277
|
+
(0, import_tasks.createLoadTask)("out-of-process", { filterOnly: true, failOnLoadErrors: !!params.failOnLoadErrors, doNotRunDepsOutsideProjectFilter: params.doNotRunDepsOutsideProjectFilter }),
|
|
278
|
+
...(0, import_tasks.createRunTestsTasks)(config)
|
|
279
|
+
];
|
|
280
|
+
const testRun = new import_tasks.TestRun(config, reporter, { pauseOnError: params.pauseOnError, pauseAtEnd: params.pauseAtEnd });
|
|
281
|
+
const run = (0, import_tasks.runTasks)(testRun, tasks, 0, stop).then(async (status) => {
|
|
282
|
+
this._testRun = void 0;
|
|
283
|
+
return status;
|
|
284
|
+
});
|
|
285
|
+
this._testRun = { run, stop };
|
|
286
|
+
return { status: await run };
|
|
287
|
+
}
|
|
288
|
+
async watch(fileNames) {
|
|
289
|
+
this._watchedTestDependencies = /* @__PURE__ */ new Set();
|
|
290
|
+
for (const fileName of fileNames) {
|
|
291
|
+
this._watchedTestDependencies.add(fileName);
|
|
292
|
+
(0, import_compilationCache.dependenciesForTestFile)(fileName).forEach((file) => this._watchedTestDependencies.add(file));
|
|
293
|
+
}
|
|
294
|
+
await this._updateWatcher(true);
|
|
295
|
+
}
|
|
296
|
+
async findRelatedTestFiles(files, userReporter) {
|
|
297
|
+
const errorReporter = (0, import_reporters.createErrorCollectingReporter)(import_base.internalScreen);
|
|
298
|
+
const reporter = new import_internalReporter.InternalReporter(userReporter ? [userReporter, errorReporter] : [errorReporter]);
|
|
299
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
300
|
+
if (!config)
|
|
301
|
+
return { errors: errorReporter.errors(), testFiles: [] };
|
|
302
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
303
|
+
...(0, import_tasks.createPluginSetupTasks)(config),
|
|
304
|
+
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false, populateDependencies: true })
|
|
305
|
+
]);
|
|
306
|
+
if (status !== "passed")
|
|
307
|
+
return { errors: errorReporter.errors(), testFiles: [] };
|
|
308
|
+
return { testFiles: (0, import_compilationCache.affectedTestFiles)(files) };
|
|
309
|
+
}
|
|
310
|
+
async stopTests() {
|
|
311
|
+
this._testRun?.stop?.resolve();
|
|
312
|
+
await this._testRun?.run;
|
|
313
|
+
}
|
|
314
|
+
async closeGracefully() {
|
|
315
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(0);
|
|
316
|
+
}
|
|
317
|
+
async stop() {
|
|
318
|
+
await this.runGlobalTeardown();
|
|
319
|
+
}
|
|
320
|
+
async _loadConfig(overrides) {
|
|
321
|
+
try {
|
|
322
|
+
const config = await (0, import_configLoader.loadConfig)(this.configLocation, overrides);
|
|
323
|
+
if (!this._plugins) {
|
|
324
|
+
(0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
|
|
325
|
+
(0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
|
|
326
|
+
this._plugins = config.plugins || [];
|
|
327
|
+
} else {
|
|
328
|
+
config.plugins.splice(0, config.plugins.length, ...this._plugins);
|
|
329
|
+
}
|
|
330
|
+
return { config };
|
|
331
|
+
} catch (e) {
|
|
332
|
+
return { config: null, error: (0, import_util.serializeError)(e) };
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
async _loadConfigOrReportError(reporter, overrides) {
|
|
336
|
+
const { config, error } = await this._loadConfig(overrides);
|
|
337
|
+
if (config)
|
|
338
|
+
return config;
|
|
339
|
+
reporter.onConfigure(import_teleReceiver.baseFullConfig);
|
|
340
|
+
reporter.onError(error);
|
|
341
|
+
await reporter.onEnd({ status: "failed" });
|
|
342
|
+
await reporter.onExit();
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function printInternalError(e) {
|
|
347
|
+
console.error("Internal error:", e);
|
|
348
|
+
}
|
|
349
|
+
async function resolveCtDirs(config) {
|
|
350
|
+
const use = config.config.projects[0].use;
|
|
351
|
+
const relativeTemplateDir = use.ctTemplateDir || "playwright";
|
|
352
|
+
const templateDir = await import_fs.default.promises.realpath(import_path.default.normalize(import_path.default.join(config.configDir, relativeTemplateDir))).catch(() => void 0);
|
|
353
|
+
if (!templateDir)
|
|
354
|
+
return null;
|
|
355
|
+
const outDir = use.ctCacheDir ? import_path.default.resolve(config.configDir, use.ctCacheDir) : import_path.default.resolve(templateDir, ".cache");
|
|
356
|
+
return {
|
|
357
|
+
outDir,
|
|
358
|
+
templateDir
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
async function runAllTestsWithConfig(config) {
|
|
362
|
+
(0, import_utils.setPlaywrightTestProcessEnv)();
|
|
363
|
+
const listOnly = config.cliListOnly;
|
|
364
|
+
(0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
|
|
365
|
+
(0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
|
|
366
|
+
const reporters = await (0, import_reporters.createReporters)(config, listOnly ? "list" : "test", false);
|
|
367
|
+
const lastRun = new import_lastRun.LastRunReporter(config);
|
|
368
|
+
if (config.cliLastFailed)
|
|
369
|
+
await lastRun.filterLastFailed();
|
|
370
|
+
const reporter = new import_internalReporter.InternalReporter([...reporters, lastRun]);
|
|
371
|
+
const tasks = listOnly ? [
|
|
372
|
+
(0, import_tasks.createLoadTask)("in-process", { failOnLoadErrors: true, filterOnly: false }),
|
|
373
|
+
(0, import_tasks.createReportBeginTask)()
|
|
374
|
+
] : [
|
|
375
|
+
(0, import_tasks.createApplyRebaselinesTask)(),
|
|
376
|
+
...(0, import_tasks.createGlobalSetupTasks)(config),
|
|
377
|
+
(0, import_tasks.createLoadTask)("in-process", { filterOnly: true, failOnLoadErrors: true }),
|
|
378
|
+
...(0, import_tasks.createRunTestsTasks)(config)
|
|
379
|
+
];
|
|
380
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), tasks, config.config.globalTimeout);
|
|
381
|
+
await new Promise((resolve) => process.stdout.write("", () => resolve()));
|
|
382
|
+
await new Promise((resolve) => process.stderr.write("", () => resolve()));
|
|
383
|
+
return status;
|
|
384
|
+
}
|
|
385
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
386
|
+
0 && (module.exports = {
|
|
387
|
+
TestRunner,
|
|
388
|
+
TestRunnerEvent,
|
|
389
|
+
runAllTestsWithConfig
|
|
390
|
+
});
|