Resolve AEM Cloud Manager deployment failures during Custom UI Test due to ESM/CommonJS compatibility

This article provides steps to resolve deployment pipeline failures during the Custom UI Test step in Adobe Experience Manager (AEM) Cloud Manager, which are caused by compatibility issues between ES modules (ESM) and CommonJS dependencies.

Description description

Environment

Adobe Experience Manager as a Cloud Service (all versions)

Issue/Symptoms

  • The deployment pipeline fails during the Custom UI Test step in Cloud Manager.
  • Error logs show messages such as: ERR_REQUIRE_ESM: Must use import to load ES Module: @wdio/logger.
  • Additional errors occur when ESM-only reporters (for example, wdio-html-nice-reporter) are loaded using require() in configuration files, resulting in similar ERR_REQUIRE_ESM errors.
  • Indexing failures may also occur if the target environment is not fully active during deployment.

Cause

The failures are due to incompatibilities between CommonJS and ES module dependencies in the custom UI test configuration. Additionally, deployment may fail if the target environment is not active.

Resolution resolution

Follow the steps below to resolve the issue:

  1. Review your custom UI test dependencies, especially those related to WebdriverIO (such as @wdio/logger and wdio-html-nice-reporter).

  2. Update import statements for ESM compatibility:

    • Remove all require('@wdio/logger') imports from CommonJS files (such as launcher.js and comparisonstrategy.js).
    • Replace these imports with simple logging statements or use dynamic import() if necessary.
  3. Adjust reporter configuration:

    • If using ESM-only reporters (such as wdio-html-nice-reporter), ensure they are loaded using import syntax rather than require() in configuration files (such as wdio.conf.commons.js).
    • Refactor configuration files to be ESM-compatible if required by your dependency set, or remove ESM-only reporters from the reporters array for the Cloud Manager run.
  4. Ensure the target environment is fully active before running the deployment pipeline to avoid indexing failures. If the environment was previously hibernated, activate it and re-run the pipeline.

  5. Re-run the deployment pipeline and monitor for errors.

  6. Verify that the Custom UI Test step completes successfully and that the deployment proceeds without module compatibility errors.

recommendation-more-help
experience-cloud-kcs-help-kbarticles