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

feat(createtestfromscenario.js): add feature to hide pending scenarios from test run #474

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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ You can follow the documentation below, or if you prefer to hack on a working ex
* [Smart tagging](#smart-tagging)
* [How to run the tests](#excluding-tests)
* [Running tagged tests](#running-tagged-tests)
* [Hiding Pending Scenarios](#hiding-pending-scenarios)
* [Ignoring specific scenarios using tags when executing test runner](#ignoring-specific-scenarios-using-tags-when-executing-test-runner)
* [Output](#output)
* [IDE support](#ide-support)
Expand Down Expand Up @@ -385,6 +386,17 @@ The trick consists in adding the "env" property with the "TAGS" subproperty in t

Then, any scenarios tagged with @ignore will be skipped when running the tests using the cypress test runner

### Hiding Pending Scenarios

By default, every defined scenario will get a test that Cypress can run,
even if the tags determine that the test should be skipped or considered "pending".
If you would like to hide those scenarios from appearing in your test run,
set the `CYPRESS_HIDE_PENDING_SCENARIOS` environment variable:

```shell
CYPRESS_HIDE_PENDING_SCENARIOS=true ./node_modules/.bin/cypress run
```

### Limiting to a subset of feature files

You can use a glob expression to select which feature files should be included.
Expand Down
6 changes: 5 additions & 1 deletion lib/createTestFromScenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const stepTest = function (state, stepDetails, exampleRowData) {
.then(() => state.onFinishStep(stepDetails, statuses.PASSED));
};

const hidePendingScenarios = function () {
return !!Cypress.env("HIDE_PENDING_SCENARIOS");
};

const runTest = (scenario, stepsToRun, rowData) => {
const indexedSteps = stepsToRun.map((step, index) => ({ ...step, index }));

Expand All @@ -58,7 +62,7 @@ const runTest = (scenario, stepsToRun, rowData) => {
)
.then(() => state.onFinishScenario(scenario));
});
} else {
} else if (!hidePendingScenarios()) {
// eslint-disable-next-line func-names,prefer-arrow-callback
it(scenario.name, function () {
// register this scenario with the cucumber data collector
Expand Down