@cotestdev/mcp_playwright 0.0.16 → 0.0.17
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/lib/common/config.js +281 -0
- package/lib/common/configLoader.js +344 -0
- package/lib/common/esmLoaderHost.js +104 -0
- package/lib/common/expectBundle.js +43 -0
- package/lib/common/expectBundleImpl.js +407 -0
- package/lib/common/fixtures.js +302 -0
- package/lib/common/globals.js +58 -0
- package/lib/common/ipc.js +60 -0
- package/lib/common/poolBuilder.js +85 -0
- package/lib/common/process.js +132 -0
- package/lib/common/suiteUtils.js +140 -0
- package/lib/common/test.js +322 -0
- package/lib/common/testLoader.js +101 -0
- package/lib/common/testType.js +298 -0
- package/lib/common/validators.js +68 -0
- package/lib/mcp/browser/tools/common.js +1 -1
- package/lib/mcp/browser/tools/console.js +1 -1
- package/lib/mcp/browser/tools/dialogs.js +1 -1
- package/lib/mcp/browser/tools/evaluate.js +1 -1
- package/lib/mcp/browser/tools/files.js +1 -1
- package/lib/mcp/browser/tools/form.js +1 -1
- package/lib/mcp/browser/tools/install.js +1 -1
- package/lib/mcp/browser/tools/keyboard.js +1 -1
- package/lib/mcp/browser/tools/mouse.js +1 -1
- package/lib/mcp/browser/tools/navigate.js +1 -1
- package/lib/mcp/browser/tools/network.js +1 -1
- package/lib/mcp/browser/tools/pdf.js +1 -1
- package/lib/mcp/browser/tools/runCode.js +1 -1
- package/lib/mcp/browser/tools/screenshot.js +1 -1
- package/lib/mcp/browser/tools/script.js +1 -1
- package/lib/mcp/browser/tools/snapshot.js +1 -1
- package/lib/mcp/browser/tools/tabs.js +1 -1
- package/lib/mcp/browser/tools/tracing.js +1 -1
- package/lib/mcp/browser/tools/verify.js +1 -1
- package/lib/mcp/browser/tools/wait.js +1 -1
- package/lib/mcp/index.js +1 -1
- package/lib/mcp/sdk/http.js +1 -1
- package/lib/mcp/sdk/server.js +1 -1
- package/lib/mcp/sdk/tool.js +1 -1
- package/lib/mcp/test/generatorTools.js +1 -1
- package/lib/mcp/test/plannerTools.js +1 -1
- package/lib/mcp/test/seed.js +1 -1
- package/lib/mcp/test/testBackend.js +1 -1
- package/lib/mcp/test/testContext.js +4 -4
- package/lib/mcp/test/testTools.js +2 -2
- package/lib/mcp/vscode/host.js +1 -1
- package/lib/third_party/pirates.js +62 -0
- package/lib/third_party/tsconfig-loader.js +103 -0
- package/lib/transform/babelBundle.js +43 -0
- package/lib/transform/babelBundleImpl.js +461 -0
- package/lib/transform/babelHighlightUtils.js +63 -0
- package/lib/transform/compilationCache.js +272 -0
- package/lib/transform/esmLoader.js +103 -0
- package/lib/transform/portTransport.js +67 -0
- package/lib/transform/transform.js +296 -0
- package/lib/utilsBundleImpl/index.js +218 -0
- package/package.json +1 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var testType_exports = {};
|
|
20
|
+
__export(testType_exports, {
|
|
21
|
+
TestTypeImpl: () => TestTypeImpl,
|
|
22
|
+
mergeTests: () => mergeTests,
|
|
23
|
+
rootTestType: () => rootTestType
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(testType_exports);
|
|
26
|
+
var import_playwright_core = require("playwright-core");
|
|
27
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
28
|
+
var import_globals = require("./globals");
|
|
29
|
+
var import_test = require("./test");
|
|
30
|
+
var import_expect = require("../matchers/expect");
|
|
31
|
+
var import_transform = require("../transform/transform");
|
|
32
|
+
var import_validators = require("./validators");
|
|
33
|
+
const testTypeSymbol = Symbol("testType");
|
|
34
|
+
class TestTypeImpl {
|
|
35
|
+
constructor(fixtures) {
|
|
36
|
+
this.fixtures = fixtures;
|
|
37
|
+
const test = (0, import_transform.wrapFunctionWithLocation)(this._createTest.bind(this, "default"));
|
|
38
|
+
test[testTypeSymbol] = this;
|
|
39
|
+
test.expect = import_expect.expect;
|
|
40
|
+
test.only = (0, import_transform.wrapFunctionWithLocation)(this._createTest.bind(this, "only"));
|
|
41
|
+
test.describe = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "default"));
|
|
42
|
+
test.describe.only = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "only"));
|
|
43
|
+
test.describe.configure = (0, import_transform.wrapFunctionWithLocation)(this._configure.bind(this));
|
|
44
|
+
test.describe.fixme = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "fixme"));
|
|
45
|
+
test.describe.parallel = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "parallel"));
|
|
46
|
+
test.describe.parallel.only = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "parallel.only"));
|
|
47
|
+
test.describe.serial = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "serial"));
|
|
48
|
+
test.describe.serial.only = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "serial.only"));
|
|
49
|
+
test.describe.skip = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "skip"));
|
|
50
|
+
test.beforeEach = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "beforeEach"));
|
|
51
|
+
test.afterEach = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "afterEach"));
|
|
52
|
+
test.beforeAll = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "beforeAll"));
|
|
53
|
+
test.afterAll = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "afterAll"));
|
|
54
|
+
test.skip = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "skip"));
|
|
55
|
+
test.fixme = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "fixme"));
|
|
56
|
+
test.fail = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "fail"));
|
|
57
|
+
test.fail.only = (0, import_transform.wrapFunctionWithLocation)(this._createTest.bind(this, "fail.only"));
|
|
58
|
+
test.slow = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "slow"));
|
|
59
|
+
test.setTimeout = (0, import_transform.wrapFunctionWithLocation)(this._setTimeout.bind(this));
|
|
60
|
+
test.step = this._step.bind(this, "pass");
|
|
61
|
+
test.step.skip = this._step.bind(this, "skip");
|
|
62
|
+
test.use = (0, import_transform.wrapFunctionWithLocation)(this._use.bind(this));
|
|
63
|
+
test.extend = (0, import_transform.wrapFunctionWithLocation)(this._extend.bind(this));
|
|
64
|
+
test.info = () => {
|
|
65
|
+
const result = (0, import_globals.currentTestInfo)();
|
|
66
|
+
if (!result)
|
|
67
|
+
throw new Error("test.info() can only be called while test is running");
|
|
68
|
+
return result;
|
|
69
|
+
};
|
|
70
|
+
this.test = test;
|
|
71
|
+
}
|
|
72
|
+
_currentSuite(location, title) {
|
|
73
|
+
const suite = (0, import_globals.currentlyLoadingFileSuite)();
|
|
74
|
+
if (!suite) {
|
|
75
|
+
throw new Error([
|
|
76
|
+
`Playwright Test did not expect ${title} to be called here.`,
|
|
77
|
+
`Most common reasons include:`,
|
|
78
|
+
`- You are calling ${title} in a configuration file.`,
|
|
79
|
+
`- You are calling ${title} in a file that is imported by the configuration file.`,
|
|
80
|
+
`- You have two different versions of @playwright/test. This usually happens`,
|
|
81
|
+
` when one of the dependencies in your package.json depends on @playwright/test.`
|
|
82
|
+
].join("\n"));
|
|
83
|
+
}
|
|
84
|
+
return suite;
|
|
85
|
+
}
|
|
86
|
+
_createTest(type, location, title, fnOrDetails, fn) {
|
|
87
|
+
throwIfRunningInsideJest();
|
|
88
|
+
const suite = this._currentSuite(location, "test()");
|
|
89
|
+
if (!suite)
|
|
90
|
+
return;
|
|
91
|
+
let details;
|
|
92
|
+
let body;
|
|
93
|
+
if (typeof fnOrDetails === "function") {
|
|
94
|
+
body = fnOrDetails;
|
|
95
|
+
details = {};
|
|
96
|
+
} else {
|
|
97
|
+
body = fn;
|
|
98
|
+
details = fnOrDetails;
|
|
99
|
+
}
|
|
100
|
+
const validatedDetails = (0, import_validators.validateTestDetails)(details, location);
|
|
101
|
+
const test = new import_test.TestCase(title, body, this, location);
|
|
102
|
+
test._requireFile = suite._requireFile;
|
|
103
|
+
test.annotations.push(...validatedDetails.annotations);
|
|
104
|
+
test._tags.push(...validatedDetails.tags);
|
|
105
|
+
suite._addTest(test);
|
|
106
|
+
if (type === "only" || type === "fail.only")
|
|
107
|
+
test._only = true;
|
|
108
|
+
if (type === "skip" || type === "fixme" || type === "fail")
|
|
109
|
+
test.annotations.push({ type, location });
|
|
110
|
+
else if (type === "fail.only")
|
|
111
|
+
test.annotations.push({ type: "fail", location });
|
|
112
|
+
}
|
|
113
|
+
_describe(type, location, titleOrFn, fnOrDetails, fn) {
|
|
114
|
+
throwIfRunningInsideJest();
|
|
115
|
+
const suite = this._currentSuite(location, "test.describe()");
|
|
116
|
+
if (!suite)
|
|
117
|
+
return;
|
|
118
|
+
let title;
|
|
119
|
+
let body;
|
|
120
|
+
let details;
|
|
121
|
+
if (typeof titleOrFn === "function") {
|
|
122
|
+
title = "";
|
|
123
|
+
details = {};
|
|
124
|
+
body = titleOrFn;
|
|
125
|
+
} else if (typeof fnOrDetails === "function") {
|
|
126
|
+
title = titleOrFn;
|
|
127
|
+
details = {};
|
|
128
|
+
body = fnOrDetails;
|
|
129
|
+
} else {
|
|
130
|
+
title = titleOrFn;
|
|
131
|
+
details = fnOrDetails;
|
|
132
|
+
body = fn;
|
|
133
|
+
}
|
|
134
|
+
const validatedDetails = (0, import_validators.validateTestDetails)(details, location);
|
|
135
|
+
const child = new import_test.Suite(title, "describe");
|
|
136
|
+
child._requireFile = suite._requireFile;
|
|
137
|
+
child.location = location;
|
|
138
|
+
child._staticAnnotations.push(...validatedDetails.annotations);
|
|
139
|
+
child._tags.push(...validatedDetails.tags);
|
|
140
|
+
suite._addSuite(child);
|
|
141
|
+
if (type === "only" || type === "serial.only" || type === "parallel.only")
|
|
142
|
+
child._only = true;
|
|
143
|
+
if (type === "serial" || type === "serial.only")
|
|
144
|
+
child._parallelMode = "serial";
|
|
145
|
+
if (type === "parallel" || type === "parallel.only")
|
|
146
|
+
child._parallelMode = "parallel";
|
|
147
|
+
if (type === "skip" || type === "fixme")
|
|
148
|
+
child._staticAnnotations.push({ type, location });
|
|
149
|
+
for (let parent = suite; parent; parent = parent.parent) {
|
|
150
|
+
if (parent._parallelMode === "serial" && child._parallelMode === "parallel")
|
|
151
|
+
throw new Error("describe.parallel cannot be nested inside describe.serial");
|
|
152
|
+
if (parent._parallelMode === "default" && child._parallelMode === "parallel")
|
|
153
|
+
throw new Error("describe.parallel cannot be nested inside describe with default mode");
|
|
154
|
+
}
|
|
155
|
+
(0, import_globals.setCurrentlyLoadingFileSuite)(child);
|
|
156
|
+
body();
|
|
157
|
+
(0, import_globals.setCurrentlyLoadingFileSuite)(suite);
|
|
158
|
+
}
|
|
159
|
+
_hook(name, location, title, fn) {
|
|
160
|
+
const suite = this._currentSuite(location, `test.${name}()`);
|
|
161
|
+
if (!suite)
|
|
162
|
+
return;
|
|
163
|
+
if (typeof title === "function") {
|
|
164
|
+
fn = title;
|
|
165
|
+
title = `${name} hook`;
|
|
166
|
+
}
|
|
167
|
+
suite._hooks.push({ type: name, fn, title, location });
|
|
168
|
+
}
|
|
169
|
+
_configure(location, options) {
|
|
170
|
+
throwIfRunningInsideJest();
|
|
171
|
+
const suite = this._currentSuite(location, `test.describe.configure()`);
|
|
172
|
+
if (!suite)
|
|
173
|
+
return;
|
|
174
|
+
if (options.timeout !== void 0)
|
|
175
|
+
suite._timeout = options.timeout;
|
|
176
|
+
if (options.retries !== void 0)
|
|
177
|
+
suite._retries = options.retries;
|
|
178
|
+
if (options.mode !== void 0) {
|
|
179
|
+
if (suite._parallelMode !== "none")
|
|
180
|
+
throw new Error(`"${suite._parallelMode}" mode is already assigned for the enclosing scope.`);
|
|
181
|
+
suite._parallelMode = options.mode;
|
|
182
|
+
for (let parent = suite.parent; parent; parent = parent.parent) {
|
|
183
|
+
if (parent._parallelMode === "serial" && suite._parallelMode === "parallel")
|
|
184
|
+
throw new Error("describe with parallel mode cannot be nested inside describe with serial mode");
|
|
185
|
+
if (parent._parallelMode === "default" && suite._parallelMode === "parallel")
|
|
186
|
+
throw new Error("describe with parallel mode cannot be nested inside describe with default mode");
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
_modifier(type, location, ...modifierArgs) {
|
|
191
|
+
const suite = (0, import_globals.currentlyLoadingFileSuite)();
|
|
192
|
+
if (suite) {
|
|
193
|
+
if (typeof modifierArgs[0] === "string" && typeof modifierArgs[1] === "function" && (type === "skip" || type === "fixme" || type === "fail")) {
|
|
194
|
+
this._createTest(type, location, modifierArgs[0], modifierArgs[1]);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (typeof modifierArgs[0] === "string" && typeof modifierArgs[1] === "object" && typeof modifierArgs[2] === "function" && (type === "skip" || type === "fixme" || type === "fail")) {
|
|
198
|
+
this._createTest(type, location, modifierArgs[0], modifierArgs[1], modifierArgs[2]);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (typeof modifierArgs[0] === "function") {
|
|
202
|
+
suite._modifiers.push({ type, fn: modifierArgs[0], location, description: modifierArgs[1] });
|
|
203
|
+
} else {
|
|
204
|
+
if (modifierArgs.length >= 1 && !modifierArgs[0])
|
|
205
|
+
return;
|
|
206
|
+
const description = modifierArgs[1];
|
|
207
|
+
suite._staticAnnotations.push({ type, description, location });
|
|
208
|
+
}
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const testInfo = (0, import_globals.currentTestInfo)();
|
|
212
|
+
if (!testInfo)
|
|
213
|
+
throw new Error(`test.${type}() can only be called inside test, describe block or fixture`);
|
|
214
|
+
if (typeof modifierArgs[0] === "function")
|
|
215
|
+
throw new Error(`test.${type}() with a function can only be called inside describe block`);
|
|
216
|
+
testInfo._modifier(type, location, modifierArgs);
|
|
217
|
+
}
|
|
218
|
+
_setTimeout(location, timeout) {
|
|
219
|
+
const suite = (0, import_globals.currentlyLoadingFileSuite)();
|
|
220
|
+
if (suite) {
|
|
221
|
+
suite._timeout = timeout;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const testInfo = (0, import_globals.currentTestInfo)();
|
|
225
|
+
if (!testInfo)
|
|
226
|
+
throw new Error(`test.setTimeout() can only be called from a test`);
|
|
227
|
+
testInfo.setTimeout(timeout);
|
|
228
|
+
}
|
|
229
|
+
_use(location, fixtures) {
|
|
230
|
+
const suite = this._currentSuite(location, `test.use()`);
|
|
231
|
+
if (!suite)
|
|
232
|
+
return;
|
|
233
|
+
suite._use.push({ fixtures, location });
|
|
234
|
+
}
|
|
235
|
+
async _step(expectation, title, body, options = {}) {
|
|
236
|
+
const testInfo = (0, import_globals.currentTestInfo)();
|
|
237
|
+
if (!testInfo)
|
|
238
|
+
throw new Error(`test.step() can only be called from a test`);
|
|
239
|
+
const step = testInfo._addStep({ category: "test.step", title, location: options.location, box: options.box });
|
|
240
|
+
return await (0, import_utils.currentZone)().with("stepZone", step).run(async () => {
|
|
241
|
+
try {
|
|
242
|
+
let result = void 0;
|
|
243
|
+
result = await (0, import_utils.raceAgainstDeadline)(async () => {
|
|
244
|
+
try {
|
|
245
|
+
return await step.info._runStepBody(expectation === "skip", body, step.location);
|
|
246
|
+
} catch (e) {
|
|
247
|
+
if (result?.timedOut)
|
|
248
|
+
testInfo._failWithError(e);
|
|
249
|
+
throw e;
|
|
250
|
+
}
|
|
251
|
+
}, options.timeout ? (0, import_utils.monotonicTime)() + options.timeout : 0);
|
|
252
|
+
if (result.timedOut)
|
|
253
|
+
throw new import_playwright_core.errors.TimeoutError(`Step timeout of ${options.timeout}ms exceeded.`);
|
|
254
|
+
step.complete({});
|
|
255
|
+
return result.result;
|
|
256
|
+
} catch (error) {
|
|
257
|
+
step.complete({ error });
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
_extend(location, fixtures) {
|
|
263
|
+
if (fixtures[testTypeSymbol])
|
|
264
|
+
throw new Error(`test.extend() accepts fixtures object, not a test object.
|
|
265
|
+
Did you mean to call mergeTests()?`);
|
|
266
|
+
const fixturesWithLocation = { fixtures, location };
|
|
267
|
+
return new TestTypeImpl([...this.fixtures, fixturesWithLocation]).test;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function throwIfRunningInsideJest() {
|
|
271
|
+
if (process.env.JEST_WORKER_ID) {
|
|
272
|
+
const packageManagerCommand = (0, import_utils.getPackageManagerExecCommand)();
|
|
273
|
+
throw new Error(
|
|
274
|
+
`Playwright Test needs to be invoked via '${packageManagerCommand} playwright test' and excluded from Jest test runs.
|
|
275
|
+
Creating one directory for Playwright tests and one for Jest is the recommended way of doing it.
|
|
276
|
+
See https://playwright.dev/docs/intro for more information about Playwright Test.`
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const rootTestType = new TestTypeImpl([]);
|
|
281
|
+
function mergeTests(...tests) {
|
|
282
|
+
let result = rootTestType;
|
|
283
|
+
for (const t of tests) {
|
|
284
|
+
const testTypeImpl = t[testTypeSymbol];
|
|
285
|
+
if (!testTypeImpl)
|
|
286
|
+
throw new Error(`mergeTests() accepts "test" functions as parameters.
|
|
287
|
+
Did you mean to call test.extend() with fixtures instead?`);
|
|
288
|
+
const newFixtures = testTypeImpl.fixtures.filter((theirs) => !result.fixtures.find((ours) => ours.fixtures === theirs.fixtures));
|
|
289
|
+
result = new TestTypeImpl([...result.fixtures, ...newFixtures]);
|
|
290
|
+
}
|
|
291
|
+
return result.test;
|
|
292
|
+
}
|
|
293
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
294
|
+
0 && (module.exports = {
|
|
295
|
+
TestTypeImpl,
|
|
296
|
+
mergeTests,
|
|
297
|
+
rootTestType
|
|
298
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var validators_exports = {};
|
|
20
|
+
__export(validators_exports, {
|
|
21
|
+
validateTestAnnotation: () => validateTestAnnotation,
|
|
22
|
+
validateTestDetails: () => validateTestDetails
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(validators_exports);
|
|
25
|
+
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
26
|
+
const testAnnotationSchema = import_utilsBundle.zod.object({
|
|
27
|
+
type: import_utilsBundle.zod.string(),
|
|
28
|
+
description: import_utilsBundle.zod.string().optional()
|
|
29
|
+
});
|
|
30
|
+
const testDetailsSchema = import_utilsBundle.zod.object({
|
|
31
|
+
tag: import_utilsBundle.zod.union([
|
|
32
|
+
import_utilsBundle.zod.string().optional(),
|
|
33
|
+
import_utilsBundle.zod.array(import_utilsBundle.zod.string())
|
|
34
|
+
]).transform((val) => Array.isArray(val) ? val : val !== void 0 ? [val] : []).refine((val) => val.every((v) => v.startsWith("@")), {
|
|
35
|
+
message: "Tag must start with '@'"
|
|
36
|
+
}),
|
|
37
|
+
annotation: import_utilsBundle.zod.union([
|
|
38
|
+
testAnnotationSchema,
|
|
39
|
+
import_utilsBundle.zod.array(testAnnotationSchema).optional()
|
|
40
|
+
]).transform((val) => Array.isArray(val) ? val : val !== void 0 ? [val] : [])
|
|
41
|
+
});
|
|
42
|
+
function validateTestAnnotation(annotation) {
|
|
43
|
+
try {
|
|
44
|
+
return testAnnotationSchema.parse(annotation);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throwZodError(error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function validateTestDetails(details, location) {
|
|
50
|
+
try {
|
|
51
|
+
const parsedDetails = testDetailsSchema.parse(details);
|
|
52
|
+
return {
|
|
53
|
+
annotations: parsedDetails.annotation.map((a) => ({ ...a, location })),
|
|
54
|
+
tags: parsedDetails.tag,
|
|
55
|
+
location
|
|
56
|
+
};
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throwZodError(error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function throwZodError(error) {
|
|
62
|
+
throw new Error(error.issues.map((i) => i.message).join("\n"));
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
validateTestAnnotation,
|
|
67
|
+
validateTestDetails
|
|
68
|
+
});
|
|
@@ -22,7 +22,7 @@ __export(common_exports, {
|
|
|
22
22
|
default: () => common_default
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(common_exports);
|
|
25
|
-
var import_mcpBundle = require("
|
|
25
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
26
26
|
var import_tool = require("./tool");
|
|
27
27
|
const baseSchema = import_mcpBundle.z.object({
|
|
28
28
|
toolText: import_mcpBundle.z.string().describe("A human-readable description of the action to perform by the tool.")
|
|
@@ -21,7 +21,7 @@ __export(console_exports, {
|
|
|
21
21
|
default: () => console_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(console_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const console = (0, import_tool.defineTabTool)({
|
|
27
27
|
capability: "core",
|
|
@@ -22,7 +22,7 @@ __export(dialogs_exports, {
|
|
|
22
22
|
handleDialog: () => handleDialog
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(dialogs_exports);
|
|
25
|
-
var import_mcpBundle = require("
|
|
25
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
26
26
|
var import_tool = require("./tool");
|
|
27
27
|
var import_common = require("./common");
|
|
28
28
|
const handleDialog = (0, import_tool.defineTabTool)({
|
|
@@ -21,7 +21,7 @@ __export(evaluate_exports, {
|
|
|
21
21
|
default: () => evaluate_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(evaluate_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_utils = require("playwright-core/lib/utils");
|
|
26
26
|
var import_tool = require("./tool");
|
|
27
27
|
var import_common = require("./common");
|
|
@@ -22,7 +22,7 @@ __export(files_exports, {
|
|
|
22
22
|
uploadFile: () => uploadFile
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(files_exports);
|
|
25
|
-
var import_mcpBundle = require("
|
|
25
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
26
26
|
var import_tool = require("./tool");
|
|
27
27
|
var import_common = require("./common");
|
|
28
28
|
const uploadFile = (0, import_tool.defineTabTool)({
|
|
@@ -21,7 +21,7 @@ __export(form_exports, {
|
|
|
21
21
|
default: () => form_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(form_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_utils = require("playwright-core/lib/utils");
|
|
26
26
|
var import_tool = require("./tool");
|
|
27
27
|
var import_common = require("./common");
|
|
@@ -33,7 +33,7 @@ __export(install_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(install_exports);
|
|
34
34
|
var import_child_process = require("child_process");
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
|
-
var import_mcpBundle = require("
|
|
36
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
37
37
|
var import_tool = require("./tool");
|
|
38
38
|
const install = (0, import_tool.defineTool)({
|
|
39
39
|
capability: "core-install",
|
|
@@ -21,7 +21,7 @@ __export(keyboard_exports, {
|
|
|
21
21
|
default: () => keyboard_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(keyboard_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
var import_snapshot = require("./snapshot");
|
|
27
27
|
var import_common = require("./common");
|
|
@@ -21,7 +21,7 @@ __export(mouse_exports, {
|
|
|
21
21
|
default: () => mouse_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(mouse_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const elementSchema = import_mcpBundle.z.object({
|
|
27
27
|
element: import_mcpBundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element")
|
|
@@ -21,7 +21,7 @@ __export(navigate_exports, {
|
|
|
21
21
|
default: () => navigate_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(navigate_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
var import_common = require("./common");
|
|
27
27
|
const navigate = (0, import_tool.defineTool)({
|
|
@@ -21,7 +21,7 @@ __export(network_exports, {
|
|
|
21
21
|
default: () => network_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(network_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const requests = (0, import_tool.defineTabTool)({
|
|
27
27
|
capability: "core",
|
|
@@ -21,7 +21,7 @@ __export(pdf_exports, {
|
|
|
21
21
|
default: () => pdf_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(pdf_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_utils = require("playwright-core/lib/utils");
|
|
26
26
|
var import_tool = require("./tool");
|
|
27
27
|
var import_utils2 = require("./utils");
|
|
@@ -33,7 +33,7 @@ __export(runCode_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(runCode_exports);
|
|
34
34
|
var import_vm = __toESM(require("vm"));
|
|
35
35
|
var import_utils = require("playwright-core/lib/utils");
|
|
36
|
-
var import_mcpBundle = require("
|
|
36
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
37
37
|
var import_tool = require("./tool");
|
|
38
38
|
const codeSchema = import_mcpBundle.z.object({
|
|
39
39
|
code: import_mcpBundle.z.string().describe(`A JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction. For example: \`async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }\``)
|
|
@@ -36,7 +36,7 @@ var import_fs = __toESM(require("fs"));
|
|
|
36
36
|
var import_utils = require("playwright-core/lib/utils");
|
|
37
37
|
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
38
38
|
var import_utils2 = require("playwright-core/lib/utils");
|
|
39
|
-
var import_mcpBundle = require("
|
|
39
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
40
40
|
var import_tool = require("./tool");
|
|
41
41
|
var import_utils3 = require("./utils");
|
|
42
42
|
var import_common = require("./common");
|
|
@@ -21,7 +21,7 @@ __export(script_exports, {
|
|
|
21
21
|
default: () => script_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(script_exports);
|
|
24
|
-
var import_bundle = require("
|
|
24
|
+
var import_bundle = require("playwright-core/lib/sdk/bundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
var import_utils = require("./utils");
|
|
27
27
|
const executeScript = (0, import_tool.defineTabTool)({
|
|
@@ -33,7 +33,7 @@ __export(snapshot_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(snapshot_exports);
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
|
-
var import_mcpBundle = require("
|
|
36
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
37
37
|
var import_utils = require("playwright-core/lib/utils");
|
|
38
38
|
var import_tool = require("./tool");
|
|
39
39
|
var import_common = require("./common");
|
|
@@ -21,7 +21,7 @@ __export(tabs_exports, {
|
|
|
21
21
|
default: () => tabs_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(tabs_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
var import_common = require("./common");
|
|
27
27
|
const browserTabs = (0, import_tool.defineTool)({
|
|
@@ -21,7 +21,7 @@ __export(tracing_exports, {
|
|
|
21
21
|
default: () => tracing_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(tracing_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const tracingStart = (0, import_tool.defineTool)({
|
|
27
27
|
capability: "tracing",
|
|
@@ -21,7 +21,7 @@ __export(verify_exports, {
|
|
|
21
21
|
default: () => verify_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(verify_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_utils = require("playwright-core/lib/utils");
|
|
26
26
|
var import_tool = require("./tool");
|
|
27
27
|
var import_common = require("./common");
|
|
@@ -21,7 +21,7 @@ __export(wait_exports, {
|
|
|
21
21
|
default: () => wait_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(wait_exports);
|
|
24
|
-
var import_mcpBundle = require("
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
var import_common = require("./common");
|
|
27
27
|
const wait = (0, import_tool.defineTool)({
|
package/lib/mcp/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var import_browserServerBackend = require("./browser/browserServerBackend");
|
|
|
35
35
|
var import_config = require("./browser/config");
|
|
36
36
|
var import_browserContextFactory = require("./browser/browserContextFactory");
|
|
37
37
|
var mcpServer = __toESM(require("./sdk/server"));
|
|
38
|
-
const packageJSON = require("
|
|
38
|
+
const packageJSON = require("playwright-core/lib/package.json");
|
|
39
39
|
async function createConnection(userConfig = {}, contextGetter) {
|
|
40
40
|
const config = await (0, import_config.resolveConfig)(userConfig);
|
|
41
41
|
const factory = contextGetter ? new SimpleBrowserContextFactory(contextGetter) : (0, import_browserContextFactory.contextFactory)(config);
|
package/lib/mcp/sdk/http.js
CHANGED
|
@@ -35,7 +35,7 @@ module.exports = __toCommonJS(http_exports);
|
|
|
35
35
|
var import_assert = __toESM(require("assert"));
|
|
36
36
|
var import_crypto = __toESM(require("crypto"));
|
|
37
37
|
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
38
|
-
var mcpBundle = __toESM(require("
|
|
38
|
+
var mcpBundle = __toESM(require("playwright-core/lib/mcpBundle"));
|
|
39
39
|
var import_utils = require("playwright-core/lib/utils");
|
|
40
40
|
var mcpServer = __toESM(require("./server"));
|
|
41
41
|
const testDebug = (0, import_utilsBundle.debug)("pw:mcp:test");
|
package/lib/mcp/sdk/server.js
CHANGED
|
@@ -38,7 +38,7 @@ __export(server_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(server_exports);
|
|
39
39
|
var import_url = require("url");
|
|
40
40
|
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
41
|
-
var mcpBundle = __toESM(require("
|
|
41
|
+
var mcpBundle = __toESM(require("playwright-core/lib/mcpBundle"));
|
|
42
42
|
var import_http = require("./http");
|
|
43
43
|
var import_inProcessTransport = require("./inProcessTransport");
|
|
44
44
|
const serverDebug = (0, import_utilsBundle.debug)("pw:mcp:server");
|
package/lib/mcp/sdk/tool.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(tool_exports, {
|
|
|
22
22
|
toMcpTool: () => toMcpTool
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(tool_exports);
|
|
25
|
-
var import_mcpBundle = require("
|
|
25
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
26
26
|
function toMcpTool(tool) {
|
|
27
27
|
const readOnly = tool.type === "readOnly" || tool.type === "assertion";
|
|
28
28
|
return {
|
|
@@ -35,7 +35,7 @@ __export(generatorTools_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(generatorTools_exports);
|
|
36
36
|
var import_fs = __toESM(require("fs"));
|
|
37
37
|
var import_path = __toESM(require("path"));
|
|
38
|
-
var import_mcpBundle = require("
|
|
38
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
39
39
|
var import_testTool = require("./testTool");
|
|
40
40
|
var import_testContext = require("./testContext");
|
|
41
41
|
const setupPage = (0, import_testTool.defineTestTool)({
|
|
@@ -35,7 +35,7 @@ __export(plannerTools_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(plannerTools_exports);
|
|
36
36
|
var import_fs = __toESM(require("fs"));
|
|
37
37
|
var import_path = __toESM(require("path"));
|
|
38
|
-
var import_mcpBundle = require("
|
|
38
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
39
39
|
var import_testTool = require("./testTool");
|
|
40
40
|
const setupPage = (0, import_testTool.defineTestTool)({
|
|
41
41
|
schema: {
|
package/lib/mcp/test/seed.js
CHANGED
|
@@ -38,7 +38,7 @@ module.exports = __toCommonJS(seed_exports);
|
|
|
38
38
|
var import_fs = __toESM(require("fs"));
|
|
39
39
|
var import_path = __toESM(require("path"));
|
|
40
40
|
var import_utils = require("playwright-core/lib/utils");
|
|
41
|
-
var import_projectUtils = require("
|
|
41
|
+
var import_projectUtils = require("playwright-core/lib/runner/projectUtils");
|
|
42
42
|
function seedProject(config, projectName) {
|
|
43
43
|
if (!projectName)
|
|
44
44
|
return (0, import_projectUtils.findTopLevelProjects)(config)[0];
|