@smoothdeploy/playwright 1.58.4 → 1.61.0
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/ThirdPartyNotices.txt +8 -5036
- package/lib/agents/agentParser.js +2 -2
- package/lib/agents/generateAgents.js +69 -22
- package/lib/agents/playwright-test-healer.agent.md +1 -0
- package/lib/agents/playwright-test-planner.agent.md +2 -1
- package/lib/cli/reportActions.js +78 -0
- package/lib/cli/testActions.js +213 -0
- package/lib/common/index.js +2931 -0
- package/lib/common/index.js.txt +35 -0
- package/lib/errorContext.js +130 -0
- package/lib/index.js +276 -219
- package/lib/{isomorphic/testServerConnection.js → isomorphic.js} +70 -35
- package/lib/isomorphic.js.txt +9 -0
- package/lib/loader/loaderProcessEntry.js +34 -0
- package/lib/loader/loaderProcessEntry.js.txt +9 -0
- package/lib/matchers/expect.js +12990 -249
- package/lib/matchers/expect.js.LICENSE +693 -0
- package/lib/matchers/expect.js.txt +72 -0
- package/lib/mcp/test/browserBackend.js +49 -22
- package/lib/mcp/test/generatorTools.js +16 -16
- package/lib/mcp/test/plannerTools.js +25 -20
- package/lib/mcp/test/seed.js +7 -7
- package/lib/mcp/test/testBackend.js +30 -30
- package/lib/mcp/test/testContext.js +54 -33
- package/lib/mcp/test/testTools.js +15 -25
- package/lib/{internalsForTest.js → package.js} +13 -8
- package/lib/program.js +71 -265
- package/lib/runner/index.js +8389 -0
- package/lib/runner/index.js.txt +60 -0
- package/lib/transform/babelBundle.js +71002 -18
- package/lib/transform/babelBundle.js.LICENSE +2359 -0
- package/lib/transform/babelBundle.js.txt +325 -0
- package/lib/transform/esmLoader.js +5994 -33
- package/lib/transform/esmLoader.js.LICENSE +335 -0
- package/lib/transform/esmLoader.js.txt +57 -0
- package/lib/util.js +48 -48
- package/lib/worker/workerProcessEntry.js +1868 -0
- package/lib/worker/workerProcessEntry.js.txt +20 -0
- package/package.json +5 -16
- package/test.mjs +1 -0
- package/types/test.d.ts +238 -28
- package/types/testReporter.d.ts +7 -5
- package/lib/common/config.js +0 -282
- package/lib/common/configLoader.js +0 -344
- package/lib/common/esmLoaderHost.js +0 -104
- package/lib/common/expectBundle.js +0 -28
- package/lib/common/expectBundleImpl.js +0 -407
- package/lib/common/fixtures.js +0 -302
- package/lib/common/ipc.js +0 -60
- package/lib/common/poolBuilder.js +0 -85
- package/lib/common/process.js +0 -132
- package/lib/common/suiteUtils.js +0 -140
- package/lib/common/test.js +0 -321
- package/lib/common/testLoader.js +0 -101
- package/lib/common/testType.js +0 -298
- package/lib/common/validators.js +0 -68
- package/lib/fsWatcher.js +0 -67
- package/lib/isomorphic/events.js +0 -77
- package/lib/isomorphic/folders.js +0 -30
- package/lib/isomorphic/stringInternPool.js +0 -69
- package/lib/isomorphic/teleReceiver.js +0 -521
- package/lib/isomorphic/teleSuiteUpdater.js +0 -157
- package/lib/isomorphic/testServerInterface.js +0 -16
- package/lib/isomorphic/testTree.js +0 -329
- package/lib/isomorphic/types.d.js +0 -16
- package/lib/loader/loaderMain.js +0 -59
- package/lib/matchers/matcherHint.js +0 -44
- package/lib/matchers/matchers.js +0 -383
- package/lib/matchers/toBeTruthy.js +0 -75
- package/lib/matchers/toEqual.js +0 -100
- package/lib/matchers/toHaveURL.js +0 -101
- package/lib/matchers/toMatchAriaSnapshot.js +0 -159
- package/lib/matchers/toMatchSnapshot.js +0 -342
- package/lib/matchers/toMatchText.js +0 -99
- package/lib/mcp/browser/browserContextFactory.js +0 -329
- package/lib/mcp/browser/browserServerBackend.js +0 -84
- package/lib/mcp/browser/config.js +0 -421
- package/lib/mcp/browser/context.js +0 -244
- package/lib/mcp/browser/response.js +0 -278
- package/lib/mcp/browser/sessionLog.js +0 -75
- package/lib/mcp/browser/tab.js +0 -343
- package/lib/mcp/browser/tools/common.js +0 -65
- package/lib/mcp/browser/tools/console.js +0 -46
- package/lib/mcp/browser/tools/dialogs.js +0 -60
- package/lib/mcp/browser/tools/evaluate.js +0 -61
- package/lib/mcp/browser/tools/files.js +0 -58
- package/lib/mcp/browser/tools/form.js +0 -63
- package/lib/mcp/browser/tools/install.js +0 -72
- package/lib/mcp/browser/tools/keyboard.js +0 -107
- package/lib/mcp/browser/tools/mouse.js +0 -107
- package/lib/mcp/browser/tools/navigate.js +0 -71
- package/lib/mcp/browser/tools/network.js +0 -63
- package/lib/mcp/browser/tools/open.js +0 -57
- package/lib/mcp/browser/tools/pdf.js +0 -49
- package/lib/mcp/browser/tools/runCode.js +0 -78
- package/lib/mcp/browser/tools/screenshot.js +0 -93
- package/lib/mcp/browser/tools/snapshot.js +0 -173
- package/lib/mcp/browser/tools/tabs.js +0 -67
- package/lib/mcp/browser/tools/tool.js +0 -47
- package/lib/mcp/browser/tools/tracing.js +0 -74
- package/lib/mcp/browser/tools/utils.js +0 -94
- package/lib/mcp/browser/tools/verify.js +0 -143
- package/lib/mcp/browser/tools/wait.js +0 -63
- package/lib/mcp/browser/tools.js +0 -84
- package/lib/mcp/browser/watchdog.js +0 -44
- package/lib/mcp/config.d.js +0 -16
- package/lib/mcp/extension/cdpRelay.js +0 -351
- package/lib/mcp/extension/extensionContextFactory.js +0 -76
- package/lib/mcp/extension/protocol.js +0 -28
- package/lib/mcp/index.js +0 -61
- package/lib/mcp/log.js +0 -35
- package/lib/mcp/program.js +0 -111
- package/lib/mcp/sdk/exports.js +0 -28
- package/lib/mcp/sdk/http.js +0 -152
- package/lib/mcp/sdk/inProcessTransport.js +0 -71
- package/lib/mcp/sdk/server.js +0 -223
- package/lib/mcp/sdk/tool.js +0 -47
- package/lib/mcp/terminal/cli.js +0 -296
- package/lib/mcp/terminal/command.js +0 -56
- package/lib/mcp/terminal/commands.js +0 -333
- package/lib/mcp/terminal/daemon.js +0 -129
- package/lib/mcp/terminal/help.json +0 -32
- package/lib/mcp/terminal/helpGenerator.js +0 -88
- package/lib/mcp/terminal/socketConnection.js +0 -80
- package/lib/plugins/gitCommitInfoPlugin.js +0 -198
- package/lib/plugins/index.js +0 -28
- package/lib/plugins/webServerPlugin.js +0 -237
- package/lib/reporters/base.js +0 -634
- package/lib/reporters/blob.js +0 -138
- package/lib/reporters/dot.js +0 -99
- package/lib/reporters/empty.js +0 -32
- package/lib/reporters/github.js +0 -128
- package/lib/reporters/html.js +0 -633
- package/lib/reporters/internalReporter.js +0 -138
- package/lib/reporters/json.js +0 -254
- package/lib/reporters/junit.js +0 -232
- package/lib/reporters/line.js +0 -131
- package/lib/reporters/list.js +0 -253
- package/lib/reporters/listModeReporter.js +0 -69
- package/lib/reporters/markdown.js +0 -144
- package/lib/reporters/merge.js +0 -558
- package/lib/reporters/multiplexer.js +0 -112
- package/lib/reporters/reporterV2.js +0 -102
- package/lib/reporters/smoothdeploy.js +0 -333
- package/lib/reporters/teleEmitter.js +0 -317
- package/lib/reporters/versions/blobV1.js +0 -16
- package/lib/runner/dispatcher.js +0 -531
- package/lib/runner/failureTracker.js +0 -72
- package/lib/runner/lastRun.js +0 -77
- package/lib/runner/loadUtils.js +0 -334
- package/lib/runner/loaderHost.js +0 -89
- package/lib/runner/processHost.js +0 -180
- package/lib/runner/projectUtils.js +0 -241
- package/lib/runner/rebase.js +0 -189
- package/lib/runner/reporters.js +0 -140
- package/lib/runner/sigIntWatcher.js +0 -96
- package/lib/runner/storage.js +0 -91
- package/lib/runner/taskRunner.js +0 -127
- package/lib/runner/tasks.js +0 -410
- package/lib/runner/testGroups.js +0 -125
- package/lib/runner/testRunner.js +0 -398
- package/lib/runner/testServer.js +0 -269
- package/lib/runner/uiModeReporter.js +0 -30
- package/lib/runner/vcs.js +0 -72
- package/lib/runner/watchMode.js +0 -396
- package/lib/runner/workerHost.js +0 -104
- package/lib/third_party/pirates.js +0 -62
- package/lib/third_party/tsconfig-loader.js +0 -103
- package/lib/transform/babelBundleImpl.js +0 -461
- package/lib/transform/compilationCache.js +0 -274
- package/lib/transform/md.js +0 -221
- package/lib/transform/portTransport.js +0 -67
- package/lib/transform/transform.js +0 -303
- package/lib/utilsBundle.js +0 -50
- package/lib/utilsBundleImpl.js +0 -103
- package/lib/worker/fixtureRunner.js +0 -262
- package/lib/worker/testInfo.js +0 -536
- package/lib/worker/testTracing.js +0 -345
- package/lib/worker/timeoutManager.js +0 -174
- package/lib/worker/util.js +0 -31
- package/lib/worker/workerMain.js +0 -530
- /package/lib/{common/globals.js → globals.js} +0 -0
package/lib/program.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,43 +15,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var program_exports = {};
|
|
30
20
|
__export(program_exports, {
|
|
31
|
-
program: () =>
|
|
21
|
+
program: () => program
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(program_exports);
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var import_configLoader = require("./common/configLoader");
|
|
40
|
-
var import_program2 = require("playwright-core/lib/cli/program");
|
|
41
|
-
var import_base = require("./reporters/base");
|
|
42
|
-
var import_html = require("./reporters/html");
|
|
43
|
-
var import_merge = require("./reporters/merge");
|
|
44
|
-
var import_projectUtils = require("./runner/projectUtils");
|
|
45
|
-
var testServer = __toESM(require("./runner/testServer"));
|
|
46
|
-
var import_watchMode = require("./runner/watchMode");
|
|
47
|
-
var import_testRunner = require("./runner/testRunner");
|
|
48
|
-
var import_reporters = require("./runner/reporters");
|
|
49
|
-
var mcp = __toESM(require("./mcp/sdk/exports"));
|
|
24
|
+
var import_bootstrap = require("playwright-core/lib/bootstrap");
|
|
25
|
+
var import_coreBundle = require("playwright-core/lib/coreBundle");
|
|
26
|
+
var import_common = require("./common");
|
|
27
|
+
var import_testActions = require("./cli/testActions");
|
|
28
|
+
var import_reportActions = require("./cli/reportActions");
|
|
50
29
|
var import_testBackend = require("./mcp/test/testBackend");
|
|
51
|
-
var import_program3 = require("./mcp/program");
|
|
52
|
-
var import_watchdog = require("./mcp/browser/watchdog");
|
|
53
30
|
var import_generateAgents = require("./agents/generateAgents");
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
31
|
+
var import_package = require("./package");
|
|
32
|
+
const { program } = require("playwright-core/lib/utilsBundle");
|
|
33
|
+
const { gracefullyProcessExitDoNotHang } = require("playwright-core/lib/coreBundle").utils;
|
|
34
|
+
import_coreBundle.libCli.decorateProgram(program);
|
|
35
|
+
function addTestCommand(program2) {
|
|
36
|
+
const command = program2.command("test [test-filter...]");
|
|
57
37
|
command.description("run tests with Playwright Test");
|
|
58
38
|
const options = testOptions.sort((a, b) => a[0].replace(/-/g, "").localeCompare(b[0].replace(/-/g, "")));
|
|
59
39
|
options.forEach(([name, { description, choices, preset }]) => {
|
|
@@ -66,11 +46,14 @@ function addTestCommand(program3) {
|
|
|
66
46
|
return command;
|
|
67
47
|
});
|
|
68
48
|
command.action(async (args, opts) => {
|
|
49
|
+
const dashDashIndex = process.argv.indexOf("--");
|
|
50
|
+
const postDashCount = dashDashIndex >= 0 ? process.argv.length - 1 - dashDashIndex : 0;
|
|
51
|
+
const testFilters = args.slice(0, args.length - postDashCount);
|
|
69
52
|
try {
|
|
70
|
-
await runTests(
|
|
53
|
+
await (0, import_testActions.runTests)(testFilters, opts);
|
|
71
54
|
} catch (e) {
|
|
72
55
|
console.error(e);
|
|
73
|
-
|
|
56
|
+
gracefullyProcessExitDoNotHang(1);
|
|
74
57
|
}
|
|
75
58
|
});
|
|
76
59
|
command.addHelpText("afterAll", `
|
|
@@ -83,61 +66,55 @@ Examples:
|
|
|
83
66
|
$ npx playwright test --headed
|
|
84
67
|
$ npx playwright test --project=webkit`);
|
|
85
68
|
}
|
|
86
|
-
function addClearCacheCommand(
|
|
87
|
-
const command =
|
|
69
|
+
function addClearCacheCommand(program2) {
|
|
70
|
+
const command = program2.command("clear-cache");
|
|
88
71
|
command.description("clears build and test caches");
|
|
89
72
|
command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
|
|
90
73
|
command.action(async (opts) => {
|
|
91
|
-
|
|
92
|
-
const { status } = await runner.clearCache((0, import_reporters.createErrorCollectingReporter)(import_base.terminalScreen));
|
|
93
|
-
const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
|
|
94
|
-
(0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
|
|
74
|
+
await (0, import_testActions.clearCache)(opts);
|
|
95
75
|
});
|
|
96
76
|
}
|
|
97
|
-
function
|
|
98
|
-
const command =
|
|
99
|
-
command.description("start dev server");
|
|
100
|
-
command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
|
|
101
|
-
command.action(async (options) => {
|
|
102
|
-
const runner = new import_testRunner.TestRunner((0, import_configLoader.resolveConfigLocation)(options.config), {});
|
|
103
|
-
await runner.startDevServer((0, import_reporters.createErrorCollectingReporter)(import_base.terminalScreen), "in-process");
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function addTestServerCommand(program3) {
|
|
107
|
-
const command = program3.command("test-server", { hidden: true });
|
|
77
|
+
function addTestServerCommand(program2) {
|
|
78
|
+
const command = program2.command("test-server", { hidden: true });
|
|
108
79
|
command.description("start test server");
|
|
109
80
|
command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
|
|
110
81
|
command.option("--host <host>", "Host to start the server on", "localhost");
|
|
111
82
|
command.option("--port <port>", "Port to start the server on", "0");
|
|
112
|
-
command.action((opts) =>
|
|
83
|
+
command.action(async (opts) => {
|
|
84
|
+
await (0, import_testActions.runTestServerAction)(opts);
|
|
85
|
+
});
|
|
113
86
|
}
|
|
114
|
-
function addShowReportCommand(
|
|
115
|
-
const command =
|
|
87
|
+
function addShowReportCommand(program2) {
|
|
88
|
+
const command = program2.command("show-report [report]");
|
|
116
89
|
command.description("show HTML report");
|
|
117
|
-
command.action((report, options) =>
|
|
90
|
+
command.action(async (report, options) => {
|
|
91
|
+
await (0, import_reportActions.showReport)(report, options.host, +options.port);
|
|
92
|
+
});
|
|
118
93
|
command.option("--host <host>", "Host to serve report on", "localhost");
|
|
119
94
|
command.option("--port <port>", "Port to serve report on", "9323");
|
|
120
95
|
command.addHelpText("afterAll", `
|
|
121
96
|
Arguments [report]:
|
|
122
97
|
When specified, opens given report, otherwise opens last generated report.
|
|
98
|
+
Accepts a directory or a .zip archive whose top-level entry is "index.html" (e.g. one downloaded from a CI artifact).
|
|
123
99
|
|
|
124
100
|
Examples:
|
|
125
101
|
$ npx playwright show-report
|
|
126
|
-
$ npx playwright show-report playwright-report
|
|
102
|
+
$ npx playwright show-report playwright-report
|
|
103
|
+
$ npx playwright show-report playwright-report.zip`);
|
|
127
104
|
}
|
|
128
|
-
function addMergeReportsCommand(
|
|
129
|
-
const command =
|
|
105
|
+
function addMergeReportsCommand(program2) {
|
|
106
|
+
const command = program2.command("merge-reports [dir]");
|
|
130
107
|
command.description("merge multiple blob reports (for sharded tests) into a single report");
|
|
131
108
|
command.action(async (dir, options) => {
|
|
132
109
|
try {
|
|
133
|
-
await mergeReports(dir, options);
|
|
110
|
+
await (0, import_reportActions.mergeReports)(dir, options);
|
|
134
111
|
} catch (e) {
|
|
135
112
|
console.error(e);
|
|
136
|
-
|
|
113
|
+
gracefullyProcessExitDoNotHang(1);
|
|
137
114
|
}
|
|
138
115
|
});
|
|
139
116
|
command.option("-c, --config <file>", `Configuration file. Can be used to specify additional configuration for the output report.`);
|
|
140
|
-
command.option("--reporter <reporter>", `Reporter to use, comma-separated, can be ${
|
|
117
|
+
command.option("--reporter <reporter>", `Reporter to use, comma-separated, can be ${import_common.builtInReporters.map((name) => `"${name}"`).join(", ")} (default: "${import_common.config.defaultReporter}")`);
|
|
141
118
|
command.addHelpText("afterAll", `
|
|
142
119
|
Arguments [dir]:
|
|
143
120
|
Directory containing blob reports.
|
|
@@ -145,238 +122,68 @@ Arguments [dir]:
|
|
|
145
122
|
Examples:
|
|
146
123
|
$ npx playwright merge-reports playwright-report`);
|
|
147
124
|
}
|
|
148
|
-
function
|
|
149
|
-
const command =
|
|
150
|
-
command.description("Interact with the browser over MCP");
|
|
151
|
-
(0, import_program3.decorateCommand)(command, packageJSON.version);
|
|
152
|
-
}
|
|
153
|
-
function addTestMCPServerCommand(program3) {
|
|
154
|
-
const command = program3.command("run-test-mcp-server", { hidden: true });
|
|
125
|
+
function addTestMCPServerCommand(program2) {
|
|
126
|
+
const command = program2.command("run-test-mcp-server", { hidden: true });
|
|
155
127
|
command.description("Interact with the test runner over MCP");
|
|
156
128
|
command.option("--headless", "run browser in headless mode, headed by default");
|
|
157
129
|
command.option("-c, --config <file>", `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
|
|
158
130
|
command.option("--host <host>", "host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.");
|
|
159
131
|
command.option("--port <port>", "port to listen on for SSE transport.");
|
|
160
132
|
command.action(async (options) => {
|
|
161
|
-
|
|
133
|
+
import_coreBundle.tools.setupExitWatchdog();
|
|
162
134
|
const factory = {
|
|
163
135
|
name: "Playwright Test Runner",
|
|
164
136
|
nameInConfig: "playwright-test-runner",
|
|
165
|
-
version: packageJSON.version,
|
|
166
|
-
|
|
137
|
+
version: import_package.packageJSON.version,
|
|
138
|
+
toolSchemas: import_testBackend.testServerBackendTools.map((tool) => tool.schema),
|
|
139
|
+
create: async () => new import_testBackend.TestServerBackend(options.config, { muteConsole: options.port === void 0, headless: options.headless }),
|
|
140
|
+
disposed: async () => {
|
|
141
|
+
}
|
|
167
142
|
};
|
|
168
|
-
await
|
|
143
|
+
await import_coreBundle.tools.start(factory, { port: options.port === void 0 ? void 0 : +options.port, host: options.host });
|
|
169
144
|
});
|
|
170
145
|
}
|
|
171
|
-
function addInitAgentsCommand(
|
|
172
|
-
const command =
|
|
146
|
+
function addInitAgentsCommand(program2) {
|
|
147
|
+
const command = program2.command("init-agents");
|
|
173
148
|
command.description("Initialize repository agents");
|
|
174
149
|
const option = command.createOption("--loop <loop>", "Agentic loop provider");
|
|
175
|
-
option.choices(["claude", "copilot", "opencode", "vscode", "vscode-legacy"]);
|
|
150
|
+
option.choices(["claude", "codex", "copilot", "opencode", "vscode", "vscode-legacy"]);
|
|
176
151
|
command.addOption(option);
|
|
177
152
|
command.option("-c, --config <file>", `Configuration file to find a project to use for seed test`);
|
|
178
153
|
command.option("--project <project>", "Project to use for seed test");
|
|
179
154
|
command.option("--prompts", "Whether to include prompts in the agent initialization");
|
|
180
155
|
command.action(async (opts) => {
|
|
181
|
-
const
|
|
156
|
+
const loadedConfig = await import_common.configLoader.loadConfigFromFile(opts.config);
|
|
182
157
|
if (opts.loop === "opencode") {
|
|
183
|
-
await import_generateAgents.OpencodeGenerator.init(
|
|
158
|
+
await import_generateAgents.OpencodeGenerator.init(loadedConfig, opts.project, opts.prompts);
|
|
184
159
|
} else if (opts.loop === "vscode-legacy") {
|
|
185
|
-
await import_generateAgents.VSCodeGenerator.init(
|
|
160
|
+
await import_generateAgents.VSCodeGenerator.init(loadedConfig, opts.project);
|
|
186
161
|
} else if (opts.loop === "claude") {
|
|
187
|
-
await import_generateAgents.ClaudeGenerator.init(
|
|
162
|
+
await import_generateAgents.ClaudeGenerator.init(loadedConfig, opts.project, opts.prompts);
|
|
163
|
+
} else if (opts.loop === "codex") {
|
|
164
|
+
await import_generateAgents.CodexGenerator.init(loadedConfig, opts.project, opts.prompts);
|
|
188
165
|
} else {
|
|
189
|
-
await import_generateAgents.CopilotGenerator.init(
|
|
166
|
+
await import_generateAgents.CopilotGenerator.init(loadedConfig, opts.project, opts.prompts);
|
|
190
167
|
return;
|
|
191
168
|
}
|
|
192
169
|
});
|
|
193
170
|
}
|
|
194
|
-
|
|
195
|
-
await (0, import_utils.startProfiling)();
|
|
196
|
-
const cliOverrides = overridesFromOptions(opts);
|
|
197
|
-
const config = await (0, import_configLoader.loadConfigFromFile)(opts.config, cliOverrides, opts.deps === false);
|
|
198
|
-
config.cliArgs = args;
|
|
199
|
-
config.cliGrep = opts.grep;
|
|
200
|
-
config.cliOnlyChanged = opts.onlyChanged === true ? "HEAD" : opts.onlyChanged;
|
|
201
|
-
config.cliGrepInvert = opts.grepInvert;
|
|
202
|
-
config.cliListOnly = !!opts.list;
|
|
203
|
-
config.cliProjectFilter = opts.project || void 0;
|
|
204
|
-
config.cliPassWithNoTests = !!opts.passWithNoTests;
|
|
205
|
-
config.cliLastFailed = !!opts.lastFailed;
|
|
206
|
-
config.cliTestList = opts.testList ? import_path.default.resolve(process.cwd(), opts.testList) : void 0;
|
|
207
|
-
config.cliTestListInvert = opts.testListInvert ? import_path.default.resolve(process.cwd(), opts.testListInvert) : void 0;
|
|
208
|
-
(0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
|
|
209
|
-
if (opts.ui || opts.uiHost || opts.uiPort) {
|
|
210
|
-
if (opts.onlyChanged)
|
|
211
|
-
throw new Error(`--only-changed is not supported in UI mode. If you'd like that to change, see https://github.com/microsoft/playwright/issues/15075 for more details.`);
|
|
212
|
-
const status2 = await testServer.runUIMode(opts.config, cliOverrides, {
|
|
213
|
-
host: opts.uiHost,
|
|
214
|
-
port: opts.uiPort ? +opts.uiPort : void 0,
|
|
215
|
-
args,
|
|
216
|
-
grep: opts.grep,
|
|
217
|
-
grepInvert: opts.grepInvert,
|
|
218
|
-
project: opts.project || void 0,
|
|
219
|
-
reporter: Array.isArray(opts.reporter) ? opts.reporter : opts.reporter ? [opts.reporter] : void 0
|
|
220
|
-
});
|
|
221
|
-
await (0, import_utils.stopProfiling)("runner");
|
|
222
|
-
const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
|
|
223
|
-
(0, import_utils.gracefullyProcessExitDoNotHang)(exitCode2);
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
if (process.env.PWTEST_WATCH) {
|
|
227
|
-
if (opts.onlyChanged)
|
|
228
|
-
throw new Error(`--only-changed is not supported in watch mode. If you'd like that to change, file an issue and let us know about your usecase for it.`);
|
|
229
|
-
const status2 = await (0, import_watchMode.runWatchModeLoop)(
|
|
230
|
-
(0, import_configLoader.resolveConfigLocation)(opts.config),
|
|
231
|
-
{
|
|
232
|
-
projects: opts.project,
|
|
233
|
-
files: args,
|
|
234
|
-
grep: opts.grep
|
|
235
|
-
}
|
|
236
|
-
);
|
|
237
|
-
await (0, import_utils.stopProfiling)("runner");
|
|
238
|
-
const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
|
|
239
|
-
(0, import_utils.gracefullyProcessExitDoNotHang)(exitCode2);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
const status = await (0, import_testRunner.runAllTestsWithConfig)(config);
|
|
243
|
-
await (0, import_utils.stopProfiling)("runner");
|
|
244
|
-
const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
|
|
245
|
-
(0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
|
|
246
|
-
}
|
|
247
|
-
async function runTestServer(opts) {
|
|
248
|
-
const host = opts.host;
|
|
249
|
-
const port = opts.port ? +opts.port : void 0;
|
|
250
|
-
const status = await testServer.runTestServer(opts.config, {}, { host, port });
|
|
251
|
-
const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
|
|
252
|
-
(0, import_utils.gracefullyProcessExitDoNotHang)(exitCode);
|
|
253
|
-
}
|
|
254
|
-
async function mergeReports(reportDir, opts) {
|
|
255
|
-
const configFile = opts.config;
|
|
256
|
-
const config = configFile ? await (0, import_configLoader.loadConfigFromFile)(configFile) : await (0, import_configLoader.loadEmptyConfigForMergeReports)();
|
|
257
|
-
const dir = import_path.default.resolve(process.cwd(), reportDir || "");
|
|
258
|
-
const dirStat = await import_fs.default.promises.stat(dir).catch((e) => null);
|
|
259
|
-
if (!dirStat)
|
|
260
|
-
throw new Error("Directory does not exist: " + dir);
|
|
261
|
-
if (!dirStat.isDirectory())
|
|
262
|
-
throw new Error(`"${dir}" is not a directory`);
|
|
263
|
-
let reporterDescriptions = resolveReporterOption(opts.reporter);
|
|
264
|
-
if (!reporterDescriptions && configFile)
|
|
265
|
-
reporterDescriptions = config.config.reporter;
|
|
266
|
-
if (!reporterDescriptions)
|
|
267
|
-
reporterDescriptions = [[import_config.defaultReporter]];
|
|
268
|
-
const rootDirOverride = configFile ? config.config.rootDir : void 0;
|
|
269
|
-
await (0, import_merge.createMergedReport)(config, dir, reporterDescriptions, rootDirOverride);
|
|
270
|
-
(0, import_utils.gracefullyProcessExitDoNotHang)(0);
|
|
271
|
-
}
|
|
272
|
-
function overridesFromOptions(options) {
|
|
273
|
-
const overrides = {
|
|
274
|
-
failOnFlakyTests: options.failOnFlakyTests ? true : void 0,
|
|
275
|
-
forbidOnly: options.forbidOnly ? true : void 0,
|
|
276
|
-
fullyParallel: options.fullyParallel ? true : void 0,
|
|
277
|
-
globalTimeout: options.globalTimeout ? parseInt(options.globalTimeout, 10) : void 0,
|
|
278
|
-
maxFailures: options.x ? 1 : options.maxFailures ? parseInt(options.maxFailures, 10) : void 0,
|
|
279
|
-
outputDir: options.output ? import_path.default.resolve(process.cwd(), options.output) : void 0,
|
|
280
|
-
quiet: options.quiet ? options.quiet : void 0,
|
|
281
|
-
repeatEach: options.repeatEach ? parseInt(options.repeatEach, 10) : void 0,
|
|
282
|
-
retries: options.retries ? parseInt(options.retries, 10) : void 0,
|
|
283
|
-
reporter: resolveReporterOption(options.reporter),
|
|
284
|
-
shard: resolveShardOption(options.shard),
|
|
285
|
-
shardWeights: resolveShardWeightsOption(),
|
|
286
|
-
timeout: options.timeout ? parseInt(options.timeout, 10) : void 0,
|
|
287
|
-
tsconfig: options.tsconfig ? import_path.default.resolve(process.cwd(), options.tsconfig) : void 0,
|
|
288
|
-
ignoreSnapshots: options.ignoreSnapshots ? !!options.ignoreSnapshots : void 0,
|
|
289
|
-
updateSnapshots: options.updateSnapshots,
|
|
290
|
-
updateSourceMethod: options.updateSourceMethod,
|
|
291
|
-
runAgents: options.runAgents,
|
|
292
|
-
workers: options.workers,
|
|
293
|
-
pause: process.env.PWPAUSE ? true : void 0
|
|
294
|
-
};
|
|
295
|
-
if (options.browser) {
|
|
296
|
-
const browserOpt = options.browser.toLowerCase();
|
|
297
|
-
if (!["all", "chromium", "firefox", "webkit"].includes(browserOpt))
|
|
298
|
-
throw new Error(`Unsupported browser "${options.browser}", must be one of "all", "chromium", "firefox" or "webkit"`);
|
|
299
|
-
const browserNames = browserOpt === "all" ? ["chromium", "firefox", "webkit"] : [browserOpt];
|
|
300
|
-
overrides.projects = browserNames.map((browserName) => {
|
|
301
|
-
return {
|
|
302
|
-
name: browserName,
|
|
303
|
-
use: { browserName }
|
|
304
|
-
};
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
if (options.headed || options.debug || overrides.pause)
|
|
308
|
-
overrides.use = { headless: false };
|
|
309
|
-
if (!options.ui && options.debug) {
|
|
310
|
-
overrides.debug = true;
|
|
311
|
-
process.env.PWDEBUG = "1";
|
|
312
|
-
}
|
|
313
|
-
if (!options.ui && options.trace) {
|
|
314
|
-
overrides.use = overrides.use || {};
|
|
315
|
-
overrides.use.trace = options.trace;
|
|
316
|
-
}
|
|
317
|
-
if (overrides.tsconfig && !import_fs.default.existsSync(overrides.tsconfig))
|
|
318
|
-
throw new Error(`--tsconfig "${options.tsconfig}" does not exist`);
|
|
319
|
-
return overrides;
|
|
320
|
-
}
|
|
321
|
-
function resolveReporterOption(reporter) {
|
|
322
|
-
if (!reporter || !reporter.length)
|
|
323
|
-
return void 0;
|
|
324
|
-
return reporter.split(",").map((r) => [resolveReporter(r)]);
|
|
325
|
-
}
|
|
326
|
-
function resolveShardOption(shard) {
|
|
327
|
-
if (!shard)
|
|
328
|
-
return void 0;
|
|
329
|
-
const shardPair = shard.split("/");
|
|
330
|
-
if (shardPair.length !== 2) {
|
|
331
|
-
throw new Error(
|
|
332
|
-
`--shard "${shard}", expected format is "current/all", 1-based, for example "3/5".`
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
const current = parseInt(shardPair[0], 10);
|
|
336
|
-
const total = parseInt(shardPair[1], 10);
|
|
337
|
-
if (isNaN(total) || total < 1)
|
|
338
|
-
throw new Error(`--shard "${shard}" total must be a positive number`);
|
|
339
|
-
if (isNaN(current) || current < 1 || current > total) {
|
|
340
|
-
throw new Error(
|
|
341
|
-
`--shard "${shard}" current must be a positive number, not greater than shard total`
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
return { current, total };
|
|
345
|
-
}
|
|
346
|
-
function resolveShardWeightsOption() {
|
|
347
|
-
const shardWeights = process.env.PWTEST_SHARD_WEIGHTS;
|
|
348
|
-
if (!shardWeights)
|
|
349
|
-
return void 0;
|
|
350
|
-
return shardWeights.split(":").map((w) => {
|
|
351
|
-
const weight = parseInt(w, 10);
|
|
352
|
-
if (isNaN(weight) || weight < 0)
|
|
353
|
-
throw new Error(`PWTEST_SHARD_WEIGHTS="${shardWeights}" weights must be non-negative numbers`);
|
|
354
|
-
return weight;
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
function resolveReporter(id) {
|
|
358
|
-
if (import_config.builtInReporters.includes(id))
|
|
359
|
-
return id;
|
|
360
|
-
const localPath = import_path.default.resolve(process.cwd(), id);
|
|
361
|
-
if (import_fs.default.existsSync(localPath))
|
|
362
|
-
return localPath;
|
|
363
|
-
return require.resolve(id, { paths: [process.cwd()] });
|
|
364
|
-
}
|
|
365
|
-
const kTraceModes = ["on", "off", "on-first-retry", "on-all-retries", "retain-on-failure", "retain-on-first-failure"];
|
|
171
|
+
const kTraceModes = ["on", "off", "on-first-retry", "on-all-retries", "retain-on-failure", "retain-on-first-failure", "retain-on-failure-and-retries"];
|
|
366
172
|
const testOptions = [
|
|
367
173
|
/* deprecated */
|
|
368
174
|
["--browser <browser>", { description: `Browser to use for tests, one of "all", "chromium", "firefox" or "webkit" (default: "chromium")` }],
|
|
369
175
|
["-c, --config <file>", { description: `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"` }],
|
|
370
|
-
["--debug", { description: `Run tests with Playwright Inspector. Shortcut for "PWDEBUG=1" environment variable and "--timeout=0 --max-failures=1 --headed --workers=1" options
|
|
176
|
+
["--debug [mode]", { description: `Run tests with Playwright Inspector. Shortcut for "PWDEBUG=1" environment variable and "--timeout=0 --max-failures=1 --headed --workers=1" options`, choices: ["inspector", "cli"], preset: "inspector" }],
|
|
371
177
|
["--fail-on-flaky-tests", { description: `Fail if any test is flagged as flaky (default: false)` }],
|
|
372
178
|
["--forbid-only", { description: `Fail if test.only is called (default: false)` }],
|
|
373
179
|
["--fully-parallel", { description: `Run all tests in parallel (default: false)` }],
|
|
374
180
|
["--global-timeout <timeout>", { description: `Maximum time this test suite can run in milliseconds (default: unlimited)` }],
|
|
375
181
|
["-g, --grep <grep>", { description: `Only run tests matching this regular expression (default: ".*")` }],
|
|
376
|
-
["--grep-invert <grep>", { description: `Only run tests that do not match this regular expression` }],
|
|
182
|
+
["-G, --grep-invert <grep>", { description: `Only run tests that do not match this regular expression` }],
|
|
377
183
|
["--headed", { description: `Run tests in headed browsers (default: headless)` }],
|
|
378
184
|
["--ignore-snapshots", { description: `Ignore screenshot and snapshot expectations` }],
|
|
379
185
|
["--last-failed", { description: `Only re-run the failures` }],
|
|
186
|
+
["--last-failed-file <file>", { description: `Override the default path for the last-run JSON file used with --last-failed (default: <outputDir>/.last-run.json). Same as PLAYWRIGHT_LAST_RUN_OUTPUT_FILE environment variable.` }],
|
|
380
187
|
["--list", { description: `Collect all the tests and report them, but do not run` }],
|
|
381
188
|
["--max-failures <N>", { description: `Stop after the first N failures` }],
|
|
382
189
|
["--no-deps", { description: `Do not run project dependencies` }],
|
|
@@ -386,12 +193,13 @@ const testOptions = [
|
|
|
386
193
|
["--project <project-name...>", { description: `Only run tests from the specified list of projects, supports '*' wildcard (default: run all projects)` }],
|
|
387
194
|
["--quiet", { description: `Suppress stdio` }],
|
|
388
195
|
["--repeat-each <N>", { description: `Run each test N times (default: 1)` }],
|
|
389
|
-
["--reporter <reporter>", { description: `Reporter to use, comma-separated, can be ${
|
|
196
|
+
["--reporter <reporter>", { description: `Reporter to use, comma-separated, can be ${import_common.builtInReporters.map((name) => `"${name}"`).join(", ")} (default: "${import_common.config.defaultReporter}")` }],
|
|
390
197
|
["--retries <retries>", { description: `Maximum retry count for flaky tests, zero for no retries (default: no retries)` }],
|
|
198
|
+
["--run-agents <mode>", { description: `Run agents to generate the code for page.perform`, choices: ["missing", "all", "none"], preset: "none" }],
|
|
391
199
|
["--shard <shard>", { description: `Shard tests and execute only the selected shard, specify in the form "current/all", 1-based, for example "3/5"` }],
|
|
392
200
|
["--test-list <file>", { description: `Path to a file containing a list of tests to run. See https://playwright.dev/docs/test-cli for more details.` }],
|
|
393
201
|
["--test-list-invert <file>", { description: `Path to a file containing a list of tests to skip. See https://playwright.dev/docs/test-cli for more details.` }],
|
|
394
|
-
["--timeout <timeout>", { description: `Specify test timeout threshold in milliseconds, zero for unlimited (default: ${
|
|
202
|
+
["--timeout <timeout>", { description: `Specify test timeout threshold in milliseconds, zero for unlimited (default: ${import_common.config.defaultTimeout})` }],
|
|
395
203
|
["--trace <mode>", { description: `Force tracing mode`, choices: kTraceModes }],
|
|
396
204
|
["--tsconfig <path>", { description: `Path to a single tsconfig applicable to all imported files (default: look up tsconfig for each imported file separately)` }],
|
|
397
205
|
["--ui", { description: `Run tests in interactive UI mode` }],
|
|
@@ -402,15 +210,13 @@ const testOptions = [
|
|
|
402
210
|
["-j, --workers <workers>", { description: `Number of concurrent workers or percentage of logical CPU cores, use 1 to run in a single worker (default: 50%)` }],
|
|
403
211
|
["-x", { description: `Stop after the first failure` }]
|
|
404
212
|
];
|
|
405
|
-
addTestCommand(
|
|
406
|
-
addShowReportCommand(
|
|
407
|
-
addMergeReportsCommand(
|
|
408
|
-
addClearCacheCommand(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
addTestServerCommand(import_program.program);
|
|
413
|
-
addInitAgentsCommand(import_program.program);
|
|
213
|
+
addTestCommand(program);
|
|
214
|
+
addShowReportCommand(program);
|
|
215
|
+
addMergeReportsCommand(program);
|
|
216
|
+
addClearCacheCommand(program);
|
|
217
|
+
addTestMCPServerCommand(program);
|
|
218
|
+
addTestServerCommand(program);
|
|
219
|
+
addInitAgentsCommand(program);
|
|
414
220
|
// Annotate the CommonJS export names for ESM import in node:
|
|
415
221
|
0 && (module.exports = {
|
|
416
222
|
program
|