Playwright+Cucumber报错:ReferenceError: exports is not defined
解决ES模块环境下Cucumber配置的exports错误
你遇到的ReferenceError: exports is not defined in ES module scope错误,是因为你的cucumber.mjs是ES模块文件(后缀为.mjs且项目启用了"type": "module"),却使用了CommonJS规范的module.exports语法,这在ES模块环境中不被支持。
修改cucumber.mjs文件,将CommonJS的导出语法替换为ES模块的导出语法即可:
const common = ` features/**/*.feature --require setup/assertions.cjs --require setup/hooks.cjs --require step-definitions/**/*.steps.js --publish-quiet `; export default { default: `${common} features/!**/!*.feature` };
修改后再执行npm run test -- --tags "@Begin"命令,即可正常运行测试。
内容的提问来源于stack exchange,提问作者nosequeweaponer
相关产品推荐
相关产品推荐

