MCPcopy Create free account
hub / github.com/wonderwhy-er/DesktopCommanderMCP / testNodeREPL

Function testNodeREPL

test/simple-node-repl-test.js:4–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import { replManager } from '../dist/repl-manager.js';
3
4async function testNodeREPL() {
5 try {
6 console.log('Creating a Node.js REPL session...');
7 const pid = await replManager.createSession('node', 5000);
8 console.log(`Created Node.js REPL session with PID ${pid}`);
9
10 console.log('Executing a simple Node.js command...');
11 const result = await replManager.executeCode(pid, 'console.log("Hello from Node.js!")', {
12 waitForPrompt: true,
13 timeout: 5000
14 });
15 console.log(`Result: ${JSON.stringify(result)}`);
16
17 console.log('Executing a multi-line Node.js code block...');
18 const nodeCode = `
19function greet(name) {
20 return \`Hello, \${name}!\`;
21}
22
23console.log(greet("World"));
24`;
25
26 const result2 = await replManager.executeCode(pid, nodeCode, {
27 multiline: true,
28 timeout: 10000,
29 waitForPrompt: true
30 });
31 console.log(`Multi-line result: ${JSON.stringify(result2)}`);
32
33 console.log('Terminating the session...');
34 const terminated = await replManager.terminateSession(pid);
35 console.log(`Session terminated: ${terminated}`);
36
37 console.log('Test completed successfully');
38 } catch (error) {
39 console.error(`Test failed with error: ${error.message}`);
40 }
41}
42
43testNodeREPL();

Callers 1

Calls 1

logMethod · 0.80

Tested by

no test coverage detected