@cotestdev/mcp_playwright 0.0.16 → 0.0.18

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.
@@ -0,0 +1,140 @@
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 suiteUtils_exports = {};
30
+ __export(suiteUtils_exports, {
31
+ applyRepeatEachIndex: () => applyRepeatEachIndex,
32
+ bindFileSuiteToProject: () => bindFileSuiteToProject,
33
+ filterByFocusedLine: () => filterByFocusedLine,
34
+ filterOnly: () => filterOnly,
35
+ filterSuite: () => filterSuite,
36
+ filterTestsRemoveEmptySuites: () => filterTestsRemoveEmptySuites
37
+ });
38
+ module.exports = __toCommonJS(suiteUtils_exports);
39
+ var import_path = __toESM(require("path"));
40
+ var import_utils = require("playwright-core/lib/utils");
41
+ var import_util = require("../util");
42
+ function filterSuite(suite, suiteFilter, testFilter) {
43
+ for (const child of suite.suites) {
44
+ if (!suiteFilter(child))
45
+ filterSuite(child, suiteFilter, testFilter);
46
+ }
47
+ const filteredTests = suite.tests.filter(testFilter);
48
+ const entries = /* @__PURE__ */ new Set([...suite.suites, ...filteredTests]);
49
+ suite._entries = suite._entries.filter((e) => entries.has(e));
50
+ }
51
+ function filterTestsRemoveEmptySuites(suite, filter) {
52
+ const filteredSuites = suite.suites.filter((child) => filterTestsRemoveEmptySuites(child, filter));
53
+ const filteredTests = suite.tests.filter(filter);
54
+ const entries = /* @__PURE__ */ new Set([...filteredSuites, ...filteredTests]);
55
+ suite._entries = suite._entries.filter((e) => entries.has(e));
56
+ return !!suite._entries.length;
57
+ }
58
+ function bindFileSuiteToProject(project, suite) {
59
+ const relativeFile = import_path.default.relative(project.project.testDir, suite.location.file);
60
+ const fileId = (0, import_utils.calculateSha1)((0, import_utils.toPosixPath)(relativeFile)).slice(0, 20);
61
+ const result = suite._deepClone();
62
+ result._fileId = fileId;
63
+ result.forEachTest((test, suite2) => {
64
+ suite2._fileId = fileId;
65
+ const [file, ...titles] = test.titlePath();
66
+ const testIdExpression = `[project=${project.id}]${(0, import_utils.toPosixPath)(file)}${titles.join("")}`;
67
+ const testId = fileId + "-" + (0, import_utils.calculateSha1)(testIdExpression).slice(0, 20);
68
+ test.id = testId;
69
+ test._projectId = project.id;
70
+ let inheritedRetries;
71
+ let inheritedTimeout;
72
+ for (let parentSuite = suite2; parentSuite; parentSuite = parentSuite.parent) {
73
+ if (parentSuite._staticAnnotations.length)
74
+ test.annotations.unshift(...parentSuite._staticAnnotations);
75
+ if (inheritedRetries === void 0 && parentSuite._retries !== void 0)
76
+ inheritedRetries = parentSuite._retries;
77
+ if (inheritedTimeout === void 0 && parentSuite._timeout !== void 0)
78
+ inheritedTimeout = parentSuite._timeout;
79
+ }
80
+ test.retries = inheritedRetries ?? project.project.retries;
81
+ test.timeout = inheritedTimeout ?? project.project.timeout;
82
+ if (test.annotations.some((a) => a.type === "skip" || a.type === "fixme"))
83
+ test.expectedStatus = "skipped";
84
+ if (test._poolDigest)
85
+ test._workerHash = `${project.id}-${test._poolDigest}-0`;
86
+ });
87
+ return result;
88
+ }
89
+ function applyRepeatEachIndex(project, fileSuite, repeatEachIndex) {
90
+ fileSuite.forEachTest((test, suite) => {
91
+ if (repeatEachIndex) {
92
+ const [file, ...titles] = test.titlePath();
93
+ const testIdExpression = `[project=${project.id}]${(0, import_utils.toPosixPath)(file)}${titles.join("")} (repeat:${repeatEachIndex})`;
94
+ const testId = suite._fileId + "-" + (0, import_utils.calculateSha1)(testIdExpression).slice(0, 20);
95
+ test.id = testId;
96
+ test.repeatEachIndex = repeatEachIndex;
97
+ if (test._poolDigest)
98
+ test._workerHash = `${project.id}-${test._poolDigest}-${repeatEachIndex}`;
99
+ }
100
+ });
101
+ }
102
+ function filterOnly(suite) {
103
+ if (!suite._getOnlyItems().length)
104
+ return;
105
+ const suiteFilter = (suite2) => suite2._only;
106
+ const testFilter = (test) => test._only;
107
+ return filterSuiteWithOnlySemantics(suite, suiteFilter, testFilter);
108
+ }
109
+ function filterSuiteWithOnlySemantics(suite, suiteFilter, testFilter) {
110
+ const onlySuites = suite.suites.filter((child) => filterSuiteWithOnlySemantics(child, suiteFilter, testFilter) || suiteFilter(child));
111
+ const onlyTests = suite.tests.filter(testFilter);
112
+ const onlyEntries = /* @__PURE__ */ new Set([...onlySuites, ...onlyTests]);
113
+ if (onlyEntries.size) {
114
+ suite._entries = suite._entries.filter((e) => onlyEntries.has(e));
115
+ return true;
116
+ }
117
+ return false;
118
+ }
119
+ function filterByFocusedLine(suite, focusedTestFileLines) {
120
+ if (!focusedTestFileLines.length)
121
+ return;
122
+ const matchers = focusedTestFileLines.map(createFileMatcherFromFilter);
123
+ const testFileLineMatches = (testFileName, testLine, testColumn) => matchers.some((m) => m(testFileName, testLine, testColumn));
124
+ const suiteFilter = (suite2) => !!suite2.location && testFileLineMatches(suite2.location.file, suite2.location.line, suite2.location.column);
125
+ const testFilter = (test) => testFileLineMatches(test.location.file, test.location.line, test.location.column);
126
+ return filterSuite(suite, suiteFilter, testFilter);
127
+ }
128
+ function createFileMatcherFromFilter(filter) {
129
+ const fileMatcher = (0, import_util.createFileMatcher)(filter.re || filter.exact || "");
130
+ return (testFileName, testLine, testColumn) => fileMatcher(testFileName) && (filter.line === testLine || filter.line === null) && (filter.column === testColumn || filter.column === null);
131
+ }
132
+ // Annotate the CommonJS export names for ESM import in node:
133
+ 0 && (module.exports = {
134
+ applyRepeatEachIndex,
135
+ bindFileSuiteToProject,
136
+ filterByFocusedLine,
137
+ filterOnly,
138
+ filterSuite,
139
+ filterTestsRemoveEmptySuites
140
+ });
@@ -0,0 +1,322 @@
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 test_exports = {};
20
+ __export(test_exports, {
21
+ Suite: () => Suite,
22
+ TestCase: () => TestCase
23
+ });
24
+ module.exports = __toCommonJS(test_exports);
25
+ var import_testType = require("./testType");
26
+ var import_teleReceiver = require("../isomorphic/teleReceiver");
27
+ class Base {
28
+ constructor(title) {
29
+ this._only = false;
30
+ this._requireFile = "";
31
+ this.title = title;
32
+ }
33
+ }
34
+ class Suite extends Base {
35
+ constructor(title, type) {
36
+ super(title);
37
+ this._use = [];
38
+ this._entries = [];
39
+ this._hooks = [];
40
+ // Annotations known statically before running the test, e.g. `test.describe.skip()` or `test.describe({ annotation }, body)`.
41
+ this._staticAnnotations = [];
42
+ // Explicitly declared tags that are not a part of the title.
43
+ this._tags = [];
44
+ this._modifiers = [];
45
+ this._parallelMode = "none";
46
+ this._type = type;
47
+ }
48
+ get type() {
49
+ return this._type;
50
+ }
51
+ entries() {
52
+ return this._entries;
53
+ }
54
+ get suites() {
55
+ return this._entries.filter((entry) => entry instanceof Suite);
56
+ }
57
+ get tests() {
58
+ return this._entries.filter((entry) => entry instanceof TestCase);
59
+ }
60
+ _addTest(test) {
61
+ test.parent = this;
62
+ this._entries.push(test);
63
+ }
64
+ _addSuite(suite) {
65
+ suite.parent = this;
66
+ this._entries.push(suite);
67
+ }
68
+ _prependSuite(suite) {
69
+ suite.parent = this;
70
+ this._entries.unshift(suite);
71
+ }
72
+ allTests() {
73
+ const result = [];
74
+ const visit = (suite) => {
75
+ for (const entry of suite._entries) {
76
+ if (entry instanceof Suite)
77
+ visit(entry);
78
+ else
79
+ result.push(entry);
80
+ }
81
+ };
82
+ visit(this);
83
+ return result;
84
+ }
85
+ _hasTests() {
86
+ let result = false;
87
+ const visit = (suite) => {
88
+ for (const entry of suite._entries) {
89
+ if (result)
90
+ return;
91
+ if (entry instanceof Suite)
92
+ visit(entry);
93
+ else
94
+ result = true;
95
+ }
96
+ };
97
+ visit(this);
98
+ return result;
99
+ }
100
+ titlePath() {
101
+ const titlePath = this.parent ? this.parent.titlePath() : [];
102
+ if (this.title || this._type !== "describe")
103
+ titlePath.push(this.title);
104
+ return titlePath;
105
+ }
106
+ _collectGrepTitlePath(path) {
107
+ if (this.parent)
108
+ this.parent._collectGrepTitlePath(path);
109
+ if (this.title || this._type !== "describe")
110
+ path.push(this.title);
111
+ path.push(...this._tags);
112
+ }
113
+ _getOnlyItems() {
114
+ const items = [];
115
+ if (this._only)
116
+ items.push(this);
117
+ for (const suite of this.suites)
118
+ items.push(...suite._getOnlyItems());
119
+ items.push(...this.tests.filter((test) => test._only));
120
+ return items;
121
+ }
122
+ _deepClone() {
123
+ const suite = this._clone();
124
+ for (const entry of this._entries) {
125
+ if (entry instanceof Suite)
126
+ suite._addSuite(entry._deepClone());
127
+ else
128
+ suite._addTest(entry._clone());
129
+ }
130
+ return suite;
131
+ }
132
+ _deepSerialize() {
133
+ const suite = this._serialize();
134
+ suite.entries = [];
135
+ for (const entry of this._entries) {
136
+ if (entry instanceof Suite)
137
+ suite.entries.push(entry._deepSerialize());
138
+ else
139
+ suite.entries.push(entry._serialize());
140
+ }
141
+ return suite;
142
+ }
143
+ static _deepParse(data) {
144
+ const suite = Suite._parse(data);
145
+ for (const entry of data.entries) {
146
+ if (entry.kind === "suite")
147
+ suite._addSuite(Suite._deepParse(entry));
148
+ else
149
+ suite._addTest(TestCase._parse(entry));
150
+ }
151
+ return suite;
152
+ }
153
+ forEachTest(visitor) {
154
+ for (const entry of this._entries) {
155
+ if (entry instanceof Suite)
156
+ entry.forEachTest(visitor);
157
+ else
158
+ visitor(entry, this);
159
+ }
160
+ }
161
+ _serialize() {
162
+ return {
163
+ kind: "suite",
164
+ title: this.title,
165
+ type: this._type,
166
+ location: this.location,
167
+ only: this._only,
168
+ requireFile: this._requireFile,
169
+ timeout: this._timeout,
170
+ retries: this._retries,
171
+ staticAnnotations: this._staticAnnotations.slice(),
172
+ tags: this._tags.slice(),
173
+ modifiers: this._modifiers.slice(),
174
+ parallelMode: this._parallelMode,
175
+ hooks: this._hooks.map((h) => ({ type: h.type, location: h.location, title: h.title })),
176
+ fileId: this._fileId
177
+ };
178
+ }
179
+ static _parse(data) {
180
+ const suite = new Suite(data.title, data.type);
181
+ suite.location = data.location;
182
+ suite._only = data.only;
183
+ suite._requireFile = data.requireFile;
184
+ suite._timeout = data.timeout;
185
+ suite._retries = data.retries;
186
+ suite._staticAnnotations = data.staticAnnotations;
187
+ suite._tags = data.tags;
188
+ suite._modifiers = data.modifiers;
189
+ suite._parallelMode = data.parallelMode;
190
+ suite._hooks = data.hooks.map((h) => ({ type: h.type, location: h.location, title: h.title, fn: () => {
191
+ } }));
192
+ suite._fileId = data.fileId;
193
+ return suite;
194
+ }
195
+ _clone() {
196
+ const data = this._serialize();
197
+ const suite = Suite._parse(data);
198
+ suite._use = this._use.slice();
199
+ suite._hooks = this._hooks.slice();
200
+ suite._fullProject = this._fullProject;
201
+ return suite;
202
+ }
203
+ project() {
204
+ return this._fullProject?.project || this.parent?.project();
205
+ }
206
+ }
207
+ class TestCase extends Base {
208
+ constructor(title, fn, testType, location) {
209
+ super(title);
210
+ this.results = [];
211
+ this.type = "test";
212
+ this.expectedStatus = "passed";
213
+ this.timeout = 0;
214
+ this.annotations = [];
215
+ this.retries = 0;
216
+ this.repeatEachIndex = 0;
217
+ this.id = "";
218
+ this._poolDigest = "";
219
+ this._workerHash = "";
220
+ this._projectId = "";
221
+ // Explicitly declared tags that are not a part of the title.
222
+ this._tags = [];
223
+ this.fn = fn;
224
+ this._testType = testType;
225
+ this.location = location;
226
+ }
227
+ titlePath() {
228
+ const titlePath = this.parent ? this.parent.titlePath() : [];
229
+ titlePath.push(this.title);
230
+ return titlePath;
231
+ }
232
+ outcome() {
233
+ return (0, import_teleReceiver.computeTestCaseOutcome)(this);
234
+ }
235
+ ok() {
236
+ const status = this.outcome();
237
+ return status === "expected" || status === "flaky" || status === "skipped";
238
+ }
239
+ get tags() {
240
+ const titleTags = this._grepBaseTitlePath().join(" ").match(/@[\S]+/g) || [];
241
+ return [
242
+ ...titleTags,
243
+ ...this._tags
244
+ ];
245
+ }
246
+ _serialize() {
247
+ return {
248
+ kind: "test",
249
+ id: this.id,
250
+ title: this.title,
251
+ retries: this.retries,
252
+ timeout: this.timeout,
253
+ expectedStatus: this.expectedStatus,
254
+ location: this.location,
255
+ only: this._only,
256
+ requireFile: this._requireFile,
257
+ poolDigest: this._poolDigest,
258
+ workerHash: this._workerHash,
259
+ annotations: this.annotations.slice(),
260
+ tags: this._tags.slice(),
261
+ projectId: this._projectId
262
+ };
263
+ }
264
+ static _parse(data) {
265
+ const test = new TestCase(data.title, () => {
266
+ }, import_testType.rootTestType, data.location);
267
+ test.id = data.id;
268
+ test.retries = data.retries;
269
+ test.timeout = data.timeout;
270
+ test.expectedStatus = data.expectedStatus;
271
+ test._only = data.only;
272
+ test._requireFile = data.requireFile;
273
+ test._poolDigest = data.poolDigest;
274
+ test._workerHash = data.workerHash;
275
+ test.annotations = data.annotations;
276
+ test._tags = data.tags;
277
+ test._projectId = data.projectId;
278
+ return test;
279
+ }
280
+ _clone() {
281
+ const data = this._serialize();
282
+ const test = TestCase._parse(data);
283
+ test._testType = this._testType;
284
+ test.fn = this.fn;
285
+ return test;
286
+ }
287
+ _appendTestResult() {
288
+ const result = {
289
+ retry: this.results.length,
290
+ parallelIndex: -1,
291
+ workerIndex: -1,
292
+ shardIndex: -1,
293
+ duration: 0,
294
+ startTime: /* @__PURE__ */ new Date(),
295
+ stdout: [],
296
+ stderr: [],
297
+ attachments: [],
298
+ status: "skipped",
299
+ steps: [],
300
+ errors: [],
301
+ annotations: []
302
+ };
303
+ this.results.push(result);
304
+ return result;
305
+ }
306
+ _grepBaseTitlePath() {
307
+ const path = [];
308
+ this.parent._collectGrepTitlePath(path);
309
+ path.push(this.title);
310
+ return path;
311
+ }
312
+ _grepTitleWithTags() {
313
+ const path = this._grepBaseTitlePath();
314
+ path.push(...this._tags);
315
+ return path.join(" ");
316
+ }
317
+ }
318
+ // Annotate the CommonJS export names for ESM import in node:
319
+ 0 && (module.exports = {
320
+ Suite,
321
+ TestCase
322
+ });
@@ -0,0 +1,101 @@
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 testLoader_exports = {};
30
+ __export(testLoader_exports, {
31
+ defaultTimeout: () => defaultTimeout,
32
+ loadTestFile: () => loadTestFile
33
+ });
34
+ module.exports = __toCommonJS(testLoader_exports);
35
+ var import_path = __toESM(require("path"));
36
+ var import_util = __toESM(require("util"));
37
+ var esmLoaderHost = __toESM(require("./esmLoaderHost"));
38
+ var import_globals = require("./globals");
39
+ var import_test = require("./test");
40
+ var import_compilationCache = require("../transform/compilationCache");
41
+ var import_transform = require("../transform/transform");
42
+ var import_util2 = require("../util");
43
+ const defaultTimeout = 3e4;
44
+ const cachedFileSuites = /* @__PURE__ */ new Map();
45
+ async function loadTestFile(file, config, testErrors) {
46
+ if (cachedFileSuites.has(file))
47
+ return cachedFileSuites.get(file);
48
+ const suite = new import_test.Suite(import_path.default.relative(config.config.rootDir, file) || import_path.default.basename(file), "file");
49
+ suite._requireFile = file;
50
+ suite.location = { file, line: 0, column: 0 };
51
+ suite._tags = [...config.config.tags];
52
+ (0, import_globals.setCurrentlyLoadingFileSuite)(suite);
53
+ if (!(0, import_globals.isWorkerProcess)()) {
54
+ (0, import_compilationCache.startCollectingFileDeps)();
55
+ await esmLoaderHost.startCollectingFileDeps();
56
+ }
57
+ try {
58
+ await (0, import_transform.requireOrImport)(file);
59
+ cachedFileSuites.set(file, suite);
60
+ } catch (e) {
61
+ if (!testErrors)
62
+ throw e;
63
+ testErrors.push(serializeLoadError(file, e));
64
+ } finally {
65
+ (0, import_globals.setCurrentlyLoadingFileSuite)(void 0);
66
+ if (!(0, import_globals.isWorkerProcess)()) {
67
+ (0, import_compilationCache.stopCollectingFileDeps)(file);
68
+ await esmLoaderHost.stopCollectingFileDeps(file);
69
+ }
70
+ }
71
+ {
72
+ const files = /* @__PURE__ */ new Set();
73
+ suite.allTests().map((t) => files.add(t.location.file));
74
+ if (files.size === 1) {
75
+ const mappedFile = files.values().next().value;
76
+ if (suite.location.file !== mappedFile) {
77
+ if (import_path.default.extname(mappedFile) !== import_path.default.extname(suite.location.file))
78
+ suite.location.file = mappedFile;
79
+ }
80
+ }
81
+ }
82
+ return suite;
83
+ }
84
+ function serializeLoadError(file, error) {
85
+ if (error instanceof Error) {
86
+ const result = (0, import_util2.filterStackTrace)(error);
87
+ const loc = error.loc;
88
+ result.location = loc ? {
89
+ file,
90
+ line: loc.line || 0,
91
+ column: loc.column || 0
92
+ } : void 0;
93
+ return result;
94
+ }
95
+ return { value: import_util.default.inspect(error) };
96
+ }
97
+ // Annotate the CommonJS export names for ESM import in node:
98
+ 0 && (module.exports = {
99
+ defaultTimeout,
100
+ loadTestFile
101
+ });