@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
|
@@ -32,7 +32,7 @@ __export(agentParser_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(agentParser_exports);
|
|
34
34
|
var import_fs = __toESM(require("fs"));
|
|
35
|
-
|
|
35
|
+
const yaml = require("playwright-core/lib/utilsBundle").yaml;
|
|
36
36
|
async function parseAgentSpec(filePath) {
|
|
37
37
|
const source = await import_fs.default.promises.readFile(filePath, "utf-8");
|
|
38
38
|
const { header, content } = extractYamlAndContent(source);
|
|
@@ -62,7 +62,7 @@ function extractYamlAndContent(markdown) {
|
|
|
62
62
|
const content = contentLines.join("\n");
|
|
63
63
|
let header;
|
|
64
64
|
try {
|
|
65
|
-
header =
|
|
65
|
+
header = yaml.parse(yamlRaw);
|
|
66
66
|
} catch (error) {
|
|
67
67
|
throw new Error(`Failed to parse YAML header: ${error.message}`);
|
|
68
68
|
}
|
|
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var generateAgents_exports = {};
|
|
30
30
|
__export(generateAgents_exports, {
|
|
31
31
|
ClaudeGenerator: () => ClaudeGenerator,
|
|
32
|
+
CodexGenerator: () => CodexGenerator,
|
|
32
33
|
CopilotGenerator: () => CopilotGenerator,
|
|
33
34
|
OpencodeGenerator: () => OpencodeGenerator,
|
|
34
35
|
VSCodeGenerator: () => VSCodeGenerator
|
|
@@ -36,29 +37,29 @@ __export(generateAgents_exports, {
|
|
|
36
37
|
module.exports = __toCommonJS(generateAgents_exports);
|
|
37
38
|
var import_fs = __toESM(require("fs"));
|
|
38
39
|
var import_path = __toESM(require("path"));
|
|
39
|
-
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
40
|
-
var import_utils = require("playwright-core/lib/utils");
|
|
41
40
|
var import_seed = require("../mcp/test/seed");
|
|
42
41
|
var import_agentParser = require("./agentParser");
|
|
42
|
+
const colors = require("playwright-core/lib/utilsBundle").colors;
|
|
43
|
+
const yaml = require("playwright-core/lib/utilsBundle").yaml;
|
|
44
|
+
const { tomlArray, tomlBasicString, tomlMultilineBasicString } = require("playwright-core/lib/coreBundle").iso;
|
|
45
|
+
const { mkdirIfNeeded } = require("playwright-core/lib/coreBundle").utils;
|
|
43
46
|
async function loadAgentSpecs() {
|
|
44
47
|
const files = await import_fs.default.promises.readdir(__dirname);
|
|
45
48
|
return Promise.all(files.filter((file) => file.endsWith(".agent.md")).map((file) => (0, import_agentParser.parseAgentSpec)(import_path.default.join(__dirname, file))));
|
|
46
49
|
}
|
|
47
50
|
class ClaudeGenerator {
|
|
48
|
-
static async init(
|
|
49
|
-
await initRepo(
|
|
51
|
+
static async init(fullConfig, projectName, prompts) {
|
|
52
|
+
await initRepo(fullConfig, projectName, {
|
|
50
53
|
promptsFolder: prompts ? ".claude/prompts" : void 0
|
|
51
54
|
});
|
|
52
55
|
const agents = await loadAgentSpecs();
|
|
53
56
|
await import_fs.default.promises.mkdir(".claude/agents", { recursive: true });
|
|
54
57
|
for (const agent of agents)
|
|
55
58
|
await writeFile(`.claude/agents/${agent.name}.md`, ClaudeGenerator.agentSpec(agent), "\u{1F916}", "agent definition");
|
|
59
|
+
const mcpServer = process.platform === "win32" ? { command: "cmd", args: ["/c", "npx", "playwright", "run-test-mcp-server"] } : { command: "npx", args: ["playwright", "run-test-mcp-server"] };
|
|
56
60
|
await writeFile(".mcp.json", JSON.stringify({
|
|
57
61
|
mcpServers: {
|
|
58
|
-
"playwright-test":
|
|
59
|
-
command: "npx",
|
|
60
|
-
args: ["playwright", "run-test-mcp-server"]
|
|
61
|
-
}
|
|
62
|
+
"playwright-test": mcpServer
|
|
62
63
|
}
|
|
63
64
|
}, null, 2), "\u{1F527}", "mcp configuration");
|
|
64
65
|
initRepoDone();
|
|
@@ -84,15 +85,60 @@ class ClaudeGenerator {
|
|
|
84
85
|
color: agent.color
|
|
85
86
|
};
|
|
86
87
|
lines.push(`---`);
|
|
87
|
-
lines.push(
|
|
88
|
+
lines.push(yaml.stringify(header, { lineWidth: 1e5 }) + `---`);
|
|
88
89
|
lines.push("");
|
|
89
90
|
lines.push(agent.instructions);
|
|
90
91
|
return lines.join("\n");
|
|
91
92
|
}
|
|
92
93
|
}
|
|
94
|
+
class CodexGenerator {
|
|
95
|
+
static async init(fullConfig, projectName, prompts) {
|
|
96
|
+
await initRepo(fullConfig, projectName, {
|
|
97
|
+
promptsFolder: prompts ? ".codex/prompts" : void 0
|
|
98
|
+
});
|
|
99
|
+
const agents = await loadAgentSpecs();
|
|
100
|
+
await import_fs.default.promises.mkdir(".codex/agents", { recursive: true });
|
|
101
|
+
for (const agent of agents)
|
|
102
|
+
await writeFile(`.codex/agents/${CodexGenerator.codexName(agent)}.toml`, CodexGenerator.agentSpec(agent), "\u{1F916}", "agent definition");
|
|
103
|
+
initRepoDone();
|
|
104
|
+
}
|
|
105
|
+
// Codex's subagent registry rejects hyphenated identifiers at spawn time with
|
|
106
|
+
// `error=unknown agent_type '<name>'`. Codex's own documentation only shows
|
|
107
|
+
// snake_case names (`pr_explorer`, `reviewer`, `docs_researcher`, ...), see
|
|
108
|
+
// https://developers.openai.com/codex/subagents. Translate the shared agent
|
|
109
|
+
// name into snake_case so the filename and the `name` field stay in sync.
|
|
110
|
+
static codexName(agent) {
|
|
111
|
+
return agent.name.replace(/-/g, "_");
|
|
112
|
+
}
|
|
113
|
+
static agentSpec(agent) {
|
|
114
|
+
const mcpName = "playwright-test";
|
|
115
|
+
const enabledTools = [];
|
|
116
|
+
for (const tool of agent.tools) {
|
|
117
|
+
const [first, second] = tool.split("/");
|
|
118
|
+
if (second && first === mcpName)
|
|
119
|
+
enabledTools.push(second);
|
|
120
|
+
}
|
|
121
|
+
const sandboxMode = agent.tools.includes("edit") ? "workspace-write" : "read-only";
|
|
122
|
+
const mcpServer = process.platform === "win32" ? { command: "cmd", args: ["/c", "npx", "playwright", "run-test-mcp-server"] } : { command: "npx", args: ["playwright", "run-test-mcp-server"] };
|
|
123
|
+
const examples = agent.examples.length ? ` Examples: ${agent.examples.map((example) => `<example>${example}</example>`).join("")}` : "";
|
|
124
|
+
const lines = [];
|
|
125
|
+
lines.push(`name = ${tomlBasicString(CodexGenerator.codexName(agent))}`);
|
|
126
|
+
lines.push(`description = ${tomlBasicString(agent.description + examples)}`);
|
|
127
|
+
lines.push(`sandbox_mode = ${tomlBasicString(sandboxMode)}`);
|
|
128
|
+
lines.push(`developer_instructions = ${tomlMultilineBasicString(agent.instructions)}`);
|
|
129
|
+
lines.push("");
|
|
130
|
+
lines.push(`[mcp_servers.${mcpName}]`);
|
|
131
|
+
lines.push(`command = ${tomlBasicString(mcpServer.command)}`);
|
|
132
|
+
lines.push(`args = ${tomlArray(mcpServer.args)}`);
|
|
133
|
+
if (enabledTools.length)
|
|
134
|
+
lines.push(`enabled_tools = ${tomlArray(enabledTools)}`);
|
|
135
|
+
lines.push("");
|
|
136
|
+
return lines.join("\n");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
93
139
|
class OpencodeGenerator {
|
|
94
|
-
static async init(
|
|
95
|
-
await initRepo(
|
|
140
|
+
static async init(fullConfig, projectName, prompts) {
|
|
141
|
+
await initRepo(fullConfig, projectName, {
|
|
96
142
|
defaultAgentName: "Build",
|
|
97
143
|
promptsFolder: prompts ? ".opencode/prompts" : void 0
|
|
98
144
|
});
|
|
@@ -147,8 +193,8 @@ class OpencodeGenerator {
|
|
|
147
193
|
}
|
|
148
194
|
}
|
|
149
195
|
class CopilotGenerator {
|
|
150
|
-
static async init(
|
|
151
|
-
await initRepo(
|
|
196
|
+
static async init(fullConfig, projectName, prompts) {
|
|
197
|
+
await initRepo(fullConfig, projectName, {
|
|
152
198
|
defaultAgentName: "agent",
|
|
153
199
|
promptsFolder: prompts ? ".github/prompts" : void 0,
|
|
154
200
|
promptSuffix: "prompt"
|
|
@@ -184,11 +230,11 @@ class CopilotGenerator {
|
|
|
184
230
|
"name": agent.name,
|
|
185
231
|
"description": agent.description + examples,
|
|
186
232
|
"tools": agent.tools,
|
|
187
|
-
"model": "Claude Sonnet 4",
|
|
233
|
+
"model": "Claude Sonnet 4.6",
|
|
188
234
|
"mcp-servers": CopilotGenerator.mcpServers
|
|
189
235
|
};
|
|
190
236
|
lines.push(`---`);
|
|
191
|
-
lines.push(
|
|
237
|
+
lines.push(yaml.stringify(header, { lineWidth: 1e5 }) + `---`);
|
|
192
238
|
lines.push("");
|
|
193
239
|
lines.push(agent.instructions);
|
|
194
240
|
lines.push("");
|
|
@@ -209,8 +255,8 @@ class CopilotGenerator {
|
|
|
209
255
|
}
|
|
210
256
|
}
|
|
211
257
|
class VSCodeGenerator {
|
|
212
|
-
static async init(
|
|
213
|
-
await initRepo(
|
|
258
|
+
static async init(fullConfig, projectName) {
|
|
259
|
+
await initRepo(fullConfig, projectName, {
|
|
214
260
|
promptsFolder: void 0
|
|
215
261
|
});
|
|
216
262
|
const agents = await loadAgentSpecs();
|
|
@@ -285,8 +331,8 @@ class VSCodeGenerator {
|
|
|
285
331
|
}
|
|
286
332
|
}
|
|
287
333
|
async function writeFile(filePath, content, icon, description) {
|
|
288
|
-
console.log(` ${icon} ${import_path.default.relative(process.cwd(), filePath)} ${
|
|
289
|
-
await
|
|
334
|
+
console.log(` ${icon} ${import_path.default.relative(process.cwd(), filePath)} ${colors.dim("- " + description)}`);
|
|
335
|
+
await mkdirIfNeeded(filePath);
|
|
290
336
|
await import_fs.default.promises.writeFile(filePath, content, "utf-8");
|
|
291
337
|
}
|
|
292
338
|
async function deleteFile(filePath, description) {
|
|
@@ -296,11 +342,11 @@ async function deleteFile(filePath, description) {
|
|
|
296
342
|
} catch {
|
|
297
343
|
return;
|
|
298
344
|
}
|
|
299
|
-
console.log(` \u2702\uFE0F ${import_path.default.relative(process.cwd(), filePath)} ${
|
|
345
|
+
console.log(` \u2702\uFE0F ${import_path.default.relative(process.cwd(), filePath)} ${colors.dim("- " + description)}`);
|
|
300
346
|
await import_fs.default.promises.unlink(filePath);
|
|
301
347
|
}
|
|
302
|
-
async function initRepo(
|
|
303
|
-
const project = (0, import_seed.seedProject)(
|
|
348
|
+
async function initRepo(fullConfig, projectName, options) {
|
|
349
|
+
const project = (0, import_seed.seedProject)(fullConfig, projectName);
|
|
304
350
|
console.log(` \u{1F3AD} Using project "${project.project.name}" as a primary project`);
|
|
305
351
|
if (!import_fs.default.existsSync("specs")) {
|
|
306
352
|
await import_fs.default.promises.mkdir("specs");
|
|
@@ -342,6 +388,7 @@ async function loadPrompt(file, params) {
|
|
|
342
388
|
// Annotate the CommonJS export names for ESM import in node:
|
|
343
389
|
0 && (module.exports = {
|
|
344
390
|
ClaudeGenerator,
|
|
391
|
+
CodexGenerator,
|
|
345
392
|
CopilotGenerator,
|
|
346
393
|
OpencodeGenerator,
|
|
347
394
|
VSCodeGenerator
|
|
@@ -9,6 +9,7 @@ tools:
|
|
|
9
9
|
- playwright-test/browser_console_messages
|
|
10
10
|
- playwright-test/browser_evaluate
|
|
11
11
|
- playwright-test/browser_generate_locator
|
|
12
|
+
- playwright-test/browser_network_request
|
|
12
13
|
- playwright-test/browser_network_requests
|
|
13
14
|
- playwright-test/browser_snapshot
|
|
14
15
|
- playwright-test/test_debug
|
|
@@ -15,9 +15,10 @@ tools:
|
|
|
15
15
|
- playwright-test/browser_hover
|
|
16
16
|
- playwright-test/browser_navigate
|
|
17
17
|
- playwright-test/browser_navigate_back
|
|
18
|
+
- playwright-test/browser_network_request
|
|
18
19
|
- playwright-test/browser_network_requests
|
|
19
20
|
- playwright-test/browser_press_key
|
|
20
|
-
- playwright-test/
|
|
21
|
+
- playwright-test/browser_run_code_unsafe
|
|
21
22
|
- playwright-test/browser_select_option
|
|
22
23
|
- playwright-test/browser_snapshot
|
|
23
24
|
- playwright-test/browser_take_screenshot
|
|
@@ -0,0 +1,78 @@
|
|
|
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 reportActions_exports = {};
|
|
30
|
+
__export(reportActions_exports, {
|
|
31
|
+
mergeReports: () => mergeReports,
|
|
32
|
+
showReport: () => showReport
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(reportActions_exports);
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_common = require("../common");
|
|
38
|
+
var import_runner = require("../runner");
|
|
39
|
+
const { gracefullyProcessExitDoNotHang } = require("playwright-core/lib/coreBundle").utils;
|
|
40
|
+
async function showReport(report, host, port) {
|
|
41
|
+
await import_runner.html.showHTMLReport(report, host, port);
|
|
42
|
+
}
|
|
43
|
+
async function mergeReports(reportDir, opts) {
|
|
44
|
+
const configFile = opts.config;
|
|
45
|
+
const config = configFile ? await import_common.configLoader.loadConfigFromFile(configFile) : await import_common.configLoader.loadEmptyConfigForMergeReports();
|
|
46
|
+
const dir = import_path.default.resolve(process.cwd(), reportDir || "");
|
|
47
|
+
const dirStat = await import_fs.default.promises.stat(dir).catch((e) => null);
|
|
48
|
+
if (!dirStat)
|
|
49
|
+
throw new Error("Directory does not exist: " + dir);
|
|
50
|
+
if (!dirStat.isDirectory())
|
|
51
|
+
throw new Error(`"${dir}" is not a directory`);
|
|
52
|
+
let reporterDescriptions = resolveReporterOption(opts.reporter);
|
|
53
|
+
if (!reporterDescriptions && configFile)
|
|
54
|
+
reporterDescriptions = config.config.reporter;
|
|
55
|
+
if (!reporterDescriptions)
|
|
56
|
+
reporterDescriptions = [[import_common.config.defaultReporter]];
|
|
57
|
+
const rootDirOverride = configFile ? config.config.rootDir : void 0;
|
|
58
|
+
await import_runner.merge.createMergedReport(config, dir, reporterDescriptions, rootDirOverride);
|
|
59
|
+
gracefullyProcessExitDoNotHang(0);
|
|
60
|
+
}
|
|
61
|
+
function resolveReporterOption(reporter) {
|
|
62
|
+
if (!reporter || !reporter.length)
|
|
63
|
+
return void 0;
|
|
64
|
+
return reporter.split(",").map((r) => [resolveReporter(r)]);
|
|
65
|
+
}
|
|
66
|
+
function resolveReporter(id) {
|
|
67
|
+
if (import_common.builtInReporters.includes(id))
|
|
68
|
+
return id;
|
|
69
|
+
const localPath = import_path.default.resolve(process.cwd(), id);
|
|
70
|
+
if (import_fs.default.existsSync(localPath))
|
|
71
|
+
return localPath;
|
|
72
|
+
return require.resolve(id, { paths: [process.cwd()] });
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
mergeReports,
|
|
77
|
+
showReport
|
|
78
|
+
});
|
|
@@ -0,0 +1,213 @@
|
|
|
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 testActions_exports = {};
|
|
30
|
+
__export(testActions_exports, {
|
|
31
|
+
clearCache: () => clearCache,
|
|
32
|
+
runTestServerAction: () => runTestServerAction,
|
|
33
|
+
runTests: () => runTests
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(testActions_exports);
|
|
36
|
+
var import_fs = __toESM(require("fs"));
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_common = require("../common");
|
|
39
|
+
var import_runner = require("../runner");
|
|
40
|
+
const { gracefullyProcessExitDoNotHang } = require("playwright-core/lib/coreBundle").utils;
|
|
41
|
+
const { startProfiling, stopProfiling } = require("playwright-core/lib/coreBundle").utils;
|
|
42
|
+
async function runTests(args, opts) {
|
|
43
|
+
await startProfiling();
|
|
44
|
+
const cliOverrides = overridesFromOptions(opts);
|
|
45
|
+
cliOverrides.argv = process.argv;
|
|
46
|
+
const config = await import_common.configLoader.loadConfigFromFile(opts.config, cliOverrides, opts.deps === false);
|
|
47
|
+
const options = {
|
|
48
|
+
locations: args.length ? args : void 0,
|
|
49
|
+
grep: opts.grep,
|
|
50
|
+
grepInvert: opts.grepInvert,
|
|
51
|
+
onlyChanged: opts.onlyChanged === true ? "HEAD" : opts.onlyChanged,
|
|
52
|
+
listMode: !!opts.list,
|
|
53
|
+
projectFilter: opts.project || void 0,
|
|
54
|
+
passWithNoTests: !!opts.passWithNoTests,
|
|
55
|
+
lastFailed: !!opts.lastFailed,
|
|
56
|
+
lastFailedFile: opts.lastFailedFile,
|
|
57
|
+
testList: opts.testList ? import_path.default.resolve(process.cwd(), opts.testList) : void 0,
|
|
58
|
+
testListInvert: opts.testListInvert ? import_path.default.resolve(process.cwd(), opts.testListInvert) : void 0,
|
|
59
|
+
shardWeights: resolveShardWeightsOption()
|
|
60
|
+
};
|
|
61
|
+
import_runner.projectUtils.filterProjects(config.projects, options.projectFilter);
|
|
62
|
+
if (opts.ui || opts.uiHost || opts.uiPort) {
|
|
63
|
+
if (opts.onlyChanged)
|
|
64
|
+
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.`);
|
|
65
|
+
const status2 = await import_runner.testServer.runUIMode(opts.config, cliOverrides, {
|
|
66
|
+
host: opts.uiHost,
|
|
67
|
+
port: opts.uiPort ? +opts.uiPort : void 0,
|
|
68
|
+
args,
|
|
69
|
+
grep: opts.grep,
|
|
70
|
+
grepInvert: opts.grepInvert,
|
|
71
|
+
project: opts.project || void 0,
|
|
72
|
+
reporter: Array.isArray(opts.reporter) ? opts.reporter : opts.reporter ? [opts.reporter] : void 0
|
|
73
|
+
});
|
|
74
|
+
await stopProfiling("runner");
|
|
75
|
+
const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
|
|
76
|
+
gracefullyProcessExitDoNotHang(exitCode2);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (process.env.PWTEST_WATCH) {
|
|
80
|
+
if (opts.onlyChanged)
|
|
81
|
+
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.`);
|
|
82
|
+
const status2 = await import_runner.watchMode.runWatchModeLoop(
|
|
83
|
+
import_common.configLoader.resolveConfigLocation(opts.config),
|
|
84
|
+
{
|
|
85
|
+
projects: opts.project,
|
|
86
|
+
files: args,
|
|
87
|
+
grep: opts.grep
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
await stopProfiling("runner");
|
|
91
|
+
const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
|
|
92
|
+
gracefullyProcessExitDoNotHang(exitCode2);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const status = await import_runner.testRunner.runAllTestsWithConfig(config, options);
|
|
96
|
+
await stopProfiling("runner");
|
|
97
|
+
const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
|
|
98
|
+
gracefullyProcessExitDoNotHang(exitCode);
|
|
99
|
+
}
|
|
100
|
+
async function runTestServerAction(opts) {
|
|
101
|
+
const host = opts.host;
|
|
102
|
+
const port = opts.port ? +opts.port : void 0;
|
|
103
|
+
const status = await import_runner.testServer.runTestServer(opts.config, {}, { host, port });
|
|
104
|
+
const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
|
|
105
|
+
gracefullyProcessExitDoNotHang(exitCode);
|
|
106
|
+
}
|
|
107
|
+
async function clearCache(opts) {
|
|
108
|
+
const runner = new import_runner.testRunner.TestRunner(import_common.configLoader.resolveConfigLocation(opts.config), {});
|
|
109
|
+
const { status } = await runner.clearCache(import_runner.runnerReporters.createErrorCollectingReporter(import_runner.base.terminalScreen));
|
|
110
|
+
const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
|
|
111
|
+
gracefullyProcessExitDoNotHang(exitCode);
|
|
112
|
+
}
|
|
113
|
+
function overridesFromOptions(options) {
|
|
114
|
+
if (options.ui) {
|
|
115
|
+
options.debug = void 0;
|
|
116
|
+
options.trace = void 0;
|
|
117
|
+
}
|
|
118
|
+
const overrides = {
|
|
119
|
+
debug: options.debug,
|
|
120
|
+
failOnFlakyTests: options.failOnFlakyTests ? true : void 0,
|
|
121
|
+
forbidOnly: options.forbidOnly ? true : void 0,
|
|
122
|
+
fullyParallel: options.fullyParallel ? true : void 0,
|
|
123
|
+
globalTimeout: options.globalTimeout ? parseInt(options.globalTimeout, 10) : void 0,
|
|
124
|
+
maxFailures: options.x ? 1 : options.maxFailures ? parseInt(options.maxFailures, 10) : void 0,
|
|
125
|
+
outputDir: options.output ? import_path.default.resolve(process.cwd(), options.output) : void 0,
|
|
126
|
+
pause: !!process.env.PWPAUSE,
|
|
127
|
+
quiet: options.quiet ? options.quiet : void 0,
|
|
128
|
+
repeatEach: options.repeatEach ? parseInt(options.repeatEach, 10) : void 0,
|
|
129
|
+
retries: options.retries ? parseInt(options.retries, 10) : void 0,
|
|
130
|
+
reporter: resolveReporterOption(options.reporter),
|
|
131
|
+
shard: resolveShardOption(options.shard),
|
|
132
|
+
timeout: options.timeout ? parseInt(options.timeout, 10) : void 0,
|
|
133
|
+
tsconfig: options.tsconfig ? import_path.default.resolve(process.cwd(), options.tsconfig) : void 0,
|
|
134
|
+
ignoreSnapshots: options.ignoreSnapshots ? !!options.ignoreSnapshots : void 0,
|
|
135
|
+
updateSnapshots: options.updateSnapshots,
|
|
136
|
+
updateSourceMethod: options.updateSourceMethod,
|
|
137
|
+
use: {
|
|
138
|
+
trace: options.trace
|
|
139
|
+
},
|
|
140
|
+
workers: options.workers
|
|
141
|
+
};
|
|
142
|
+
if (options.browser) {
|
|
143
|
+
const browserOpt = options.browser.toLowerCase();
|
|
144
|
+
if (!["all", "chromium", "firefox", "webkit"].includes(browserOpt))
|
|
145
|
+
throw new Error(`Unsupported browser "${options.browser}", must be one of "all", "chromium", "firefox" or "webkit"`);
|
|
146
|
+
const browserNames = browserOpt === "all" ? ["chromium", "firefox", "webkit"] : [browserOpt];
|
|
147
|
+
overrides.projects = browserNames.map((browserName) => {
|
|
148
|
+
return {
|
|
149
|
+
name: browserName,
|
|
150
|
+
use: { browserName }
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (options.headed)
|
|
155
|
+
overrides.use.headless = false;
|
|
156
|
+
if (options.debug === "inspector") {
|
|
157
|
+
overrides.use.headless = false;
|
|
158
|
+
process.env.PWDEBUG = "1";
|
|
159
|
+
}
|
|
160
|
+
if (overrides.tsconfig && !import_fs.default.existsSync(overrides.tsconfig))
|
|
161
|
+
throw new Error(`--tsconfig "${options.tsconfig}" does not exist`);
|
|
162
|
+
return overrides;
|
|
163
|
+
}
|
|
164
|
+
function resolveReporterOption(reporter) {
|
|
165
|
+
if (!reporter || !reporter.length)
|
|
166
|
+
return void 0;
|
|
167
|
+
return reporter.split(",").map((r) => [resolveReporter(r)]);
|
|
168
|
+
}
|
|
169
|
+
function resolveShardOption(shard) {
|
|
170
|
+
if (!shard)
|
|
171
|
+
return void 0;
|
|
172
|
+
const shardPair = shard.split("/");
|
|
173
|
+
if (shardPair.length !== 2) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`--shard "${shard}", expected format is "current/all", 1-based, for example "3/5".`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
const current = parseInt(shardPair[0], 10);
|
|
179
|
+
const total = parseInt(shardPair[1], 10);
|
|
180
|
+
if (isNaN(total) || total < 1)
|
|
181
|
+
throw new Error(`--shard "${shard}" total must be a positive number`);
|
|
182
|
+
if (isNaN(current) || current < 1 || current > total) {
|
|
183
|
+
throw new Error(
|
|
184
|
+
`--shard "${shard}" current must be a positive number, not greater than shard total`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
return { current, total };
|
|
188
|
+
}
|
|
189
|
+
function resolveShardWeightsOption() {
|
|
190
|
+
const shardWeights = process.env.PWTEST_SHARD_WEIGHTS;
|
|
191
|
+
if (!shardWeights)
|
|
192
|
+
return void 0;
|
|
193
|
+
return shardWeights.split(":").map((w) => {
|
|
194
|
+
const weight = parseInt(w, 10);
|
|
195
|
+
if (isNaN(weight) || weight < 0)
|
|
196
|
+
throw new Error(`PWTEST_SHARD_WEIGHTS="${shardWeights}" weights must be non-negative numbers`);
|
|
197
|
+
return weight;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function resolveReporter(id) {
|
|
201
|
+
if (import_common.builtInReporters.includes(id))
|
|
202
|
+
return id;
|
|
203
|
+
const localPath = import_path.default.resolve(process.cwd(), id);
|
|
204
|
+
if (import_fs.default.existsSync(localPath))
|
|
205
|
+
return localPath;
|
|
206
|
+
return require.resolve(id, { paths: [process.cwd()] });
|
|
207
|
+
}
|
|
208
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
209
|
+
0 && (module.exports = {
|
|
210
|
+
clearCache,
|
|
211
|
+
runTestServerAction,
|
|
212
|
+
runTests
|
|
213
|
+
});
|