Skip to content

Commit 46e3943

Browse files
committed
Added Unit Test by removing the existing ones
1 parent 20efb01 commit 46e3943

33 files changed

+1375
-2523
lines changed

jest.config.cjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ module.exports = {
1010
],
1111
modulePathIgnorePatterns: ["<rootDir>/docs/"],
1212
moduleNameMapper: {
13-
"^./tools.js$": "<rootDir>/test/helpers/index.ts",
14-
"^./toolsHandler.js$": "<rootDir>/test/helpers/index.ts",
13+
"^(.*)\\.js$": "$1"
1514
},
15+
transform: {
16+
'^.+\\.tsx?$': ['ts-jest', {
17+
useESM: true,
18+
tsconfig: 'tsconfig.test.json'
19+
}],
20+
},
21+
extensionsToTreatAsEsm: ['.ts'],
22+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
1623
};

run-tests.cjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { execSync } = require('child_process');
2+
3+
try {
4+
console.log("Running tests with coverage...");
5+
execSync('npx jest --no-cache --coverage', { stdio: 'inherit' });
6+
console.log("Tests completed successfully!");
7+
} catch (error) {
8+
console.error("Error running tests:", error.message);
9+
console.log(error.stdout?.toString() || "No output");
10+
process.exit(1);
11+
}

run-tests.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { execSync } = require('child_process');
2+
3+
try {
4+
console.log('Running tests...');
5+
const output = execSync('npx jest --no-cache --coverage', { encoding: 'utf8' });
6+
console.log(output);
7+
} catch (error) {
8+
console.error('Error running tests:', error.message);
9+
console.log(error.stdout);
10+
}
Lines changed: 330 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Tool Definitions should match snapshot 1`] = `
4+
[
5+
{
6+
"description": "Navigate to a URL",
7+
"inputSchema": {
8+
"properties": {
9+
"height": {
10+
"description": "Viewport height in pixels (default: 720)",
11+
"type": "number",
12+
},
13+
"timeout": {
14+
"description": "Navigation timeout in milliseconds",
15+
"type": "number",
16+
},
17+
"url": {
18+
"type": "string",
19+
},
20+
"waitUntil": {
21+
"description": "Navigation wait condition",
22+
"type": "string",
23+
},
24+
"width": {
25+
"description": "Viewport width in pixels (default: 1280)",
26+
"type": "number",
27+
},
28+
},
29+
"required": [
30+
"url",
31+
],
32+
"type": "object",
33+
},
34+
"name": "playwright_navigate",
35+
},
36+
{
37+
"description": "Take a screenshot of the current page or a specific element",
38+
"inputSchema": {
39+
"properties": {
40+
"downloadsDir": {
41+
"description": "Custom downloads directory path (default: user's Downloads folder)",
42+
"type": "string",
43+
},
44+
"fullPage": {
45+
"description": "Store screenshot of the entire page (default: false)",
46+
"type": "boolean",
47+
},
48+
"height": {
49+
"description": "Height in pixels (default: 600)",
50+
"type": "number",
51+
},
52+
"name": {
53+
"description": "Name for the screenshot",
54+
"type": "string",
55+
},
56+
"savePng": {
57+
"description": "Save screenshot as PNG file (default: false)",
58+
"type": "boolean",
59+
},
60+
"selector": {
61+
"description": "CSS selector for element to screenshot",
62+
"type": "string",
63+
},
64+
"storeBase64": {
65+
"description": "Store screenshot in base64 format (default: true)",
66+
"type": "boolean",
67+
},
68+
"width": {
69+
"description": "Width in pixels (default: 800)",
70+
"type": "number",
71+
},
72+
},
73+
"required": [
74+
"name",
75+
],
76+
"type": "object",
77+
},
78+
"name": "playwright_screenshot",
79+
},
80+
{
81+
"description": "Click an element on the page",
82+
"inputSchema": {
83+
"properties": {
84+
"selector": {
85+
"description": "CSS selector for the element to click",
86+
"type": "string",
87+
},
88+
},
89+
"required": [
90+
"selector",
91+
],
92+
"type": "object",
93+
},
94+
"name": "playwright_click",
95+
},
96+
{
97+
"description": "Click an element in an iframe on the page",
98+
"inputSchema": {
99+
"properties": {
100+
"iframeSelector": {
101+
"description": "CSS selector for the iframe containing the element to click",
102+
"type": "string",
103+
},
104+
"selector": {
105+
"description": "CSS selector for the element to click",
106+
"type": "string",
107+
},
108+
},
109+
"required": [
110+
"iframeSelector",
111+
"selector",
112+
],
113+
"type": "object",
114+
},
115+
"name": "playwright_iframe_click",
116+
},
117+
{
118+
"description": "fill out an input field",
119+
"inputSchema": {
120+
"properties": {
121+
"selector": {
122+
"description": "CSS selector for input field",
123+
"type": "string",
124+
},
125+
"value": {
126+
"description": "Value to fill",
127+
"type": "string",
128+
},
129+
},
130+
"required": [
131+
"selector",
132+
"value",
133+
],
134+
"type": "object",
135+
},
136+
"name": "playwright_fill",
137+
},
138+
{
139+
"description": "Select an element on the page with Select tag",
140+
"inputSchema": {
141+
"properties": {
142+
"selector": {
143+
"description": "CSS selector for element to select",
144+
"type": "string",
145+
},
146+
"value": {
147+
"description": "Value to select",
148+
"type": "string",
149+
},
150+
},
151+
"required": [
152+
"selector",
153+
"value",
154+
],
155+
"type": "object",
156+
},
157+
"name": "playwright_select",
158+
},
159+
{
160+
"description": "Hover an element on the page",
161+
"inputSchema": {
162+
"properties": {
163+
"selector": {
164+
"description": "CSS selector for element to hover",
165+
"type": "string",
166+
},
167+
},
168+
"required": [
169+
"selector",
170+
],
171+
"type": "object",
172+
},
173+
"name": "playwright_hover",
174+
},
175+
{
176+
"description": "Execute JavaScript in the browser console",
177+
"inputSchema": {
178+
"properties": {
179+
"script": {
180+
"description": "JavaScript code to execute",
181+
"type": "string",
182+
},
183+
},
184+
"required": [
185+
"script",
186+
],
187+
"type": "object",
188+
},
189+
"name": "playwright_evaluate",
190+
},
191+
{
192+
"description": "Retrieve console logs from the browser with filtering options",
193+
"inputSchema": {
194+
"properties": {
195+
"clear": {
196+
"description": "Whether to clear logs after retrieval (default: false)",
197+
"type": "boolean",
198+
},
199+
"limit": {
200+
"description": "Maximum number of logs to return",
201+
"type": "number",
202+
},
203+
"search": {
204+
"description": "Text to search for in logs (handles text with square brackets)",
205+
"type": "string",
206+
},
207+
"type": {
208+
"description": "Type of logs to retrieve (all, error, warning, log, info, debug)",
209+
"enum": [
210+
"all",
211+
"error",
212+
"warning",
213+
"log",
214+
"info",
215+
"debug",
216+
],
217+
"type": "string",
218+
},
219+
},
220+
"required": [],
221+
"type": "object",
222+
},
223+
"name": "playwright_console_logs",
224+
},
225+
{
226+
"description": "Close the browser and release all resources",
227+
"inputSchema": {
228+
"properties": {},
229+
"required": [],
230+
"type": "object",
231+
},
232+
"name": "playwright_close",
233+
},
234+
{
235+
"description": "Perform an HTTP GET request",
236+
"inputSchema": {
237+
"properties": {
238+
"url": {
239+
"description": "URL to perform GET operation",
240+
"type": "string",
241+
},
242+
},
243+
"required": [
244+
"url",
245+
],
246+
"type": "object",
247+
},
248+
"name": "playwright_get",
249+
},
250+
{
251+
"description": "Perform an HTTP POST request",
252+
"inputSchema": {
253+
"properties": {
254+
"url": {
255+
"description": "URL to perform POST operation",
256+
"type": "string",
257+
},
258+
"value": {
259+
"description": "Data to post in the body",
260+
"type": "string",
261+
},
262+
},
263+
"required": [
264+
"url",
265+
"value",
266+
],
267+
"type": "object",
268+
},
269+
"name": "playwright_post",
270+
},
271+
{
272+
"description": "Perform an HTTP PUT request",
273+
"inputSchema": {
274+
"properties": {
275+
"url": {
276+
"description": "URL to perform PUT operation",
277+
"type": "string",
278+
},
279+
"value": {
280+
"description": "Data to PUT in the body",
281+
"type": "string",
282+
},
283+
},
284+
"required": [
285+
"url",
286+
"value",
287+
],
288+
"type": "object",
289+
},
290+
"name": "playwright_put",
291+
},
292+
{
293+
"description": "Perform an HTTP PATCH request",
294+
"inputSchema": {
295+
"properties": {
296+
"url": {
297+
"description": "URL to perform PUT operation",
298+
"type": "string",
299+
},
300+
"value": {
301+
"description": "Data to PATCH in the body",
302+
"type": "string",
303+
},
304+
},
305+
"required": [
306+
"url",
307+
"value",
308+
],
309+
"type": "object",
310+
},
311+
"name": "playwright_patch",
312+
},
313+
{
314+
"description": "Perform an HTTP DELETE request",
315+
"inputSchema": {
316+
"properties": {
317+
"url": {
318+
"description": "URL to perform DELETE operation",
319+
"type": "string",
320+
},
321+
},
322+
"required": [
323+
"url",
324+
],
325+
"type": "object",
326+
},
327+
"name": "playwright_delete",
328+
},
329+
]
330+
`;

0 commit comments

Comments
 (0)