首页 > 解决方案 > 连接两个测试框架的 cypress-cucumber-preprocessor 不起作用

问题描述

我想连接 Cypress 和 Cucumber,我发现了以下插件:https ://www.npmjs.com/package/cypress-cucumber-preprocessor

但是我的实现不起作用并且找不到。我还将插件添加到plugins/index.js文件夹中。

cypess/integration/test.feature

Feature: Background Section

   Background:
    Given counter has been reset

   Scenario: Basic example #1
     When counter is incremented
     Then counter equals 1

   Scenario: Basic example #2
     When counter is incremented
     When counter is incremented
     Then counter equals 2

cypess/集成/test.js

let counter = 0;

Given("counter has been reset", () => {
  counter = 0;
});

When("counter is incremented", () => {
  counter += 1;
});

Then("counter equals {int}", value => {
  expect(counter).to.equal(value);
});

cypess/插件/index.js

// Cucumber Plugin
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
  on('file:preprocessor', cucumber())
}

错误

在此处输入图像描述

标签: javascriptangulartypescriptcucumbercypress

解决方案


如果要自定义它,则必须配置 step_definitions 的路径。

但是,如果您更喜欢简单的方法,默认情况下 cypress-cucumber-preprocessor 使用文件夹cypress/support/step_definitions

所以我相信如果你把你的 test.js 文件移动到上面描述的文件夹中,将会解决你的问题。


推荐阅读