Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CJS Support #1028

Open
heksein opened this issue Jan 30, 2023 · 1 comment
Open

CJS Support #1028

heksein opened this issue Jan 30, 2023 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@heksein
Copy link

heksein commented Jan 30, 2023

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"
  }
}
@christian-bromann
Copy link
Member

This is because the package currently does not provide an CJS export. Any contributions that support for CJS are welcome.

@christian-bromann christian-bromann changed the title 'ERR_REQUIRE_ESM' error while importing setOptions CJS Support Jan 30, 2023
@christian-bromann christian-bromann added the help wanted Extra attention is needed label Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants