无法 运行 赛普拉斯中的单个文件

Can not able to run single file in cypress

我在集成文件夹下有一个 5 个 .js 文件,想 运行 在赛普拉斯中使用单个 .js 文件。但抛出的错误如下:

The following validation error was thrown by your plugins file (C:\Users\admin\LegrandRX\cypress\plugins\index.js). Error: The before:run event requires the experimentalRunEvents flag to be enabled. To enable it, set "experimentalRunEvents": true in your cypress.json

我设置了script: { "cy:run": "cypress run"} 我也根据错误在 cypress.json 中尝试了 "experimentalRunEvents": true 但没有成功

Cypress.json 从评论中添加的文件:

{
  "reporter": "cypress-mochawesome-reporter",
  "reporterOptions": {
    "reportDir": "cypress/reports",
    "charts": true,
    "overwrite": false,
    "html": false,
    "json": true,
    "reportPageTitle": "My Test Suite",
    "embeddedScreenshots": true,
    "inlineAssets": true,
    "experimentalRunEvents": true
  },
  "video": false
}

请在reporterOptions

外加上"experimentalRunEvents":true
{
  "reporter": "cypress-mochawesome-reporter",
  "reporterOptions": {
    "reportDir": "cypress/reports",
    "charts": true,
    "overwrite": false,
    "html": false,
    "json": true,
    "reportPageTitle": "My Test Suite",
    "embeddedScreenshots": true,
    "inlineAssets": true
  },
  "experimentalRunEvents": true,
  "video": false
}

要运行 单个规范文件,您可以使用命令:

cypress run --spec "cypress/integration/examples/actions.spec.js"