Skip to content

CJS Support #1028

Description

@heksein

If to follow official documentation (https://webdriver.io/docs/api/expect-webdriverio/#default-options) and try to set custom matcher options on before hook, then ERR_REQUIRE_ESM happens on the next line:
import { setOptions } from 'expect-webdriverio'

Error:

ERROR @wdio/config:ConfigParser: Failed loading configuration file: file://***/wdio.conf.js: require() of ES Module /Users/***/node_modules/expect-webdriverio/lib/index.js from /Users/***/wdio.conf.js not supported.
Instead change the require of index.js in /Users/***/wdio.conf.js to a dynamic import() which is available in all CommonJS modules.

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/***/node_modules/expect-webdriverio/lib/index.js from /Users/***/wdio.conf.js not supported.
Instead change the require of index.js in /Users/***/wdio.conf.js to a dynamic import() which is available in all CommonJS modules.

ENV: MacOS Ventura 13.1
Node version: 19.3.0
NPX version: 9.2.0

package.json:

{
  "dependencies": {
    "@babel/cli": "^7.20.7",
    "@babel/core": "^7.20.7",
    "@babel/preset-env": "^7.20.2",
    "@babel/register": "^7.18.9",
    "@wdio/allure-reporter": "^8.0.13",
    "@wdio/cli": "^8.0.13",
    "@wdio/concise-reporter": "^8.3.0",
    "@wdio/local-runner": "^8.0.13",
    "@wdio/mocha-framework": "^8.0.13",
    "@wdio/spec-reporter": "^8.0.13",
    "chromedriver": "^108.0.0",
    "csv-parse": "^5.3.3",
    "fs": "^0.0.1-security",
    "fs-extra": "^11.1.0",
    "jest-matcher-utils": "^29.4.1",
    "wdio-chromedriver-service": "^8.0.1",
    "wdio-wait-for": "^3.0.1"
  },
  "scripts": {
    "wdio": "wdio run ./wdio.conf.js"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions