当尝试在Chrome和Electron浏览器中运行我的测试时,似乎得到以下异常:
cypress-auto-framework\cypress\integration\Cucumber\EATest.feature:2
Test the EA Features
^
ParseError: Unexpected token我的功能文件用于捕获需求:
Feature: EaTestFeature
Test the EA Features
Scenario: Test the login feature
Given I visit the EA site
And I click on the login link
And I login using credentials "admin" and "Password"我的Steps文件用于将我的功能文件映射到实际操作:
import {Given, When, And, Then} from "cypress-cucumber-preprocessor/steps"
/// <reference types="Cypress" />
Given('/^I visit the EA site$/', () => {
cy.visit('http://eaapp.somee.com/')
})
And('/^I click on the login link$/', () => {
cy.contains('Login').click();
})
And('/^I login using credentials {string} and {string}$/', (userName, password) => {
cy.get('#UserName').type(userName)
cy.get('#Password').type(password)
cy.get('.btn').click();
})插件> index.js文件:
module.exports = (on, config) => {
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
on('file:preprocessor', cucumber())
}
}Package.json文件:
{
"name": "cypress-auto-framework",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"cypress": "^3.6.1",
"cypress-cucumber-preprocessor": "^1.16.2",
"cypress-dark": "^1.7.14",
"cypress-xpath": "^1.4.0"
},
"dependencies": {},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
}
}你知道问题是什么吗?
谢谢
发布于 2019-11-12 18:43:08
看起来你混合了regex步骤和纯字符串类型的占位符。
您有两种可能的选择:
使用正则表达式:And(/^I login using credentials "(.*?)" and "(.*?)"$/, ...
And('I login using credentials {string} and {string}',...的
发布于 2019-11-28 02:03:49
我猜原因是你把黄瓜插件放到了错误的index.js文件中,它应该在插件> index.js,而不是支持> index.js中
发布于 2020-01-07 07:27:51
尝试在config块之外声明cucumber常量
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
module.exports = (on, config) => {
on('file:preprocessor', cucumber())
}
}https://stackoverflow.com/questions/58801072
复制相似问题