无测试 Found/Cypress 无法在此文件中检测到测试

No Test Found/Cypress could not detect test in this file

我目前正在学习 Cypress 并尝试参考尽可能多的资源。我目前也在使用 cucumber 插件,当我尝试 运行 Cypress 时,我不断收到“未找到测试”和“Cypress 无法检测到此文件中的测试”,并且除了一个右侧空白的白色屏幕。我在这里引用了另一个关于此的问题,但它正在丢失一个规范文件,这不是这里的问题。我已经根据文档导入了正确的步骤定义,但它也没有指向那个。

现在这是我的文件结构。

cypress -
    -integrations
        -BDD
           -ecommerce
              -ecommerce.spec.js
           - ecommerce.feature

在我的 cypress.json 文件中


    "testFiles":  "**/*.js",
    "baseUrl": "https://localhost:17843/GfmAdminConsole/",
    "env":{
        "url":"https://rahulshettyacademy.com"
    },
    "reporter": "mochawesome"
    
}

这是我正在尝试的代码 运行

import {Given,When,Then,And} from 'cypress-cucumber-preprocessor/steps'
import HomePage from "./HomePage"
import ProductPage from "./ProductPage"
import CheckOutPg from "./CheckOutPg"







/// <reference types="Cypress" />
Given('I open ECommerce Page',()=>{
    cy.visit("https://rahulshettyacademy.com/angularpractice/")
})


//When using hook to load data, use non-es6 syntax for a function.....might need to check if this was updated in later releases
When('I add items to Cart',function(){
    const homePage = new HomePage()
    const productPage = new ProductPage()
    homePage.getShopTab().click()
    
    
    testData.productName.forEach((product)=>{
        cy.selectProduct(product)
    })


    
    productPage.getCheckoutBtn().click()


})

And('Validate the total price of the items selected',()=>{
    let sum = 0
    let total;
    const checkOut = new CheckOutPg()
    checkOut.getItemPrices().each(($el,index,$list)=>{
        let price = $el.text().split(' ')[1].trim()
        sum = Number(sum) + Number(price);
    }).then(()=>{
        cy.log(sum)
        
    })
    checkOut.getTotal().then((el)=> {
        total =   el.text().split(' ')[1].trim()
        expect(Number(total)).to.eq(sum)
       })

})

Then('Select the country submit and verify Thank you',()=>{
    cy.get(':nth-child(6) > :nth-child(5) > .btn').click()
    cy.get('#country').type('United States')
    cy.wait(6000)
    cy.get('.suggestions > ul > li > a').click()
    cy.get('input[type="checkbox"]').check({force:true})
    cy.get('.ng-untouched > .btn').click()
    cy.get('.alert').then((el)=>{
        const text = el.text()
       expect(text.includes('Success')).to.be.true
    })
})

编辑: ecommerce.feature 文件

Feature: End to end Ecommerce validation


application Regression test
@focus
Scenario: Ecommerce products delivery

Given I open ecommerce page
When I add items to cart
And Validate the total prices
Then select the country submit and verify Thankyou

如有任何指导,我们将不胜感激,并提前致谢。

检查你的cypress.json 根据https://github.com/TheBrainFamily/cypress-cucumber-preprocessor#cypress-configuration应该有

"testFiles": "**/*.feature"