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
I worked around this by adding background to each feature file. This will execute before each scenario in your feature file.
Example:
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
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)
})
Cucumber Before() is a different hook, because of the capital "B".
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)
})
发布评论
评论(2)
我通过将
背景
添加到每个功能文件来解决此问题。这将在您的功能文件中的每种情况下执行。例子:
I worked around this by adding
background
to each feature file. This will execute before each scenario in your feature file.Example:
我不是Cypress-Cucumber =预处理器的专家noreferrer“> cypress-cucumber-preprocessor/features/hooks_ordering.feature 似乎有摩卡咖啡
正常用法()
Cucumber
()
是一个不同的钩子,因为资本“ b”。I'm no expert in cypress-cucumber=preprocessor, but looking at cypress-cucumber-preprocessor/features/hooks_ordering.feature there seems to be normal usage of Mocha
before()
andbeforeEach()
hooks.Cucumber
Before()
is a different hook, because of the capital "B".