首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CucumberJs :无法找到步骤定义文件

CucumberJs :无法找到步骤定义文件
EN

Stack Overflow用户
提问于 2021-01-07 09:24:36
回答 1查看 871关注 0票数 2

当我试图运行柏树时,它确实检测到了特性文件,但是无法得到步骤定义文件,下面是我要看到的错误。

在我的配置下面共享:

  1. 包json文件片段

代码语言:javascript
复制
{...
  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true,
  }
}

  1. cypress.json

代码语言:javascript
复制
{
   ...
   "testFiles": "**/*.{feature,features}"
}

  1. plugins/index.js

代码语言:javascript
复制
const cucumber = require('cypress-cucumber-preprocessor').default
 
module.exports = (on, config) => {
  on('file:preprocessor', cucumber())
}

还共享我的测试文件:

功能文件(google/check-title.feature)

代码语言:javascript
复制
Feature: The Google

  I want to open google page
  
  @focus
  Scenario: Opening a social network page
    Given I open Google page
    Then I see "Google" in the title

步骤定义文件(google/check/Chec-Title.js)

代码语言:javascript
复制
import { Given, Then } from 'cypress-cucumber-preprocessor/steps';

const url = 'https://google.com';
Given('I open Google page', () => {
  cy.visit(url);
});
Then(`I see {string} in the title`, (title) => {
  cy.title().should('include', title);
});
EN

回答 1

Stack Overflow用户

发布于 2021-12-04 00:36:29

这可能会有所帮助:在package.json中,将标志nonGlobalStepDefinitions设置为false,并定义目录测试来自:"stepDefinitions":"cypress/integration/“

代码语言:javascript
复制
{
  "devDependencies": {
    "cypress": "^9.1.0",
    "cypress-cucumber-preprocessor": "^4.3.0"
  },
  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": false,
    "stepDefinitions": "cypress/integration/"
  }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65609668

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档