MCPcopy
hub / github.com/7836246/cursor2api / test

Function test

test/e2e-agentic.mjs:503–529  ·  view source on GitHub ↗
(name, fn)

Source from the content-addressed store, hash-verified

501const allResults = [];
502
503async function test(name, fn) {
504 const t0 = Date.now();
505 process.stdout.write(`\n ${C.blue}▶${C.reset} ${C.bold}${name}${C.reset}\n`);
506 try {
507 const result = await fn();
508 const ms = ((Date.now() - t0) / 1000).toFixed(1);
509 console.log(` ${ok('通过')} (${ms}s, ${result?.turns || '?'} 轮工具调用)`);
510 if (result?.toolCallLog) {
511 const summary = result.toolCallLog
512 .filter(t => t.tool !== '__DONE__')
513 .map(t => `${t.turn}:${t.tool}`)
514 .join(' → ');
515 console.log(info(` 路径: ${summary}`));
516 }
517 if (result?.finalResult) {
518 console.log(info(` 结果: "${String(result.finalResult).substring(0, 120)}..."`));
519 }
520 passed++;
521 allResults.push({ name, ok: true });
522 } catch (e) {
523 const ms = ((Date.now() - t0) / 1000).toFixed(1);
524 console.log(` ${fail('失败')} (${ms}s)`);
525 console.log(` ${C.red}${e.message}${C.reset}`);
526 failed++;
527 allResults.push({ name, ok: false, error: e.message });
528 }
529}
530
531// ════════════════════════════════════════════════════════════════════
532// 检测服务器

Callers 1

e2e-agentic.mjsFile · 0.70

Calls 6

logMethod · 0.80
pushMethod · 0.80
okFunction · 0.70
infoFunction · 0.70
failFunction · 0.70
writeMethod · 0.45

Tested by

no test coverage detected