Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

feat(Generator): support simple regex for tags #66

Merged
merged 4 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 5 additions & 3 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Please fill out the below template as best you can.
--------------------------------------------------------
<!-- Please fill out the below template as best you can.
-------------------------------------------------------->

### Description of Issue
Describe the issue as best you can. Screenshots, logs, and stack traces can be very helpful!
<!-- Describe the issue as best you can. Screenshots, logs, and stack traces can be very helpful! -->

### System Configuration
#### Project Version
Expand All @@ -14,5 +14,7 @@ Describe the issue as best you can. Screenshots, logs, and stack traces can be v
1. Step 2

### Expected Outcomes
<!--
- Links can be styled as buttons
- Disabled links behave the same as disabled buttons
-->
7 changes: 5 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
### Summary
Summarize the contents of the code changes in your pull request. Tag any open issues you believe to be resolved by this pull request.
<!-- Summarize the contents of the code changes in your pull request. Tag any open issues you believe to be resolved by this pull request. -->

### Additional Details
<!--
If you have anything else that you think may be relevant to this issue, list it here. Additional information can help us better understand your changes and speed up the review process.

Please add your name to the [CONTRIBUTORS.md] file. Adding your name to the [CONTRIBUTORS.md] file signifies agreement to all rights and reservations provided by the [License].

Thanks for contributing to cucumber-forge-report-generator.
Thanks for contributing to cucumber-forge-report-generator.

[CONTRIBUTORS.md]: ../blob/main/CONTRIBUTORS.md
[License]: ../blob/main/LICENSE

-->
16 changes: 10 additions & 6 deletions features/generate_report.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Report Generation

@feeding
Scenario: Feeding the Dog
Given the dog is hungery
Given the dog is hungry
When I give dog food to the dog
Then the dog will eat it

Expand Down Expand Up @@ -47,7 +47,7 @@ Feature: Report Generation

@feeding
Scenario: Feeding the Cat
Given the cat is hungery
Given the cat is hungry
When I give the following food to the cat:
| fish |
| steak |
Expand Down Expand Up @@ -116,6 +116,10 @@ Feature: Report Generation
| tag: |
| 'feeding' |
| '@feeding' |
| '@feed*' |
| '@feeding*'|
| 'feed*' |
| 'feeding*' |

Scenario: Generating an HTML report with features filtered by a tag
The features and scenarios included in a report can be filtered based on their tags.
Expand All @@ -142,7 +146,7 @@ Feature: Report Generation

@feeding
Scenario: Feeding the Dog
Given the dog is hungery
Given the dog is hungry
When I give dog food to the dog
Then the dog will eat it
"""
Expand All @@ -153,7 +157,7 @@ Feature: Report Generation
Given there is a file named 'invalid.feature' in the 'feature/dog' directory with the following contents:
"""
Feature: Dog Care
Given the dog is hungery
Given the dog is hungry
When I give dog food to the dog
Then the dog will eat it
"""
Expand All @@ -163,7 +167,7 @@ Feature: Report Generation
Scenario: Generating a report when the directory contains a feature file that has only Cucumber steps
Given there is a file named 'invalid.feature' in the 'feature/dog' directory with the following contents:
"""
Given the dog is hungery
Given the dog is hungry
When I give dog food to the dog
Then the dog will eat it
"""
Expand Down Expand Up @@ -264,7 +268,7 @@ Feature: Report Generation
# language: american
Feature: Dog Care
Scenario: Feeding the Dog
Given the dog is hungery
Given the dog is hungry
When I give dog food to the dog
Then the dog will eat it
"""
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"main": "src/Generator.js",
"types": "types/Generator.d.ts",
"scripts": {
"test": "./node_modules/.bin/cucumber-js features/*.feature",
"lint": "npx eslint src --color",
"build:types": "npx -p typescript tsc -p tsconfig.declaration.json",
"test": "cucumber-js features/*.feature",
"lint": "eslint src --color",
"lint:fix": "eslint src --color --fix",
"build:types": "tsc -p tsconfig.declaration.json",
"prepublishOnly": "npm run build:types"
},
"repository": {
Expand All @@ -24,7 +25,9 @@
"author": "Cerner Corporation",
"license": "Apache-2.0",
"release": {
"branches": ["main"],
"branches": [
"main"
],
"repositoryUrl": "https://github.com/cerner/cucumber-forge-report-generator.git"
},
"dependencies": {
Expand All @@ -41,6 +44,7 @@
"eslint": "^7.9.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.0",
"jsdom": "^16.4.0"
"jsdom": "^16.4.0",
"typescript": "^4.1.3"
jkuester marked this conversation as resolved.
Show resolved Hide resolved
}
}
22 changes: 17 additions & 5 deletions src/Generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,24 @@ const getFeatureFromFile = (featureFilename) => {
return feature;
};

const getFilteredScenarios = (scenarios) => scenarios.map((scenario) => {
if (scenario.tags && scenario.tags.includes(tagFilter)) {
return scenario;
const filter = (scenario) => {
// empty filter: allow all
if (!tagFilter) return true;

let allow = false;
const wild = tagFilter.endsWith('*');
const strippedFilter = tagFilter.endsWith('*') ? tagFilter.slice(0, -1) : tagFilter;
if (scenario.tags) {
scenario.tags.forEach((tag) => {
if ((wild && tag.startsWith(strippedFilter)) || tag === strippedFilter) {
allow = true;
}
});
}
return undefined;
}).filter((scenario) => scenario);
return allow;
};

const getFilteredScenarios = (scenarios) => scenarios.filter(filter);

const populateHtmlIdentifiers = (feature) => {
feature.featureId = idSequence;
Expand Down