首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在柏树试验中实现BeforeAll黄瓜钩?

如何在柏树试验中实现BeforeAll黄瓜钩?
EN

Stack Overflow用户
提问于 2022-05-23 13:48:13
回答 2查看 972关注 0票数 0

我们正在使用:

代码语言:javascript
复制
"cypress": "^9.6.1",
"cypress-cucumber-preprocessor": "^4.3.1",

使用TypeScript:

代码语言:javascript
复制
"ts-node": "^10.8.0",
"tsify": "^5.0.4",
"typescript": "^4.6.4"

据我所知,柏树预处理器没有任何before挂钩,这将在整个测试套件之前进行。有什么办法实现这样的钩吗?

EN

回答 2

Stack Overflow用户

发布于 2022-05-23 14:00:17

为此,我将background添加到每个特性文件中。这将在您的特性文件中的每个场景之前执行。

示例:

代码语言:javascript
复制
Feature: Doing some this

Background: 
    Given This will run before each scenario
Scenario: 
    Given Will run after the background process
Scenario: 
    This Will also run after the background run
票数 1
EN

Stack Overflow用户

发布于 2022-05-23 21:45:01

我不是柏树专家-黄瓜=预处理器,但是看看ordering.feature,Mocha before()beforeEach()钩子的正常使用似乎是正常的。

黄瓜Before()是一个不同的钩,因为资本"B“。

代码语言:javascript
复制
    And a file named "cypress/support/step_definitions/steps.js" with:
      """
      const {
        Given,
        Before,
        After
      } = require("@badeball/cypress-cucumber-preprocessor")
      let counter;
      before(function() {
        counter = 0;
      })
      beforeEach(function() {
        expect(counter++, "Expected beforeEach() to be called after before()").to.equal(0)
      })
      Before(function() {
        expect(counter++, "Expected Before() to be called after beforeEach()").to.equal(1)
      })
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72349682

复制
相关文章

相似问题

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