首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有检测结果。Cypress无法在此文件中检测到cypress版本10.2.0的测试

没有检测结果。Cypress无法在此文件中检测到cypress版本10.2.0的测试
EN

Stack Overflow用户
提问于 2022-06-23 17:02:59
回答 2查看 659关注 0票数 2

我遵循了官方链接(“https://github.com/badeball/cypress-cucumber-preprocessor"”)中提到的使用黄瓜和柏树实现BDD框架的步骤,但是我的测试没有出现在自动窗口中,有人能帮我解决这个问题吗?自动窗口

cypress.config.js

代码语言:javascript
复制
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:

代码语言:javascript
复制
{
  "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

代码语言:javascript
复制
Feature: Web Test
Background: Background name: Navigate to webpage
Scenarios: Web Page Navigation
When navigate to a web page

步骤定义: qaweb.js

代码语言:javascript
复制
 import { When } from "@badeball/cypress-cucumber-preprocessor";
    /// <reference types="Cypress" />
    When("navigate to a web page", () => {
        cy.visit("https://www.duckduckgo.com");
      });

VS屏幕截图

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-06-26 21:28:49

在特性文件中,将Scenarios更改为Scenario

代码语言:javascript
复制
Feature: Web Test
  Background: Background name: Navigate to webpage
  Scenario: Web Page Navigation
    When navigate to a web page
票数 1
EN

Stack Overflow用户

发布于 2022-06-26 19:39:09

我在您的cypress.config.js中看到的唯一问题是setupNodeEvents的存在。这应该是函数,类似这样的东西,或者您可以删除它,如果您不需要它。

代码语言:javascript
复制
    setupNodeEvents(on, config) {
      return require('./cypress/plugins/index.js')(on, config)
    },
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72734032

复制
相关文章

相似问题

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