File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { openNewTab } from "./open-new-tab.js";
1111import { closeTab } from "./close-tab.js" ;
1212import { waitForElement } from "./wait-for-element.js" ;
1313import { attachToBrowser } from "./attach-to-browser.js" ;
14+ import { runTests } from "./run-tests.js" ;
1415
1516export const tools = [
1617 navigate ,
@@ -25,4 +26,5 @@ export const tools = [
2526 closeTab ,
2627 waitForElement ,
2728 attachToBrowser ,
29+ runTests ,
2830] as const satisfies ToolDefinition < any > [ ] ; // eslint-disable-line @typescript-eslint/no-explicit-any
Original file line number Diff line number Diff line change 1+ import { ToolDefinition } from "../types.js" ;
2+ import { ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js" ;
3+ import { createSimpleResponse , createErrorResponse } from "../responses/index.js" ;
4+ import { execSync } from "child_process" ;
5+ import { z } from "zod" ;
6+
7+ const runTestsSchema = {
8+ projectDir : z . string ( ) . describe ( "Project directory" ) ,
9+ keepBrowser : z . boolean ( ) . describe ( "Save browser after run" ) . optional ( ) ,
10+ } ;
11+
12+ const runTestsCb : ToolCallback < typeof runTestsSchema > = async ( { projectDir, keepBrowser = false } ) => {
13+ try {
14+ const result = execSync ( `cd ${ projectDir } && npx testplane ${ keepBrowser ? "--keep-browser" : "" } ` ) ;
15+
16+ return createSimpleResponse ( `Successfully run tests:\n${ result } ` ) ;
17+ } catch ( error ) {
18+ console . error ( "Error run tests:" , error ) ;
19+ return createErrorResponse ( "Error run tests" , error instanceof Error ? error : undefined ) ;
20+ }
21+ } ;
22+
23+ export const runTests : ToolDefinition < typeof runTestsSchema > = {
24+ name : "runTests" ,
25+ description : "Run tests" ,
26+ schema : runTestsSchema ,
27+ cb : runTestsCb ,
28+ } ;
You can’t perform that action at this time.
0 commit comments