Некоторое время я бился головой, пытаясь понять, почему несколько определений шагов, использующих cucumber-tsflow
, не распознаются огурцом, а определения пакетов cucumber
без косточек прекрасно работают.Кто-нибудь сталкивался с этой проблемой раньше?Любая помощь будет оценена!
Моя структура репо выглядит следующим образом:
root/
- features/sample.feature
- steps/steps.ts
Внутри sample.feature, у меня есть:
Feature: Simple maths
In order to do maths
As a developer
I want to increment variables
Scenario: easy maths
Given a variable set to 1
When I increment the variable by 1
Then the variable should contain 2
Не работает Фрагмент (steps.ts):
import assert = require('assert')
import { binding, given, then, when } from 'cucumber-tsflow'
@binding()
class MySteps {
private a: number
@given('/a variable set to "([^"]*)"/')
public aVariableSetTo(searchValue: string): void {
this.a = Number(searchValue)
}
@when('/I increment the variable by "([^"]*)"/')
public incrementTheVariableBy(increment: string): void {
this.a = this.a + Number(increment)
}
@then('/the variable should contain "([^"]*)"/')
public theVariableShouldContain(expected: string): void {
assert.equal(this.a, Number(expected))
}
}
export = MySteps
Работа Фрагмент (steps.ts):
const { Given, When, Then } = require('cucumber')
var assert = require('assert')
let a
Given('a variable set to {int}', function(number) {
a = number
})
When('I increment the variable by {int}', function(number) {
a = a + number
})
Then('the variable should contain {int}', function(number) {
assert.equal(a, number)
})
Команда, использованная для запуска тестаis:
./node_modules/.bin/cucumber-js src/test/features/ --require src/test/steps/*.ts --require-module ts-node/register
Мои версии пакета:
"cucumber": "^5.0.2",
"cucumber-tsflow": "^3.1.0",
"ts-node": "^7.0.1",
"typescript": "~3.1.6"
Различные вещи, которые я пытался (и не смог) получить исправленную версию Не работает :
- Понижена версия огурца до 3.x и 4.x вместо 5.x
- Пробовал различные структуры каталогов и реорганизацию
- Пробовал несколько вариантов командной строки для огурца-js