Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make strict the default #699

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cucumber.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var common = [
'--compiler js:babel-register',
'--strict',
'--format progress',
'--format rerun:@rerun.txt'
].join(' ')
Expand Down
8 changes: 4 additions & 4 deletions features/core.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature: Core feature elements execution
};
module.exports = cucumberSteps;
"""
When I run cucumber-js with `--strict`
When I run cucumber-js
Then it passes

Scenario: Given, When, Then, And and But steps
Expand Down Expand Up @@ -51,7 +51,7 @@ Feature: Core feature elements execution
};
module.exports = cucumberSteps;
"""
When I run cucumber-js with `--strict`
When I run cucumber-js
Then it passes

Scenario: Step definition body is executed
Expand Down Expand Up @@ -87,7 +87,7 @@ Feature: Core feature elements execution
};
module.exports = cucumberSteps;
"""
When I run cucumber-js with `--strict`
When I run cucumber-js
Then it passes

Scenario: Steps accepting parameters
Expand Down Expand Up @@ -129,5 +129,5 @@ Feature: Core feature elements execution
};
module.exports = cucumberSteps;
"""
When I run cucumber-js with `--strict`
When I run cucumber-js
Then it passes
2 changes: 1 addition & 1 deletion features/custom_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Feature: custom formatter
a feature / a scenario
Given an undefined step - undefined

SUCCESS
FAILURE
"""

Scenario: extending SummaryFormatter
Expand Down
8 changes: 4 additions & 4 deletions features/data_tables.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: Data Tables

module.exports = stepDefinitions
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then it passes

Scenario: rows
Expand Down Expand Up @@ -56,7 +56,7 @@ Feature: Data Tables

module.exports = stepDefinitions
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then it passes

Scenario: rowsHash
Expand Down Expand Up @@ -84,7 +84,7 @@ Feature: Data Tables

module.exports = stepDefinitions
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then it passes

Scenario: hashes
Expand Down Expand Up @@ -115,5 +115,5 @@ Feature: Data Tables

module.exports = stepDefinitions
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then it passes
4 changes: 2 additions & 2 deletions features/doc_string.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: doc string
};
module.exports = cucumberSteps;
"""
When I run cucumber-js with `--strict`
When I run cucumber-js
Then it passes

Scenario: with other step definition arguments
Expand All @@ -48,5 +48,5 @@ Feature: doc string
};
module.exports = cucumberSteps;
"""
When I run cucumber-js with `--strict`
When I run cucumber-js
Then it passes
2 changes: 1 addition & 1 deletion features/fake_time.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ Feature: Allow time to be faked by utilities such as sinon.useFakeTimers

module.exports = stepDefinitions
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then it passes
4 changes: 2 additions & 2 deletions features/generator_step_definitions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Feature: Generator Step Definitions
"""

Scenario: without generator function runner
When I run cucumber-js with `--strict`
When I run cucumber-js
Then the exit status should be 1
And the error output contains the text:
"""
Expand All @@ -60,5 +60,5 @@ Feature: Generator Step Definitions
});
};
"""
When I run cucumber-js with `--strict`
When I run cucumber-js
Then the exit status should be 0
6 changes: 3 additions & 3 deletions features/hook_timeouts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Feature: Step definition timeouts
Scenario:
Given a passing step
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then the output contains the text:
"""
function timed out after 500 milliseconds
Expand All @@ -42,7 +42,7 @@ Feature: Step definition timeouts
Scenario:
Given a passing step
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then the exit status should be 0


Expand All @@ -55,7 +55,7 @@ Feature: Step definition timeouts
Scenario:
Given a passing step
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then the output contains the text:
"""
function timed out after 500 milliseconds
Expand Down
2 changes: 1 addition & 1 deletion features/nested_features.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Feature: Automatically required support files for nested features
};
module.exports = cucumberSteps;
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then the exit status should be 0
4 changes: 2 additions & 2 deletions features/register_handler_timeouts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: registerHandler timeouts
});
};
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then the error output contains the text:
"""
features/supports/handlers.js:4 function timed out after 500 milliseconds
Expand All @@ -44,5 +44,5 @@ Feature: registerHandler timeouts
});
};
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then the exit status should be 0
6 changes: 3 additions & 3 deletions features/step_definition_timeouts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Feature: Step definition timeouts
Scenario:
When a <TYPE> step runs slowly
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then the output contains the text:
"""
function timed out after 500 milliseconds
Expand All @@ -51,7 +51,7 @@ Feature: Step definition timeouts
Scenario:
When a <TYPE> step runs slowly with an increased timeout
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then the exit status should be 0

Examples:
Expand All @@ -68,7 +68,7 @@ Feature: Step definition timeouts
When a <TYPE> step runs slowly with an increased timeout
And a <TYPE> step runs slowly
"""
When I run cucumber.js with `--strict`
When I run cucumber.js
Then the output contains the text:
"""
function timed out after 500 milliseconds
Expand Down
28 changes: 16 additions & 12 deletions features/strict_mode.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Strict mode

Using the `--strict` flag will cause cucumber to fail unless all the
step definitions have been defined.
Using the `--no-strict` flag will cause cucumber to succeed even if there are
undefined or pending steps.

Background:
Given a file named "features/a.feature" with:
Expand All @@ -11,28 +11,32 @@ Feature: Strict mode
Given a step
"""

Scenario: Succeed scenario with implemented step with --strict
Scenario: Fail with undefined step by default
When I run cucumber.js
Then the exit status should be 1

Scenario: Succeed with undefined step with --no-strict
When I run cucumber.js with `--no-strict`
Then the exit status should be 0

Scenario: Fail with pending step by default
Given a file named "features/step_definitions/cucumber_steps.js" with:
"""
var cucumberSteps = function() {
this.Given(/^a step$/, function() {});
this.Given(/^a step$/, function() { return 'pending'; });
};
module.exports = cucumberSteps;
"""
When I run cucumber.js with `--strict`
Then the exit status should be 0

Scenario: Fail scenario with undefined step with --strict
When I run cucumber.js with `--strict`
When I run cucumber.js
Then the exit status should be 1

Scenario: Fail Scenario with pending step with --strict
Scenario: Succeed with pending step with --no-strict
Given a file named "features/step_definitions/cucumber_steps.js" with:
"""
var cucumberSteps = function() {
this.Given(/^a step$/, function() { return 'pending'; });
};
module.exports = cucumberSteps;
"""
When I run cucumber.js with `--strict`
Then the exit status should be 1
When I run cucumber.js with `--no-strict`
Then the exit status should be 0
2 changes: 1 addition & 1 deletion src/cli/argv_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export default class ArgvParser {
.option('-f, --format <TYPE[:PATH]>', 'specify the output format, optionally supply PATH to redirect formatter output (repeatable)', ArgvParser.collect, [])
.option('--format-options <JSON>', 'provide options for formatters (repeatable)', ArgvParser.mergeJson('--format-options'), {})
.option('--name <REGEXP>', 'only execute the scenarios with name matching the expression (repeatable)', ArgvParser.collect, [])
.option('--no-strict', 'succeed even if there are pending or undefined steps')
.option('-p, --profile <NAME>', 'specify the profile to use (repeatable)', ArgvParser.collect, [])
.option('-r, --require <FILE|DIR>', 'require files before executing features (repeatable)', ArgvParser.collect, [])
.option('-S, --strict', 'fail if there are any undefined or pending steps')
.option('-t, --tags <EXPRESSION>', 'only execute the features or scenarios with tags matching the expression', '')
.option('--world-parameters <JSON>', 'provide parameters that will be passed to the world constructor (repeatable)', ArgvParser.mergeJson('--world-parameters'), {})

Expand Down
2 changes: 1 addition & 1 deletion src/cli/configuration_builder_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Configuration', function() {
dryRun: false,
failFast: false,
filterStacktraces: true,
strict: false,
strict: true,
worldParameters: {}
},
scenarioFilterOptions: {
Expand Down