我遵循了官方链接(“https://github.com/badeball/cypress-cucumber-preprocessor"”)中提到的使用黄瓜和柏树实现BDD框架的步骤,但是我的测试没有出现在自动窗口中,有人能帮我解决这个问题吗?自动窗口
cypress.config.js
const { defineConfig } = require("cypress");
const webpack = require("@cypress/webpack-preprocessor");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
async function setupNodeEvents(on, config) {
await preprocessor.addCucumberPreprocessorPlugin(on, config);
on(
"file:preprocessor",
webpack({
webpackOptions: {
resolve: {
extensions: [".ts", ".js"],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: "ts-loader",
},
],
},
{
test: /\.feature$/,
use: [
{
loader: "@badeball/cypress-cucumber-preprocessor/webpack",
options: config,
},
],
},
],
},
},
})
);
// Make sure to return the config object as it might have been modified by the plugin.
return config;
}
module.exports = defineConfig({
e2e: {
specPattern: "**/*.feature",
supportFile: false,
setupNodeEvents,
},
});package.json:
{
"name": "cypressjs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Aninda Mondal",
"license": "ISC",
"devDependencies": {
},
"dependencies": {
"@badeball/cypress-cucumber-preprocessor": "^11.2.0-rc1",
"@cypress/webpack-preprocessor": "^5.12.0",
"cypress": "^10.2.0"
},
"cypress-cucumber-preprocessor": {
"json": {
"enabled": true
}
},
"stepDefinitions": [
"**/cypress/e2e/**/*.{js,ts}",
"**/cypress/e2e/.{js,ts}",
"**/cypress/support/step_definitions/**/*.{js,ts}"
]
}特征文件: qaweb.feature
Feature: Web Test
Background: Background name: Navigate to webpage
Scenarios: Web Page Navigation
When navigate to a web page步骤定义: qaweb.js
import { When } from "@badeball/cypress-cucumber-preprocessor";
/// <reference types="Cypress" />
When("navigate to a web page", () => {
cy.visit("https://www.duckduckgo.com");
});发布于 2022-06-26 21:28:49
在特性文件中,将Scenarios更改为Scenario
Feature: Web Test
Background: Background name: Navigate to webpage
Scenario: Web Page Navigation
When navigate to a web page发布于 2022-06-26 19:39:09
我在您的cypress.config.js中看到的唯一问题是setupNodeEvents的存在。这应该是函数,类似这样的东西,或者您可以删除它,如果您不需要它。
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},https://stackoverflow.com/questions/72734032
复制相似问题