(configPath, pluginOverrides)
| 505 | } |
| 506 | |
| 507 | async function initCodecept(configPath, pluginOverrides) { |
| 508 | const plugins = normalizePluginOverrides(pluginOverrides) |
| 509 | const sig = pluginsSignature(plugins) |
| 510 | |
| 511 | if (containerInitialized) { |
| 512 | if (!Object.keys(plugins).length || sig === currentPluginsSig) return |
| 513 | await teardownContainer() |
| 514 | } |
| 515 | |
| 516 | const testRoot = process.env.CODECEPTJS_PROJECT_DIR || process.cwd() |
| 517 | |
| 518 | if (!configPath) { |
| 519 | configPath = process.env.CODECEPTJS_CONFIG || resolvePath(testRoot, 'codecept.conf.js') |
| 520 | if (!existsSync(configPath)) configPath = resolvePath(testRoot, 'codecept.conf.cjs') |
| 521 | } |
| 522 | |
| 523 | if (!existsSync(configPath)) { |
| 524 | throw new Error( |
| 525 | `CodeceptJS config not found: ${configPath}\n` + |
| 526 | `CODECEPTJS_CONFIG=${process.env.CODECEPTJS_CONFIG || 'not set'}\n` + |
| 527 | `CODECEPTJS_PROJECT_DIR=${process.env.CODECEPTJS_PROJECT_DIR || 'not set'}\n` + |
| 528 | `cwd=${process.cwd()}` |
| 529 | ) |
| 530 | } |
| 531 | |
| 532 | console.log = () => {} |
| 533 | console.error = () => {} |
| 534 | console.warn = () => {} |
| 535 | |
| 536 | const { getConfig } = await import('../lib/command/utils.js') |
| 537 | const config = await getConfig(configPath) |
| 538 | |
| 539 | // aiTrace is the canonical per-step ARIA/HTML/screenshot capture for MCP. |
| 540 | // Always on so run_code / continue can read the latest snapshot from disk |
| 541 | // instead of double-capturing through grabAriaSnapshot etc. |
| 542 | applyPluginOverrides(config, { aiTrace: { on: 'step' }, browser: { show: false }, ...plugins }) |
| 543 | |
| 544 | codecept = new Codecept(config, {}) |
| 545 | await codecept.init(testRoot) |
| 546 | await container.started() |
| 547 | |
| 548 | containerInitialized = true |
| 549 | browserStarted = true |
| 550 | aiTraceEnabled = config.plugins?.aiTrace?.enabled === true |
| 551 | currentPluginsSig = sig |
| 552 | } |
| 553 | |
| 554 | async function formatReturnValue(value) { |
| 555 | if (value instanceof WebElement) return await value.describe() |
no test coverage detected