当我尝试运行 cypress 时,它确实检测到了功能文件,但无法获取步骤定义文件,下面是我看到的错误。
在我的配置下分享:
- 打包 json 文件片段
{...
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true,
}
}
- 柏树.json
{
...
"testFiles": "**/*.{feature,features}"
}
- 插件/index.js
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
on('file:preprocessor', cucumber())
}
还分享我的测试文件:
功能文件(google/check-title.feature)
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-title/check-title.js)
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);
});