首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用TypeScript和Cypress 10+安装和配置@badeball/Cypress-黄瓜预处理程序的正确方法

使用TypeScript和Cypress 10+安装和配置@badeball/Cypress-黄瓜预处理程序的正确方法
EN

Stack Overflow用户
提问于 2022-11-18 16:27:47
回答 2查看 67关注 0票数 0

我正试图用TypeScript实现Cypress 11的柏树预处理器,但我不确定我错过了什么。以下是我所做的步骤:

  1. 使用以下命令安装它:

npm install @badeball/cypress-黄瓜-预处理器

  1. 这是我的问题。我不知道如何在"cypress.config.ts“文件中实现插件。问题是,我仍然在使用‘require('./cypress/ plugins /index.js')(on,config)的旧实现插件的解决方案。有办法同时使用这两种实现(一种用于调用“index.js”文件,另一种用于添加柏树-黄瓜-预处理器插件)?我不知道该如何处理。
代码语言:javascript
运行
复制
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";

export default defineConfig({
  projectId: '7emkc5',
  reporter: 'mochawesome',
  reporterOptions: {
    reportDir: 'cypress/report/mochawesome-report',
    overwrite: false,
    html: true,
    json: true,
    timestamp: 'dd-mm-yyyy_HH-MM-ss',
  },
  chromeWebSecurity: false,
  e2e: {
    // We've imported your old cypress plugins here.
    // You may want to clean this up later by importing these.
    setupNodeEvents(on, config) {
      return require('./cypress/plugins/index.js')(on, config)
    },
    specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
  },
})

I am using the last version of Cypress 11.1.0 and typescript.
EN

回答 2

Stack Overflow用户

发布于 2022-11-18 22:20:09

只需按照指南安装TS https://docs.cypress.io/guides/tooling/typescript-support#Install-TypeScript即可

然后,将此https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/quick-start.md粘贴到cypress.config.ts中。

还安装bahmutov lib:

代码语言:javascript
运行
复制
npm i @bahmutov/cypress-esbuild-preprocessor    

这对我有用..。祝好运!

票数 2
EN

Stack Overflow用户

发布于 2022-11-19 17:35:35

下面是使用10+向Cypress TypeScript添加插件的干净流程:

  1. 安装NodeJS (Cypress支持的版本)。
  2. 安装柏树。
  3. 安装/添加TypeScript对柏树的支持
  4. @bahmutov/cypress-esbuild-预处理器插件添加到项目中。
  5. @badeball/cypress-黄瓜-预处理器插件添加到项目中。
  6. 将eX-样设置添加到cypress.config.ts类。

然而,现在我有了一个不同的问题。我似乎无法在“setupNodeEvents”方法中添加一些插件。我问了一个新问题,这里

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74492646

复制
相关文章

相似问题

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