Cucumber step definitions not found using cucumber-tsflow
I have been banging my head for a while trying to figure out why a few step definitions using cucumber-tsflow aren't being recognized by cucumber, yet the bare bones cucumber package definitions work fine. Has anyone come across this issue before? Any help would be appreciated!
My repo structure is as follows:
root/
- features/sample.feature
- steps/steps.ts
Inside sample.feature, I have:
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
Not Working Snippet (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
Working Snippet (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)
})
The command I used to run the test is:
./node_modules/.bin/cucumber-js src/test/features/ --require src/test/steps/*.ts --require-module ts-node/register
My package versions are:
"cucumber": "^5.0.2",
"cucumber-tsflow": "^3.1.0",
"ts-node": "^7.0.1",
"typescript": "~3.1.6"
Various things I tried (and failed) to get the Not Working version fixed:
- Downgraded cucumber version to 3.x, and 4.x instead of 5.x
- Tried various directory structures and re-arranging
- Tried several command line variations for cucumber-js
typescript cucumber
add a comment |
I have been banging my head for a while trying to figure out why a few step definitions using cucumber-tsflow aren't being recognized by cucumber, yet the bare bones cucumber package definitions work fine. Has anyone come across this issue before? Any help would be appreciated!
My repo structure is as follows:
root/
- features/sample.feature
- steps/steps.ts
Inside sample.feature, I have:
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
Not Working Snippet (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
Working Snippet (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)
})
The command I used to run the test is:
./node_modules/.bin/cucumber-js src/test/features/ --require src/test/steps/*.ts --require-module ts-node/register
My package versions are:
"cucumber": "^5.0.2",
"cucumber-tsflow": "^3.1.0",
"ts-node": "^7.0.1",
"typescript": "~3.1.6"
Various things I tried (and failed) to get the Not Working version fixed:
- Downgraded cucumber version to 3.x, and 4.x instead of 5.x
- Tried various directory structures and re-arranging
- Tried several command line variations for cucumber-js
typescript cucumber
Resolved the original issue. For anyone that wants to use this snippet, the line@when('/I increment the variable by "([^"]*)"/')had an extra"before the$so the steps weren't being recognized... wow.
– Jack T.
Nov 22 '18 at 20:27
add a comment |
I have been banging my head for a while trying to figure out why a few step definitions using cucumber-tsflow aren't being recognized by cucumber, yet the bare bones cucumber package definitions work fine. Has anyone come across this issue before? Any help would be appreciated!
My repo structure is as follows:
root/
- features/sample.feature
- steps/steps.ts
Inside sample.feature, I have:
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
Not Working Snippet (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
Working Snippet (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)
})
The command I used to run the test is:
./node_modules/.bin/cucumber-js src/test/features/ --require src/test/steps/*.ts --require-module ts-node/register
My package versions are:
"cucumber": "^5.0.2",
"cucumber-tsflow": "^3.1.0",
"ts-node": "^7.0.1",
"typescript": "~3.1.6"
Various things I tried (and failed) to get the Not Working version fixed:
- Downgraded cucumber version to 3.x, and 4.x instead of 5.x
- Tried various directory structures and re-arranging
- Tried several command line variations for cucumber-js
typescript cucumber
I have been banging my head for a while trying to figure out why a few step definitions using cucumber-tsflow aren't being recognized by cucumber, yet the bare bones cucumber package definitions work fine. Has anyone come across this issue before? Any help would be appreciated!
My repo structure is as follows:
root/
- features/sample.feature
- steps/steps.ts
Inside sample.feature, I have:
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
Not Working Snippet (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
Working Snippet (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)
})
The command I used to run the test is:
./node_modules/.bin/cucumber-js src/test/features/ --require src/test/steps/*.ts --require-module ts-node/register
My package versions are:
"cucumber": "^5.0.2",
"cucumber-tsflow": "^3.1.0",
"ts-node": "^7.0.1",
"typescript": "~3.1.6"
Various things I tried (and failed) to get the Not Working version fixed:
- Downgraded cucumber version to 3.x, and 4.x instead of 5.x
- Tried various directory structures and re-arranging
- Tried several command line variations for cucumber-js
typescript cucumber
typescript cucumber
edited Nov 21 '18 at 20:29
Jack T.
asked Nov 21 '18 at 20:24
Jack T.Jack T.
747
747
Resolved the original issue. For anyone that wants to use this snippet, the line@when('/I increment the variable by "([^"]*)"/')had an extra"before the$so the steps weren't being recognized... wow.
– Jack T.
Nov 22 '18 at 20:27
add a comment |
Resolved the original issue. For anyone that wants to use this snippet, the line@when('/I increment the variable by "([^"]*)"/')had an extra"before the$so the steps weren't being recognized... wow.
– Jack T.
Nov 22 '18 at 20:27
Resolved the original issue. For anyone that wants to use this snippet, the line
@when('/I increment the variable by "([^"]*)"/') had an extra " before the $ so the steps weren't being recognized... wow.– Jack T.
Nov 22 '18 at 20:27
Resolved the original issue. For anyone that wants to use this snippet, the line
@when('/I increment the variable by "([^"]*)"/') had an extra " before the $ so the steps weren't being recognized... wow.– Jack T.
Nov 22 '18 at 20:27
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419968%2fcucumber-step-definitions-not-found-using-cucumber-tsflow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419968%2fcucumber-step-definitions-not-found-using-cucumber-tsflow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Resolved the original issue. For anyone that wants to use this snippet, the line
@when('/I increment the variable by "([^"]*)"/')had an extra"before the$so the steps weren't being recognized... wow.– Jack T.
Nov 22 '18 at 20:27