ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / mcp / test / testTools.js
Blame History Raw 109 lines
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 testTools_exports = {};
30
__export(testTools_exports, {
31
debugTest: () => debugTest,
32
listTests: () => listTests,
33
runTests: () => runTests
34
});
35
module.exports = __toCommonJS(testTools_exports);
36
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
37
var import_listModeReporter = __toESM(require("../../reporters/listModeReporter"));
38
var import_testTool = require("./testTool");
39
const listTests = (0, import_testTool.defineTestTool)({
40
schema: {
41
name: "test_list",
42
title: "List tests",
43
description: "List tests",
44
inputSchema: import_mcpBundle.z.object({}),
45
type: "readOnly"
46
},
47
handle: async (context) => {
48
const { testRunner, screen, output } = await context.createTestRunner();
49
const reporter = new import_listModeReporter.default({ screen, includeTestId: true });
50
await testRunner.listTests(reporter, {});
51
return { content: output.map((text) => ({ type: "text", text })) };
52
}
53
});
54
const runTests = (0, import_testTool.defineTestTool)({
55
schema: {
56
name: "test_run",
57
title: "Run tests",
58
description: "Run tests",
59
inputSchema: import_mcpBundle.z.object({
60
locations: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe('Folder, file or location to run: "test/e2e" or "test/e2e/file.spec.ts" or "test/e2e/file.spec.ts:20"'),
61
projects: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe('Projects to run, projects from playwright.config.ts, by default runs all projects. Running with "chromium" is a good start')
62
}),
63
type: "readOnly"
64
},
65
handle: async (context, params) => {
66
const { output } = await context.runTestsWithGlobalSetupAndPossiblePause({
67
locations: params.locations ?? [],
68
projects: params.projects,
69
disableConfigReporters: true
70
});
71
return { content: [{ type: "text", text: output }] };
72
}
73
});
74
const debugTest = (0, import_testTool.defineTestTool)({
75
schema: {
76
name: "test_debug",
77
title: "Debug single test",
78
description: "Debug single test",
79
inputSchema: import_mcpBundle.z.object({
80
test: import_mcpBundle.z.object({
81
id: import_mcpBundle.z.string().describe("Test ID to debug."),
82
title: import_mcpBundle.z.string().describe("Human readable test title for granting permission to debug the test.")
83
})
84
}),
85
type: "readOnly"
86
},
87
handle: async (context, params) => {
88
const { output, status } = await context.runTestsWithGlobalSetupAndPossiblePause({
89
headed: context.computedHeaded,
90
locations: [],
91
// we can make this faster by passing the test's location, so we don't need to scan all tests to find the ID
92
testIds: [params.test.id],
93
// For automatic recovery
94
timeout: 0,
95
workers: 1,
96
pauseOnError: true,
97
disableConfigReporters: true,
98
actionTimeout: 5e3
99
});
100
return { content: [{ type: "text", text: output }], isError: status !== "paused" && status !== "passed" };
101
}
102
});
103
// Annotate the CommonJS export names for ESM import in node:
104
0 && (module.exports = {
105
debugTest,
106
listTests,
107
runTests
108
});
109

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button