Skip to content

Fix/mcp fixes#5548

Merged
DavertMik merged 14 commits into4.xfrom
fix/mcp-fixes
May 4, 2026
Merged

Fix/mcp fixes#5548
DavertMik merged 14 commits into4.xfrom
fix/mcp-fixes

Conversation

@DavertMik
Copy link
Copy Markdown
Contributor

@DavertMik DavertMik commented May 4, 2026

Summary

Cluster of fixes around the MCP server, init, dryRun, workers, and a few core export tweaks. Most changes are about making the MCP loop usable in real projects (rich tool descriptions, headless default, agent-friendly return values) plus paying down a few quality-of-life issues.

What's in here

MCP server (bin/mcp-server.js)

  • Rich tool descriptions that point at traceFile, aiTraceHint, and pauseAt/continue so an agent picking up the tool list knows when to do what.
  • run_code runs in a scope that mirrors the Mocha environment: I, helpers, locate, within, session, secret, inject, pause, tryTo, retryTo, hopeThat, step, element, eachElement, expectElement, plus every support object. Response advertises every symbol via availableObjects.
  • grep argument on run_test / run_step_by_step, mirroring the CLI --grep flag.
  • settleMs argument on snapshot / run_code (default 300ms) so animations / re-renders don't race the capture.
  • Browser defaults to headless (browser: { show: false }) — opt into headed with plugins={ browser: { show: true } }.
  • aiTraceHint surfaces in tool responses when aiTrace is disabled, telling the agent how to re-enable it for richer per-step capture.
  • installShutdownHooks ensures the container is torn down on SIGTERM/SIGINT/beforeExit.
  • formatReturnValue plus WebElement.describe() / toJSON so returning an element from run_code produces a usable plain-object snapshot instead of {}.

Init (lib/command/init.js)

  • -y, --yes flag — skip prompts and use sensible defaults (Playwright + chromium, BASE_URL env for url).
  • Default test glob moved to ./tests/*_test.js for new projects.

Dry run (lib/command/dryRun.js)

  • Stop disabling every plugin. Only block interactive (pause, pauseOnFail) and external-I/O ones (analyze, aiTrace, pageInfo, heal). Plugins that register support objects (e.g. auth → I.login) keep working — helper calls inside are already no-op'd by HelperStep when store.dryRun is true.

Core

  • lib/config.js: populate globalThis.codeceptjs at config-import time so @codeceptjs/configure proxies don't throw before initCodeceptGlobals runs.
  • lib/globals.js: pause, inject, share stay global even under noGlobals: true. They're the everyday debugging / wiring entry points and have no useful import alternative for page-object code that runs before the container is available.
  • lib/index.js: add session, inject, locate to named/default exports.
  • lib/mocha/factory.js: default cleanReferencesAfterRun: false. Mocha 10+ disposes the instance after .run(), which broke every subsequent MCP run_test call.
  • lib/parser.js + lib/mocha/inject.js: only warn on the legacy (I) parameter format when explicitly asked. Stops noisy errors during normal injection.
  • lib/plugin/browser.js: merge plugin config with _args so options set in codecept.conf.js aren't lost when passing CLI flags.
  • lib/workers.js: drop the hardcoded 10-minute overall timeout and make per-worker timeout configurable via CODECEPT_WORKER_TIMEOUT.

Docs

  • docs/continuous-integration.md: rewritten end-to-end (GitHub Actions / GitLab / Bitbucket / Jenkins / CircleCI examples, @testomatio/reporter integration via the GitHub + HTML pipe combo).
  • docs/migration-4.md: small touch-ups.

Type of change

  • 🚀 New functionality
  • 🐛 Bug fix
  • 📋 Documentation changes/updates

Test plan

  • npm test (existing unit suites — trace_test passes; pre-existing REST suite needs the local fixture server)
  • MCP end-to-end: start_browserrun_codesnapshotrun_test with and without pauseAt
  • codeceptjs init -y produces a working config
  • codeceptjs dry-run keeps auth and similar support-object plugins functional

DavertMik and others added 14 commits April 26, 2026 22:27
Resolves conflicts in bin/mcp-server.js by combining:
- origin/4.x: shell session lifecycle (startShellSession/endShellSession),
  per-test plugin overrides, ensureBootstrap caching, TraceReader/ariaDiff
  in run_code, currentAiTraceDir tracking from event.test.before.
- fix/mcp-fixes: rich tool descriptions, expanded run_code scope (locate,
  within, session, secret, inject, pause, tryTo, retryTo, hopeThat, step,
  els, WebElement), grep arg on run_test/run_step_by_step, settleMs on
  snapshot/run_code, aiTraceHint, browser:{show:false} default,
  installShutdownHooks, formatReturnValue for WebElement results.

ensureSession() now auto-starts a shell session for snapshot/run_code so
the previous auto-init UX is preserved on top of the new lifecycle.
The new dry-run no longer disables every plugin (only the interactive
and external-I/O ones), so the customLocator test now sees `Plugins:
screenshot, customLocator` and the strict `toContain('Plugins:
customLocator')` assertion fails. Match the plugin list with a regex
instead — what we care about is that customLocator was activated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Update mcp.md to match the current tool surface (cancel, polymorphic
pauseAt, settleMs, plugins-only-on-start_browser, availableObjects,
WebElement auto-describe, traceFile per scenario) and warn against
running the MCP server from a global codeceptjs install.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@DavertMik DavertMik merged commit caf1a79 into 4.x May 4, 2026
10 checks passed
@DavertMik DavertMik deleted the fix/mcp-fixes branch May 4, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants