codeceptjs / codeceptjs/CodeceptJS

Migrate CodeceptJS to ESM (Top-level await)

Đang mở
#4,185 8 bình luận 1 reaction 2 người được giao Được @DenysKuchma nhận Xem trên GitHub
4.0
Ngôn ngữ chính
JavaScript
Star
4.2k
Fork
757
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
16

Mô tả

#### What are you trying to achieve?
I need to use top-level `await` to retrieve config from AWS and other APIs but CodeceptJS seems completely incompatible with ES modules. Top-level await is simply not possible in CommonJS. Are there any plans to support ES modules?

#### What do you get instead?

If you set `"type": "module"` in `package.json` you get this error:

```bash
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/REDACTED/config/codecept.conf.js from /Users/REDACTED/node_modules/codeceptjs/lib/config.js not supported.
Instead change the require of codecept.conf.js in /Users/REDACTED/node_modules/codeceptjs/lib/config.js to a dynamic import() which is available in all CommonJS modules.
at loadConfigFile (/Users/REDACTED/node_modules/codeceptjs/lib/config.js:160:26)
at Config.load (/Users/REDACTED/node_modules/codeceptjs/lib/config.js:91:14)
at module.exports.getConfig (/Users/REDACTED/node_modules/codeceptjs/lib/command/utils.js:14:33)
at module.exports (/Users/REDACTED/node_modules/codeceptjs/lib/command/run.js:18:16)
at Command. (/Users/REDACTED/node_modules/codeceptjs/bin/codecept.js:9:11)
```

### Details

* CodeceptJS version: 3.5.13-beta.3
* NodeJS Version: v20.10.0
* Operating System: MacOS Ventura

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.