当尝试 npm install -D cypress-xpath 到已安装 cypress-cucumber-preprocessor 的 Cypress 项目 [require('cypress-xpath') 添加到我的 cypress/support/index.js] 时,我收到以下错误插件 > index.js 文件用于"/// <reference types="cypress" />"?
找不到“cypress”的类型定义文件.ts(2688)
添加到插件 > index.js 文件
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
on('file:preprocessor', cucumber())
}
Run Code Online (Sandbox Code Playgroud)
package.json 文件
"devdependencies": {
"cypress": "^8.3.1",
"cypress-cucumber-preprocessor": "^4.2.0"
},
"Dependencies": {
"cypress-xpath": "^1.6.2"
}
Run Code Online (Sandbox Code Playgroud)
支持>index.js文件
require('cypress-xpath')
Run Code Online (Sandbox Code Playgroud)
运行时:
npx cypress open
Run Code Online (Sandbox Code Playgroud)
插件文件丢失或无效。
您的pluginsFile设置为C:\Users\Delwin\VSCode\Cypress\Cucumber1\cypress\plugins\index.js,但文件丢失,包含语法错误,或者在需要时抛出错误。pluginsFile 必须是 .js、.ts 或 .coffee 文件。
或者您可能已重命名您的pluginsFile 的扩展名。如果是这种情况,请重新启动测试运行程序。
请修复此问题,或者如果您的项目不需要插件文件,请将pluginsFile 设置为 false。
错误:找不到模块“cypress-cucumber-preprocessor”
我Cypress从升级9.5.2到10.3.0,之前我使用cypress-cucumber-preprocessor:4.3.1现在我将其升级到@badeball/cypress-cucumber-preprocessor:^11.4.0。
升级之前,我使用cypress-tags命令来运行测试
npx cypress-tags run --env TAGS="@regression" --browser chrome
Run Code Online (Sandbox Code Playgroud)
但升级后它给我带来了以下错误。
npm ERR! could not determine executable to run
Run Code Online (Sandbox Code Playgroud)
请找到下面的示例功能
Feature: Login Features
@regression
Scenario: Test sample login
Given I login to the website as "testUser"
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我获得基于最新 Cypress 和 Cucumber 标签运行测试的替代选项吗?
我试图在表中找到 cy.contains() 特定文本的行。
我不能做:
cy.get("tr").contains("specific text")
Run Code Online (Sandbox Code Playgroud)
这将返回包含文本的 span 元素
我不能做
cy.get("tr").contains("specific text").parent()
Run Code Online (Sandbox Code Playgroud)
因为跨度的父级我不是我的
我不能做
cy.get("tr").contains("specific text").parentUnitl("tr")
Run Code Online (Sandbox Code Playgroud)
这不会返回该元素
我也许可以做
cy.get("tr").contains("specific text").parentUnitl("tr").parent()
Run Code Online (Sandbox Code Playgroud)
但我认为对于如此简单的事情来说,这变得非常复杂。
我错过了什么吗?
谢谢
Cypress 10 几天前发布,带来了大量重大突破性变化。作为第一次 Cypress 用户(从 Protractor 和 Cucumber 迁移),我没有意识到这一点。我正在尝试使用 Cucumber 安装 Cypress,但所有文档(也许还有cypress-cucumber-preprocessor插件本身)都是为 Cypress 9 编写/配置的。
有没有人cypress-cucumber-preprocessor在 Angular 项目中成功配置或迁移 Cypress 10,如果是,步骤是什么?
cucumber typescript angular cypress cypress-cucumber-preprocessor
我在 cypress-cucumber-preprocessor 的最新配置中遇到错误
您的 configFile 从以下位置抛出错误: ...\cypress.config.ts
执行 e2e.setupNodeEvents() 函数时抛出错误:
TypeError: (0 , cypress_esbuild_preprocessor_1.default) 不是函数...
版本:
"@badeball/cypress-cucumber-preprocessor": "^18.0.6",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
"cypress": "^13.4.0",
Run Code Online (Sandbox Code Playgroud)
这是我使用的配置,取自cypress-cucumber-preprocessor/examples/esbuild-cjs /cypress.config.js
"@badeball/cypress-cucumber-preprocessor": "^18.0.6",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
"cypress": "^13.4.0",
Run Code Online (Sandbox Code Playgroud)
配置与我使用的最后一个版本几乎相同,有以下版本:
"@badeball/cypress-cucumber-preprocessor": "^15.0.0",
"@bahmutov/cypress-esbuild-preprocessor": "^2.1.5",
"cypress": "^12.1.0",
Run Code Online (Sandbox Code Playgroud)
只是当时createEsbuildPlugin是默认导出。
我尝试了最新的默认值和命名导入,但都给出了错误。
还尝试了tsconfig.json推荐的添加(旧项目中未使用)
import { defineConfig } from "cypress";
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild";
export default defineConfig({
e2e: {
specPattern: "**/*.feature",
async setupNodeEvents(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions): Promise<Cypress.PluginConfigOptions> …Run Code Online (Sandbox Code Playgroud) 我已经安装并尝试配置 Cucumber 预处理器包,以将 Cucumber 实现到现有的 cypress 框架中。但是当我去运行我的功能文件时,我收到以下错误。有任何想法吗?
错误:无法遍历依赖关系图:无法从 C:\Source\CoreDevGit\Src 所需的“C:\Source\CoreDevGit\Src\Project\Project.Web.CypressTests\cypress\support”中找到模块“./commands” \Project\Project.Web.CypressTests\cypress\support\index.js
插件/index.js
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
require('cypress-log-to-output').install(on, (type, event)=>{
if (event.level === 'warning' || event.type === 'warning') {
return false
}
return true
})
};
module.exports = (on, config) => {
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome' && browser.isHeadless) {
launchOptions.args.push('--disable-gpu');
return launchOptions
}
});
}
const …Run Code Online (Sandbox Code Playgroud) 我正在与Angular应用程序cypress 9.3.1一起使用。@cypress/code-coverage 3.9.12cypress-cucumber-preprocessor 4.3.113.0.1
我的测试运行良好,并且还收集了代码覆盖率,但在 afterAll 挂钩中我收到错误TypeError: elm[aelFn] is not a function。我不知道它是从哪里来的。
我正在使用ngx-build-plus 13.0.1extraWebpackConf 来为 Angular 应用程序提供服务,但即使我使用“常规”,@angular-devkit/build-angular:dev-server错误消息也会出现在我的测试结束时(然后代码不会被检测)。
我的plugin/index.ts:
const browserify = require('@cypress/browserify-preprocessor');
const cucumber = require('cypress-cucumber-preprocessor').default;
const path = require('path');
export default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions): Cypress.PluginConfigOptions => {
// code coverage plugin
require('@cypress/code-coverage/task')(on, config);
// cucumber plugin
const options = {
...browserify.defaultOptions,
typescript: path.resolve('node_modules/typescript'),
};
on('file:preprocessor', cucumber(options));
return config;
};
Run Code Online (Sandbox Code Playgroud)
您可以看到下面的错误截图:
[![elm[aelFn] 不是函数1](https://i.stack.imgur.com/jS6Fn.png)
编辑:即使我删除赛普拉斯代码覆盖插件,错误仍然发生。
我正在尝试将我的测试从 Cypress 8.7.0 版本迁移到 Cypress 10.10.0 版本。安装了最新版本并进行了以下设置,但出现以下错误。使用以下版本:
Cypress 10.10.0,
"@badeball/cypress-cucumber-preprocessor": "^11.4.0",
node v18.4.0,
@bahmutov/cypress-esbuild-preprocessor": "^2.1.5"
Expected to find a global registry (this usually means you are trying to define steps or hooks in support/e2e.js, which is not supported) (this might be a bug, please report at https://github.com/badeball/cypress-cucumber-preprocessor)
Because this error occurred during a before each hook we are skipping all of the remaining tests.
Run Code Online (Sandbox Code Playgroud)
我已在 e2e.js 文件和 support/index.js 文件中添加了错误处理,但仍然无法解决此问题。我有 .env 文件,其中的环境变量位于我的根位置。有人可以就这个问题提出建议吗?
//详细错误日志:
Because this error occurred during …Run Code Online (Sandbox Code Playgroud) 我在运行一些用 Cypress 编写的自动化 e2e 测试时遇到间歇性问题。显然我是唯一遇到此问题的人,因此它可能与我的笔记本电脑无关。奇怪的是它间歇性地发生。
当我运行测试并且 cypress 尝试浏览我们的应用程序时,出现以下错误:
`CypressError cy.visit() 尝试加载失败:
http://本地主机:4200/
我们尝试向此 URL 发出 http 请求,但请求失败且没有响应。
我们在网络级别收到此错误:
错误:连接ECONNREFUSED 127.0.0.1:4200
失败的常见情况:
如果我在由 Cypress 控制的 Chrome 实例中打开一个新选项卡,我也会收到相同的错误。
如果我打开 Chrome 的标准实例(不受 Cypress 控制),页面加载正常。
真正奇怪的是,如果我在几个小时内再次尝试,我可以投入资金,它就会开始工作。
任何人对此都有任何预感,因为我一无所知或不确定如何调试。
最初,xpath 插件在我的 cypress 项目中运行良好。安装了 Typescript 插件并从 javascript 移至 Typescript。现在它开始在 xpath 上抛出错误
Property 'xpath' does not exist on type 'cy & EventEmitter'.ts(2339)
Run Code Online (Sandbox Code Playgroud)
请建议,如何在 Cypress 项目中将 xpath 与 typescript 一起使用? cypress-xpath": "^1.6.2",包含在 package.json 中
package.json文件如下:
"devDependencies": {
"@types/node": "^14.17.8",
"add": "^2.0.6",
"cypress-cucumber-preprocessor": "^4.3.0",
"cypress-mochawesome-reporter": "^2.2.0",
"cypress-xpath": "^1.6.2",
"typescript": "^4.4.3",
"yarn": "^1.22.10"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
}
Run Code Online (Sandbox Code Playgroud) cypress ×10
cypress-cucumber-preprocessor ×10
angular ×2
cucumber ×2
typescript ×2
xpath ×2
node.js ×1