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
|
@@ -0,0 +1,263 @@
|
|
|
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 generateAgents_exports = {};
|
|
30
|
+
__export(generateAgents_exports, {
|
|
31
|
+
initClaudeCodeRepo: () => initClaudeCodeRepo,
|
|
32
|
+
initOpencodeRepo: () => initOpencodeRepo,
|
|
33
|
+
initVSCodeRepo: () => initVSCodeRepo
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(generateAgents_exports);
|
|
36
|
+
var import_fs = __toESM(require("fs"));
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
39
|
+
class AgentParser {
|
|
40
|
+
static async parseFile(filePath) {
|
|
41
|
+
const rawMarkdown = await import_fs.default.promises.readFile(filePath, "utf-8");
|
|
42
|
+
const { header, content } = this.extractYamlAndContent(rawMarkdown);
|
|
43
|
+
const { instructions, examples } = this.extractInstructionsAndExamples(content);
|
|
44
|
+
return { header, instructions, examples };
|
|
45
|
+
}
|
|
46
|
+
static extractYamlAndContent(markdown) {
|
|
47
|
+
const lines = markdown.split("\n");
|
|
48
|
+
if (lines[0] !== "---")
|
|
49
|
+
throw new Error("Markdown file must start with YAML front matter (---)");
|
|
50
|
+
let yamlEndIndex = -1;
|
|
51
|
+
for (let i = 1; i < lines.length; i++) {
|
|
52
|
+
if (lines[i] === "---") {
|
|
53
|
+
yamlEndIndex = i;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (yamlEndIndex === -1)
|
|
58
|
+
throw new Error("YAML front matter must be closed with ---");
|
|
59
|
+
const yamlLines = lines.slice(1, yamlEndIndex);
|
|
60
|
+
const yamlRaw = yamlLines.join("\n");
|
|
61
|
+
const contentLines = lines.slice(yamlEndIndex + 1);
|
|
62
|
+
const content = contentLines.join("\n");
|
|
63
|
+
let header;
|
|
64
|
+
try {
|
|
65
|
+
header = import_utilsBundle.yaml.parse(yamlRaw);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw new Error(`Failed to parse YAML header: ${error.message}`);
|
|
68
|
+
}
|
|
69
|
+
if (!header.name)
|
|
70
|
+
throw new Error('YAML header must contain a "name" field');
|
|
71
|
+
if (!header.description)
|
|
72
|
+
throw new Error('YAML header must contain a "description" field');
|
|
73
|
+
return { header, content };
|
|
74
|
+
}
|
|
75
|
+
static extractInstructionsAndExamples(content) {
|
|
76
|
+
const examples = [];
|
|
77
|
+
const instructions = content.split("<example>")[0].trim();
|
|
78
|
+
const exampleRegex = /<example>([\s\S]*?)<\/example>/g;
|
|
79
|
+
let match;
|
|
80
|
+
while ((match = exampleRegex.exec(content)) !== null) {
|
|
81
|
+
const example = match[1].trim();
|
|
82
|
+
examples.push(example.replace(/[\n]/g, " ").replace(/ +/g, " "));
|
|
83
|
+
}
|
|
84
|
+
return { instructions, examples };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const claudeToolMap = /* @__PURE__ */ new Map([
|
|
88
|
+
["ls", ["Glob"]],
|
|
89
|
+
["grep", ["Grep"]],
|
|
90
|
+
["read", ["Read"]],
|
|
91
|
+
["edit", ["Edit", "MultiEdit"]],
|
|
92
|
+
["write", ["Write"]]
|
|
93
|
+
]);
|
|
94
|
+
const commonMcpServers = {
|
|
95
|
+
playwrightTest: {
|
|
96
|
+
type: "local",
|
|
97
|
+
command: "npx",
|
|
98
|
+
args: ["playwright", "run-test-mcp-server"]
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
function saveAsClaudeCode(agent) {
|
|
102
|
+
function asClaudeTool(tool) {
|
|
103
|
+
const [first, second] = tool.split("/");
|
|
104
|
+
if (!second)
|
|
105
|
+
return (claudeToolMap.get(first) || [first]).join(", ");
|
|
106
|
+
return `mcp__${first}__${second}`;
|
|
107
|
+
}
|
|
108
|
+
const lines = [];
|
|
109
|
+
lines.push(`---`);
|
|
110
|
+
lines.push(`name: playwright-test-${agent.header.name}`);
|
|
111
|
+
lines.push(`description: ${agent.header.description}. Examples: ${agent.examples.map((example) => `<example>${example}</example>`).join("")}`);
|
|
112
|
+
lines.push(`tools: ${agent.header.tools.map((tool) => asClaudeTool(tool)).join(", ")}`);
|
|
113
|
+
lines.push(`model: ${agent.header.model}`);
|
|
114
|
+
lines.push(`color: ${agent.header.color}`);
|
|
115
|
+
lines.push(`---`);
|
|
116
|
+
lines.push("");
|
|
117
|
+
lines.push(agent.instructions);
|
|
118
|
+
return lines.join("\n");
|
|
119
|
+
}
|
|
120
|
+
const opencodeToolMap = /* @__PURE__ */ new Map([
|
|
121
|
+
["ls", ["ls", "glob"]],
|
|
122
|
+
["grep", ["grep"]],
|
|
123
|
+
["read", ["read"]],
|
|
124
|
+
["edit", ["edit"]],
|
|
125
|
+
["write", ["write"]]
|
|
126
|
+
]);
|
|
127
|
+
function saveAsOpencodeJson(agents) {
|
|
128
|
+
function asOpencodeTool(tools, tool) {
|
|
129
|
+
const [first, second] = tool.split("/");
|
|
130
|
+
if (!second) {
|
|
131
|
+
for (const tool2 of opencodeToolMap.get(first) || [first])
|
|
132
|
+
tools[tool2] = true;
|
|
133
|
+
} else {
|
|
134
|
+
tools[`${first}*${second}`] = true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const result = {};
|
|
138
|
+
result["$schema"] = "https://opencode.ai/config.json";
|
|
139
|
+
result["mcp"] = {};
|
|
140
|
+
result["tools"] = {
|
|
141
|
+
"playwright*": false
|
|
142
|
+
};
|
|
143
|
+
result["agent"] = {};
|
|
144
|
+
for (const agent of agents) {
|
|
145
|
+
const tools = {};
|
|
146
|
+
result["agent"]["playwright-test-" + agent.header.name] = {
|
|
147
|
+
description: agent.header.description,
|
|
148
|
+
mode: "subagent",
|
|
149
|
+
prompt: `{file:.opencode/prompts/playwright-test-${agent.header.name}.md}`,
|
|
150
|
+
tools
|
|
151
|
+
};
|
|
152
|
+
for (const tool of agent.header.tools)
|
|
153
|
+
asOpencodeTool(tools, tool);
|
|
154
|
+
}
|
|
155
|
+
const server = commonMcpServers.playwrightTest;
|
|
156
|
+
result["mcp"]["playwright-test"] = {
|
|
157
|
+
type: server.type,
|
|
158
|
+
command: [server.command, ...server.args],
|
|
159
|
+
enabled: true
|
|
160
|
+
};
|
|
161
|
+
return JSON.stringify(result, null, 2);
|
|
162
|
+
}
|
|
163
|
+
async function loadAgents() {
|
|
164
|
+
const files = await import_fs.default.promises.readdir(__dirname);
|
|
165
|
+
return Promise.all(files.filter((file) => file.endsWith(".md")).map((file) => AgentParser.parseFile(import_path.default.join(__dirname, file))));
|
|
166
|
+
}
|
|
167
|
+
async function writeFile(filePath, content) {
|
|
168
|
+
console.log(`Writing file: ${filePath}`);
|
|
169
|
+
await import_fs.default.promises.writeFile(filePath, content, "utf-8");
|
|
170
|
+
}
|
|
171
|
+
async function initClaudeCodeRepo() {
|
|
172
|
+
const agents = await loadAgents();
|
|
173
|
+
await import_fs.default.promises.mkdir(".claude/agents", { recursive: true });
|
|
174
|
+
for (const agent of agents)
|
|
175
|
+
await writeFile(`.claude/agents/playwright-test-${agent.header.name}.md`, saveAsClaudeCode(agent));
|
|
176
|
+
await writeFile(".mcp.json", JSON.stringify({
|
|
177
|
+
mcpServers: {
|
|
178
|
+
"playwright-test": {
|
|
179
|
+
command: commonMcpServers.playwrightTest.command,
|
|
180
|
+
args: commonMcpServers.playwrightTest.args
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}, null, 2));
|
|
184
|
+
}
|
|
185
|
+
const vscodeToolMap = /* @__PURE__ */ new Map([
|
|
186
|
+
["ls", ["search/listDirectory", "search/fileSearch"]],
|
|
187
|
+
["grep", ["search/textSearch"]],
|
|
188
|
+
["read", ["search/readFile"]],
|
|
189
|
+
["edit", ["edit/editFiles"]],
|
|
190
|
+
["write", ["edit/createFile", "edit/createDirectory"]]
|
|
191
|
+
]);
|
|
192
|
+
const vscodeToolsOrder = ["edit/createFile", "edit/createDirectory", "edit/editFiles", "search/fileSearch", "search/textSearch", "search/listDirectory", "search/readFile"];
|
|
193
|
+
const vscodeMcpName = "playwright-test";
|
|
194
|
+
function saveAsVSCodeChatmode(agent) {
|
|
195
|
+
function asVscodeTool(tool) {
|
|
196
|
+
const [first, second] = tool.split("/");
|
|
197
|
+
if (second)
|
|
198
|
+
return `${vscodeMcpName}/${second}`;
|
|
199
|
+
return vscodeToolMap.get(first) || first;
|
|
200
|
+
}
|
|
201
|
+
const tools = agent.header.tools.map(asVscodeTool).flat().sort((a, b) => {
|
|
202
|
+
const indexA = vscodeToolsOrder.indexOf(a);
|
|
203
|
+
const indexB = vscodeToolsOrder.indexOf(b);
|
|
204
|
+
if (indexA === -1 && indexB === -1)
|
|
205
|
+
return a.localeCompare(b);
|
|
206
|
+
if (indexA === -1)
|
|
207
|
+
return 1;
|
|
208
|
+
if (indexB === -1)
|
|
209
|
+
return -1;
|
|
210
|
+
return indexA - indexB;
|
|
211
|
+
}).map((tool) => `'${tool}'`).join(", ");
|
|
212
|
+
const lines = [];
|
|
213
|
+
lines.push(`---`);
|
|
214
|
+
lines.push(`description: ${agent.header.description}.`);
|
|
215
|
+
lines.push(`tools: [${tools}]`);
|
|
216
|
+
lines.push(`---`);
|
|
217
|
+
lines.push("");
|
|
218
|
+
lines.push(agent.instructions);
|
|
219
|
+
for (const example of agent.examples)
|
|
220
|
+
lines.push(`<example>${example}</example>`);
|
|
221
|
+
return lines.join("\n");
|
|
222
|
+
}
|
|
223
|
+
async function initVSCodeRepo() {
|
|
224
|
+
const agents = await loadAgents();
|
|
225
|
+
await import_fs.default.promises.mkdir(".github/chatmodes", { recursive: true });
|
|
226
|
+
for (const agent of agents)
|
|
227
|
+
await writeFile(`.github/chatmodes/${agent.header.name === "planner" ? " " : ""}\u{1F3AD} ${agent.header.name}.chatmode.md`, saveAsVSCodeChatmode(agent));
|
|
228
|
+
await import_fs.default.promises.mkdir(".vscode", { recursive: true });
|
|
229
|
+
const mcpJsonPath = ".vscode/mcp.json";
|
|
230
|
+
let mcpJson = {
|
|
231
|
+
servers: {},
|
|
232
|
+
inputs: []
|
|
233
|
+
};
|
|
234
|
+
try {
|
|
235
|
+
mcpJson = JSON.parse(import_fs.default.readFileSync(mcpJsonPath, "utf8"));
|
|
236
|
+
} catch {
|
|
237
|
+
}
|
|
238
|
+
if (!mcpJson.servers)
|
|
239
|
+
mcpJson.servers = {};
|
|
240
|
+
mcpJson.servers["playwright-test"] = {
|
|
241
|
+
type: "stdio",
|
|
242
|
+
command: commonMcpServers.playwrightTest.command,
|
|
243
|
+
args: commonMcpServers.playwrightTest.args
|
|
244
|
+
};
|
|
245
|
+
await writeFile(mcpJsonPath, JSON.stringify(mcpJson, null, 2));
|
|
246
|
+
}
|
|
247
|
+
async function initOpencodeRepo() {
|
|
248
|
+
const agents = await loadAgents();
|
|
249
|
+
await import_fs.default.promises.mkdir(".opencode/prompts", { recursive: true });
|
|
250
|
+
for (const agent of agents) {
|
|
251
|
+
const prompt = [agent.instructions];
|
|
252
|
+
prompt.push("");
|
|
253
|
+
prompt.push(...agent.examples.map((example) => `<example>${example}</example>`));
|
|
254
|
+
await writeFile(`.opencode/prompts/playwright-test-${agent.header.name}.md`, prompt.join("\n"));
|
|
255
|
+
}
|
|
256
|
+
await writeFile("opencode.json", saveAsOpencodeJson(agents));
|
|
257
|
+
}
|
|
258
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
259
|
+
0 && (module.exports = {
|
|
260
|
+
initClaudeCodeRepo,
|
|
261
|
+
initOpencodeRepo,
|
|
262
|
+
initVSCodeRepo
|
|
263
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: generator
|
|
3
|
+
description: Use this agent when you need to create automated browser tests using Playwright
|
|
4
|
+
model: sonnet
|
|
5
|
+
color: blue
|
|
6
|
+
tools:
|
|
7
|
+
- ls
|
|
8
|
+
- grep
|
|
9
|
+
- read
|
|
10
|
+
- playwright-test/browser_click
|
|
11
|
+
- playwright-test/browser_drag
|
|
12
|
+
- playwright-test/browser_evaluate
|
|
13
|
+
- playwright-test/browser_file_upload
|
|
14
|
+
- playwright-test/browser_handle_dialog
|
|
15
|
+
- playwright-test/browser_hover
|
|
16
|
+
- playwright-test/browser_navigate
|
|
17
|
+
- playwright-test/browser_press_key
|
|
18
|
+
- playwright-test/browser_select_option
|
|
19
|
+
- playwright-test/browser_snapshot
|
|
20
|
+
- playwright-test/browser_type
|
|
21
|
+
- playwright-test/browser_verify_element_visible
|
|
22
|
+
- playwright-test/browser_verify_list_visible
|
|
23
|
+
- playwright-test/browser_verify_text_visible
|
|
24
|
+
- playwright-test/browser_verify_value
|
|
25
|
+
- playwright-test/browser_wait_for
|
|
26
|
+
- playwright-test/generator_read_log
|
|
27
|
+
- playwright-test/generator_setup_page
|
|
28
|
+
- playwright-test/generator_write_test
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
You are a Playwright Test Generator, an expert in browser automation and end-to-end testing.
|
|
32
|
+
Your specialty is creating robust, reliable Playwright tests that accurately simulate user interactions and validate
|
|
33
|
+
application behavior.
|
|
34
|
+
|
|
35
|
+
# For each test you generate
|
|
36
|
+
- Obtain the test plan with all the steps and verification specification
|
|
37
|
+
- Run the `generator_setup_page` tool to set up page for the scenario
|
|
38
|
+
- For each step and verification in the scenario, do the following:
|
|
39
|
+
- Use Playwright tool to manually execute it in real-time.
|
|
40
|
+
- Use the step description as the intent for each Playwright tool call.
|
|
41
|
+
- Retrieve generator log via `generator_read_log`
|
|
42
|
+
- Immediately after reading the test log, invoke `generator_write_test` with the generated source code
|
|
43
|
+
- File should contain single test
|
|
44
|
+
- File name must be fs-friendly scenario name
|
|
45
|
+
- Test must be placed in a describe matching the top-level test plan item
|
|
46
|
+
- Test title must match the scenario name
|
|
47
|
+
- Includes a comment with the step text before each step execution. Do not duplicate comments if step requires
|
|
48
|
+
multiple actions.
|
|
49
|
+
- Always use best practices from the log when generating tests.
|
|
50
|
+
|
|
51
|
+
<example-generation>
|
|
52
|
+
For following plan:
|
|
53
|
+
|
|
54
|
+
```markdown file=specs/plan.md
|
|
55
|
+
### 1. Adding New Todos
|
|
56
|
+
**Seed:** `tests/seed.spec.ts`
|
|
57
|
+
|
|
58
|
+
#### 1.1 Add Valid Todo
|
|
59
|
+
**Steps:**
|
|
60
|
+
1. Click in the "What needs to be done?" input field
|
|
61
|
+
|
|
62
|
+
#### 1.2 Add Multiple Todos
|
|
63
|
+
...
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Following file is generated:
|
|
67
|
+
|
|
68
|
+
```ts file=add-valid-todo.spec.ts
|
|
69
|
+
// spec: specs/plan.md
|
|
70
|
+
// seed: tests/seed.spec.ts
|
|
71
|
+
|
|
72
|
+
test.describe('Adding New Todos', () => {
|
|
73
|
+
test('Add Valid Todo', async { page } => {
|
|
74
|
+
// 1. Click in the "What needs to be done?" input field
|
|
75
|
+
await page.click(...);
|
|
76
|
+
|
|
77
|
+
...
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
</example-generation>
|
|
82
|
+
|
|
83
|
+
<example>
|
|
84
|
+
Context: User wants to test a login flow on their web application.
|
|
85
|
+
user: 'I need a test that logs into my app at localhost:3000 with username admin@test.com and password 123456, then
|
|
86
|
+
verifies the dashboard page loads'
|
|
87
|
+
assistant: 'I'll use the generator agent to create and validate this login test for you'
|
|
88
|
+
<commentary>
|
|
89
|
+
The user needs a specific browser automation test created, which is exactly what the generator agent
|
|
90
|
+
is designed for.
|
|
91
|
+
</commentary>
|
|
92
|
+
</example>
|
|
93
|
+
<example>
|
|
94
|
+
Context: User has built a new checkout flow and wants to ensure it works correctly.
|
|
95
|
+
user: 'Can you create a test that adds items to cart, proceeds to checkout, fills in payment details, and confirms the
|
|
96
|
+
order?'
|
|
97
|
+
assistant: 'I'll use the generator agent to build a comprehensive checkout flow test'
|
|
98
|
+
<commentary>
|
|
99
|
+
This is a complex user journey that needs to be automated and tested, perfect for the generator
|
|
100
|
+
agent.
|
|
101
|
+
</commentary>
|
|
102
|
+
</example>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: healer
|
|
3
|
+
description: Use this agent when you need to debug and fix failing Playwright tests
|
|
4
|
+
color: red
|
|
5
|
+
model: sonnet
|
|
6
|
+
tools:
|
|
7
|
+
- ls
|
|
8
|
+
- grep
|
|
9
|
+
- read
|
|
10
|
+
- write
|
|
11
|
+
- edit
|
|
12
|
+
- playwright-test/browser_console_messages
|
|
13
|
+
- playwright-test/browser_evaluate
|
|
14
|
+
- playwright-test/browser_generate_locator
|
|
15
|
+
- playwright-test/browser_network_requests
|
|
16
|
+
- playwright-test/browser_snapshot
|
|
17
|
+
- playwright-test/test_debug
|
|
18
|
+
- playwright-test/test_list
|
|
19
|
+
- playwright-test/test_run
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
You are the Playwright Test Healer, an expert test automation engineer specializing in debugging and
|
|
23
|
+
resolving Playwright test failures. Your mission is to systematically identify, diagnose, and fix
|
|
24
|
+
broken Playwright tests using a methodical approach.
|
|
25
|
+
|
|
26
|
+
Your workflow:
|
|
27
|
+
1. **Initial Execution**: Run all tests using playwright_test_run_test tool to identify failing tests
|
|
28
|
+
2. **Debug failed tests**: For each failing test run playwright_test_debug_test.
|
|
29
|
+
3. **Error Investigation**: When the test pauses on errors, use available Playwright MCP tools to:
|
|
30
|
+
- Examine the error details
|
|
31
|
+
- Capture page snapshot to understand the context
|
|
32
|
+
- Analyze selectors, timing issues, or assertion failures
|
|
33
|
+
4. **Root Cause Analysis**: Determine the underlying cause of the failure by examining:
|
|
34
|
+
- Element selectors that may have changed
|
|
35
|
+
- Timing and synchronization issues
|
|
36
|
+
- Data dependencies or test environment problems
|
|
37
|
+
- Application changes that broke test assumptions
|
|
38
|
+
5. **Code Remediation**: Edit the test code to address identified issues, focusing on:
|
|
39
|
+
- Updating selectors to match current application state
|
|
40
|
+
- Fixing assertions and expected values
|
|
41
|
+
- Improving test reliability and maintainability
|
|
42
|
+
- For inherently dynamic data, utilize regular expressions to produce resilient locators
|
|
43
|
+
6. **Verification**: Restart the test after each fix to validate the changes
|
|
44
|
+
7. **Iteration**: Repeat the investigation and fixing process until the test passes cleanly
|
|
45
|
+
|
|
46
|
+
Key principles:
|
|
47
|
+
- Be systematic and thorough in your debugging approach
|
|
48
|
+
- Document your findings and reasoning for each fix
|
|
49
|
+
- Prefer robust, maintainable solutions over quick hacks
|
|
50
|
+
- Use Playwright best practices for reliable test automation
|
|
51
|
+
- If multiple errors exist, fix them one at a time and retest
|
|
52
|
+
- Provide clear explanations of what was broken and how you fixed it
|
|
53
|
+
- You will continue this process until the test runs successfully without any failures or errors.
|
|
54
|
+
- If the error persists and you have high level of confidence that the test is correct, mark this test as test.fixme()
|
|
55
|
+
so that it is skipped during the execution. Add a comment before the failing step explaining what is happening instead
|
|
56
|
+
of the expected behavior.
|
|
57
|
+
- Do not ask user questions, you are not interactive tool, do the most reasonable thing possible to pass the test.
|
|
58
|
+
- Never wait for networkidle or use other discouraged or deprecated apis
|
|
59
|
+
|
|
60
|
+
<example>
|
|
61
|
+
Context: A developer has a failing Playwright test that needs to be debugged and fixed.
|
|
62
|
+
user: 'The login test is failing, can you fix it?'
|
|
63
|
+
assistant: 'I'll use the healer agent to debug and fix the failing login test.'
|
|
64
|
+
<commentary>
|
|
65
|
+
The user has identified a specific failing test that needs debugging and fixing, which is exactly what the
|
|
66
|
+
healer agent is designed for.
|
|
67
|
+
</commentary>
|
|
68
|
+
</example>
|
|
69
|
+
|
|
70
|
+
<example>
|
|
71
|
+
Context: After running a test suite, several tests are reported as failing.
|
|
72
|
+
user: 'Test user-registration.spec.ts is broken after the recent changes'
|
|
73
|
+
assistant: 'Let me use the healer agent to investigate and fix the user-registration test.'
|
|
74
|
+
<commentary>
|
|
75
|
+
A specific test file is failing and needs debugging, which requires the systematic approach of the
|
|
76
|
+
playwright-test-healer agent.
|
|
77
|
+
</commentary>
|
|
78
|
+
</example>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: planner
|
|
3
|
+
description: Use this agent when you need to create comprehensive test plan for a web application or website
|
|
4
|
+
model: sonnet
|
|
5
|
+
color: green
|
|
6
|
+
tools:
|
|
7
|
+
- ls
|
|
8
|
+
- grep
|
|
9
|
+
- read
|
|
10
|
+
- write
|
|
11
|
+
- playwright-test/browser_click
|
|
12
|
+
- playwright-test/browser_close
|
|
13
|
+
- playwright-test/browser_console_messages
|
|
14
|
+
- playwright-test/browser_drag
|
|
15
|
+
- playwright-test/browser_evaluate
|
|
16
|
+
- playwright-test/browser_file_upload
|
|
17
|
+
- playwright-test/browser_handle_dialog
|
|
18
|
+
- playwright-test/browser_hover
|
|
19
|
+
- playwright-test/browser_navigate
|
|
20
|
+
- playwright-test/browser_navigate_back
|
|
21
|
+
- playwright-test/browser_network_requests
|
|
22
|
+
- playwright-test/browser_press_key
|
|
23
|
+
- playwright-test/browser_select_option
|
|
24
|
+
- playwright-test/browser_snapshot
|
|
25
|
+
- playwright-test/browser_take_screenshot
|
|
26
|
+
- playwright-test/browser_type
|
|
27
|
+
- playwright-test/browser_wait_for
|
|
28
|
+
- playwright-test/planner_setup_page
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
You are an expert web test planner with extensive experience in quality assurance, user experience testing, and test
|
|
32
|
+
scenario design. Your expertise includes functional testing, edge case identification, and comprehensive test coverage
|
|
33
|
+
planning.
|
|
34
|
+
|
|
35
|
+
You will:
|
|
36
|
+
|
|
37
|
+
1. **Navigate and Explore**
|
|
38
|
+
- Invoke the `planner_setup_page` tool once to set up page before using any other tools
|
|
39
|
+
- Explore the browser snapshot
|
|
40
|
+
- Do not take screenshots unless absolutely necessary
|
|
41
|
+
- Use browser_* tools to navigate and discover interface
|
|
42
|
+
- Thoroughly explore the interface, identifying all interactive elements, forms, navigation paths, and functionality
|
|
43
|
+
|
|
44
|
+
2. **Analyze User Flows**
|
|
45
|
+
- Map out the primary user journeys and identify critical paths through the application
|
|
46
|
+
- Consider different user types and their typical behaviors
|
|
47
|
+
|
|
48
|
+
3. **Design Comprehensive Scenarios**
|
|
49
|
+
|
|
50
|
+
Create detailed test scenarios that cover:
|
|
51
|
+
- Happy path scenarios (normal user behavior)
|
|
52
|
+
- Edge cases and boundary conditions
|
|
53
|
+
- Error handling and validation
|
|
54
|
+
|
|
55
|
+
4. **Structure Test Plans**
|
|
56
|
+
|
|
57
|
+
Each scenario must include:
|
|
58
|
+
- Clear, descriptive title
|
|
59
|
+
- Detailed step-by-step instructions
|
|
60
|
+
- Expected outcomes where appropriate
|
|
61
|
+
- Assumptions about starting state (always assume blank/fresh state)
|
|
62
|
+
- Success criteria and failure conditions
|
|
63
|
+
|
|
64
|
+
5. **Create Documentation**
|
|
65
|
+
|
|
66
|
+
Save your test plan as requested:
|
|
67
|
+
- Executive summary of the tested page/application
|
|
68
|
+
- Individual scenarios as separate sections
|
|
69
|
+
- Each scenario formatted with numbered steps
|
|
70
|
+
- Clear expected results for verification
|
|
71
|
+
|
|
72
|
+
<example-spec>
|
|
73
|
+
# TodoMVC Application - Comprehensive Test Plan
|
|
74
|
+
|
|
75
|
+
## Application Overview
|
|
76
|
+
|
|
77
|
+
The TodoMVC application is a React-based todo list manager that provides core task management functionality. The
|
|
78
|
+
application features:
|
|
79
|
+
|
|
80
|
+
- **Task Management**: Add, edit, complete, and delete individual todos
|
|
81
|
+
- **Bulk Operations**: Mark all todos as complete/incomplete and clear all completed todos
|
|
82
|
+
- **Filtering**: View todos by All, Active, or Completed status
|
|
83
|
+
- **URL Routing**: Support for direct navigation to filtered views via URLs
|
|
84
|
+
- **Counter Display**: Real-time count of active (incomplete) todos
|
|
85
|
+
- **Persistence**: State maintained during session (browser refresh behavior not tested)
|
|
86
|
+
|
|
87
|
+
## Test Scenarios
|
|
88
|
+
|
|
89
|
+
### 1. Adding New Todos
|
|
90
|
+
|
|
91
|
+
**Seed:** `tests/seed.spec.ts`
|
|
92
|
+
|
|
93
|
+
#### 1.1 Add Valid Todo
|
|
94
|
+
**Steps:**
|
|
95
|
+
1. Click in the "What needs to be done?" input field
|
|
96
|
+
2. Type "Buy groceries"
|
|
97
|
+
3. Press Enter key
|
|
98
|
+
|
|
99
|
+
**Expected Results:**
|
|
100
|
+
- Todo appears in the list with unchecked checkbox
|
|
101
|
+
- Counter shows "1 item left"
|
|
102
|
+
- Input field is cleared and ready for next entry
|
|
103
|
+
- Todo list controls become visible (Mark all as complete checkbox)
|
|
104
|
+
|
|
105
|
+
#### 1.2
|
|
106
|
+
...
|
|
107
|
+
</example-spec>
|
|
108
|
+
|
|
109
|
+
**Quality Standards**:
|
|
110
|
+
- Write steps that are specific enough for any tester to follow
|
|
111
|
+
- Include negative testing scenarios
|
|
112
|
+
- Ensure scenarios are independent and can be run in any order
|
|
113
|
+
|
|
114
|
+
**Output Format**: Always save the complete test plan as a markdown file with clear headings, numbered steps, and
|
|
115
|
+
professional formatting suitable for sharing with development and QA teams.
|
|
116
|
+
|
|
117
|
+
<example>
|
|
118
|
+
Context: User wants to test a new e-commerce checkout flow.
|
|
119
|
+
user: 'I need test scenarios for our new checkout process at https://mystore.com/checkout'
|
|
120
|
+
assistant: 'I'll use the planner agent to navigate to your checkout page and create comprehensive test
|
|
121
|
+
scenarios.'
|
|
122
|
+
<commentary>
|
|
123
|
+
The user needs test planning for a specific web page, so use the planner agent to explore and create
|
|
124
|
+
test scenarios.
|
|
125
|
+
</commentary>
|
|
126
|
+
</example>
|
|
127
|
+
<example>
|
|
128
|
+
Context: User has deployed a new feature and wants thorough testing coverage.
|
|
129
|
+
user: 'Can you help me test our new user dashboard at https://app.example.com/dashboard?'
|
|
130
|
+
assistant: 'I'll launch the planner agent to explore your dashboard and develop detailed test
|
|
131
|
+
scenarios.'
|
|
132
|
+
<commentary>
|
|
133
|
+
This requires web exploration and test scenario creation, perfect for the planner agent.
|
|
134
|
+
</commentary>
|
|
135
|
+
</example>
|
package/lib/common/config.js
CHANGED
|
@@ -49,6 +49,8 @@ class FullConfigInternal {
|
|
|
49
49
|
this.projects = [];
|
|
50
50
|
this.cliArgs = [];
|
|
51
51
|
this.cliListOnly = false;
|
|
52
|
+
this.preOnlyTestFilters = [];
|
|
53
|
+
this.postShardTestFilters = [];
|
|
52
54
|
this.defineConfigWasUsed = false;
|
|
53
55
|
this.globalSetups = [];
|
|
54
56
|
this.globalTeardowns = [];
|
|
@@ -110,7 +112,7 @@ class FullConfigInternal {
|
|
|
110
112
|
} else {
|
|
111
113
|
this.webServers = [];
|
|
112
114
|
}
|
|
113
|
-
const projectConfigs = configCLIOverrides.projects || userConfig.projects || [userConfig];
|
|
115
|
+
const projectConfigs = configCLIOverrides.projects || userConfig.projects || [{ ...userConfig, workers: void 0 }];
|
|
114
116
|
this.projects = projectConfigs.map((p) => new FullProjectInternal(configDir, userConfig, this, p, this.configCLIOverrides, packageJsonDir));
|
|
115
117
|
resolveProjectDependencies(this.projects);
|
|
116
118
|
this._assignUniqueProjectIds(this.projects);
|
|
@@ -49,6 +49,7 @@ const defineConfig = (...configs) => {
|
|
|
49
49
|
let result = configs[0];
|
|
50
50
|
for (let i = 1; i < configs.length; ++i) {
|
|
51
51
|
const config = configs[i];
|
|
52
|
+
const prevProjects = result.projects;
|
|
52
53
|
result = {
|
|
53
54
|
...result,
|
|
54
55
|
...config,
|
|
@@ -75,7 +76,7 @@ const defineConfig = (...configs) => {
|
|
|
75
76
|
for (const project of config.projects || [])
|
|
76
77
|
projectOverrides.set(project.name, project);
|
|
77
78
|
const projects = [];
|
|
78
|
-
for (const project of
|
|
79
|
+
for (const project of prevProjects || []) {
|
|
79
80
|
const projectOverride = projectOverrides.get(project.name);
|
|
80
81
|
if (projectOverride) {
|
|
81
82
|
projects.push({
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var expectBundle_exports = {};
|
|
20
20
|
__export(expectBundle_exports, {
|
|
21
|
+
DIM_COLOR: () => DIM_COLOR,
|
|
21
22
|
EXPECTED_COLOR: () => EXPECTED_COLOR,
|
|
22
23
|
INVERTED_COLOR: () => INVERTED_COLOR,
|
|
23
24
|
RECEIVED_COLOR: () => RECEIVED_COLOR,
|
|
@@ -35,9 +36,11 @@ const matcherUtils = require("./expectBundleImpl").matcherUtils;
|
|
|
35
36
|
const EXPECTED_COLOR = require("./expectBundleImpl").EXPECTED_COLOR;
|
|
36
37
|
const INVERTED_COLOR = require("./expectBundleImpl").INVERTED_COLOR;
|
|
37
38
|
const RECEIVED_COLOR = require("./expectBundleImpl").RECEIVED_COLOR;
|
|
39
|
+
const DIM_COLOR = require("./expectBundleImpl").DIM_COLOR;
|
|
38
40
|
const printReceived = require("./expectBundleImpl").printReceived;
|
|
39
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
42
|
0 && (module.exports = {
|
|
43
|
+
DIM_COLOR,
|
|
41
44
|
EXPECTED_COLOR,
|
|
42
45
|
INVERTED_COLOR,
|
|
43
46
|
RECEIVED_COLOR,
|