@cotestdev/mcp_playwright 0.0.15 → 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/script.js +1 -1
- package/lib/mcp/index.js +1 -1
- package/lib/mcp/test/seed.js +1 -1
- package/lib/mcp/test/testContext.js +4 -4
- package/lib/mcp/test/testTools.js +1 -1
- package/lib/mcp/vscode/host.js +1 -1
- package/lib/mcpBundle.js +84 -0
- package/lib/mcpBundleImpl/index.js +130 -0
- 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
|
+
});
|
|
@@ -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)({
|
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/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];
|
|
@@ -37,14 +37,14 @@ var import_fs = __toESM(require("fs"));
|
|
|
37
37
|
var import_os = __toESM(require("os"));
|
|
38
38
|
var import_path = __toESM(require("path"));
|
|
39
39
|
var import_utils = require("playwright-core/lib/utils");
|
|
40
|
-
var import_base = require("
|
|
41
|
-
var import_list = __toESM(require("
|
|
40
|
+
var import_base = require("playwright-core/lib/reporters/base");
|
|
41
|
+
var import_list = __toESM(require("playwright-core/lib/reporters/list"));
|
|
42
42
|
var import_streams = require("./streams");
|
|
43
43
|
var import_util = require("../../util");
|
|
44
|
-
var import_testRunner = require("
|
|
44
|
+
var import_testRunner = require("playwright-core/lib/runner/testRunner");
|
|
45
45
|
var import_seed = require("./seed");
|
|
46
46
|
var import_exports = require("../sdk/exports");
|
|
47
|
-
var import_configLoader = require("
|
|
47
|
+
var import_configLoader = require("playwright-core/lib/common/configLoader");
|
|
48
48
|
var import_response = require("../browser/response");
|
|
49
49
|
var import_log = require("../log");
|
|
50
50
|
class GeneratorJournal {
|
|
@@ -34,7 +34,7 @@ __export(testTools_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(testTools_exports);
|
|
36
36
|
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
37
|
-
var import_listModeReporter = __toESM(require("
|
|
37
|
+
var import_listModeReporter = __toESM(require("playwright-core/lib/reporters/listModeReporter"));
|
|
38
38
|
var import_testTool = require("./testTool");
|
|
39
39
|
const listTests = (0, import_testTool.defineTestTool)({
|
|
40
40
|
schema: {
|
package/lib/mcp/vscode/host.js
CHANGED
|
@@ -37,7 +37,7 @@ var mcpServer = __toESM(require("../sdk/server"));
|
|
|
37
37
|
var import_log = require("../log");
|
|
38
38
|
var import_browserServerBackend = require("../browser/browserServerBackend");
|
|
39
39
|
var import_browserContextFactory = require("../browser/browserContextFactory");
|
|
40
|
-
const packageJSON = require("
|
|
40
|
+
const packageJSON = require("playwright-core/lib/../package.json");
|
|
41
41
|
const { z, zodToJsonSchema } = mcpBundle;
|
|
42
42
|
const contextSwitchOptions = z.object({
|
|
43
43
|
connectionString: z.string().optional().describe("The connection string to use to connect to the browser"),
|
package/lib/mcpBundle.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
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 mcpBundle_exports = {};
|
|
30
|
+
__export(mcpBundle_exports, {
|
|
31
|
+
CallToolRequestSchema: () => CallToolRequestSchema,
|
|
32
|
+
Client: () => Client,
|
|
33
|
+
ListRootsRequestSchema: () => ListRootsRequestSchema,
|
|
34
|
+
ListToolsRequestSchema: () => ListToolsRequestSchema,
|
|
35
|
+
Loop: () => Loop,
|
|
36
|
+
PingRequestSchema: () => PingRequestSchema,
|
|
37
|
+
ProgressNotificationSchema: () => ProgressNotificationSchema,
|
|
38
|
+
SSEClientTransport: () => SSEClientTransport,
|
|
39
|
+
SSEServerTransport: () => SSEServerTransport,
|
|
40
|
+
Server: () => Server,
|
|
41
|
+
StdioClientTransport: () => StdioClientTransport,
|
|
42
|
+
StdioServerTransport: () => StdioServerTransport,
|
|
43
|
+
StreamableHTTPClientTransport: () => StreamableHTTPClientTransport,
|
|
44
|
+
StreamableHTTPServerTransport: () => StreamableHTTPServerTransport,
|
|
45
|
+
z: () => z,
|
|
46
|
+
zodToJsonSchema: () => zodToJsonSchema
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(mcpBundle_exports);
|
|
49
|
+
var bundle = __toESM(require("./mcpBundleImpl"));
|
|
50
|
+
const zodToJsonSchema = bundle.zodToJsonSchema;
|
|
51
|
+
const Client = bundle.Client;
|
|
52
|
+
const Server = bundle.Server;
|
|
53
|
+
const SSEClientTransport = bundle.SSEClientTransport;
|
|
54
|
+
const SSEServerTransport = bundle.SSEServerTransport;
|
|
55
|
+
const StdioClientTransport = bundle.StdioClientTransport;
|
|
56
|
+
const StdioServerTransport = bundle.StdioServerTransport;
|
|
57
|
+
const StreamableHTTPServerTransport = bundle.StreamableHTTPServerTransport;
|
|
58
|
+
const StreamableHTTPClientTransport = bundle.StreamableHTTPClientTransport;
|
|
59
|
+
const CallToolRequestSchema = bundle.CallToolRequestSchema;
|
|
60
|
+
const ListRootsRequestSchema = bundle.ListRootsRequestSchema;
|
|
61
|
+
const ProgressNotificationSchema = bundle.ProgressNotificationSchema;
|
|
62
|
+
const ListToolsRequestSchema = bundle.ListToolsRequestSchema;
|
|
63
|
+
const PingRequestSchema = bundle.PingRequestSchema;
|
|
64
|
+
const Loop = bundle.Loop;
|
|
65
|
+
const z = bundle.z;
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
CallToolRequestSchema,
|
|
69
|
+
Client,
|
|
70
|
+
ListRootsRequestSchema,
|
|
71
|
+
ListToolsRequestSchema,
|
|
72
|
+
Loop,
|
|
73
|
+
PingRequestSchema,
|
|
74
|
+
ProgressNotificationSchema,
|
|
75
|
+
SSEClientTransport,
|
|
76
|
+
SSEServerTransport,
|
|
77
|
+
Server,
|
|
78
|
+
StdioClientTransport,
|
|
79
|
+
StdioServerTransport,
|
|
80
|
+
StreamableHTTPClientTransport,
|
|
81
|
+
StreamableHTTPServerTransport,
|
|
82
|
+
z,
|
|
83
|
+
zodToJsonSchema
|
|
84
|
+
});
|