Cucumber多配置文件迁移至ESM格式后default配置无法识别求助
Cucumber JS ESM配置不生效的解决方法
问题核心是Cucumber对ESM格式配置文件的导出规则:ESM配置必须使用命名导出export const config,而非默认导出export default。
修正后的ESM配置代码
const common = { // ...你的公共配置内容 }; export const config = { ci: { ...common, format: [ "progress", ], }, default: { ...common, format: [ "progress-bar", ], }, };
注意事项
- 保留
package.json中的"type": "module"配置,确保Node.js以ESM模式加载配置文件。 - 运行命令和原逻辑一致:指定配置用
npx cucumber-js --profile ci,不指定时自动启用default配置。
内容的提问来源于stack exchange,提问作者user4695271
相关产品推荐
相关产品推荐

