Background
In my TypeScript project, I am utilizing https://github.com/cucumber/cucumber-js. The code snippet below showcases a typical cucumber implementation:
import {
Given,
Then,
When
} from 'cucumber'
Given(`Page is up and running`, function(this: World) {
someFunction()
})
Objective
My goal is to find a way to enhance the functionality of the Given
function. Specifically, I want to:
- Execute a pre-defined action before the code inside
Given
runs. For instance, I would like to print out the first argument in theGiven
statement (e.g.,Page is up and running
). - Avoid making changes to the existing step implementations.
Within the index.d.ts
file, each step has two alias function definitions, as shown below:
export function Given(pattern: RegExp | string, code: StepDefinitionCode): void;
export function Given(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void;