diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index e649170..e13d0e6 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,8 +1,8 @@ -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! + ### System Configuration #### Project Version @@ -14,5 +14,7 @@ Describe the issue as best you can. Screenshots, logs, and stack traces can be v 1. Step 2 ### Expected Outcomes + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 43d62a1..da0c078 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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. + ### Additional Details + \ No newline at end of file diff --git a/features/generate_report.feature b/features/generate_report.feature index 037ffd9..16228db 100644 --- a/features/generate_report.feature +++ b/features/generate_report.feature @@ -15,9 +15,9 @@ Feature: Report Generation Background: Given I have a dog - @feeding + @feeding @feed_dog 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 @@ -45,9 +45,9 @@ Feature: Report Generation Background: Given I have a cat - @feeding + @feeding @feed_cat 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 | @@ -117,6 +117,24 @@ Feature: Report Generation | 'feeding' | | '@feeding' | + Scenario Outline: Generating an HTML report with scenarios filtered by a tag ending with a wildcard + If the provided tag ends with a wildcard (`*`), the features and scenarios are filtered to the ones with + tags that begin with the given tag value. + + When a report is generated with the code "new Generator().generate(this.allFeaturesPath, null, )" + Then the report will contain 2 features + And the report will contain 2 scenarios + And the report name on the sidebar will be + And the sidebar will contain 2 feature buttons + And the sidebar will contain 2 scenario buttons + + Examples: + | tag: | + | '@feeding*'| + | 'feeding*' | + | 'feed_*' | + | '@feed_*' | + 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. @@ -142,7 +160,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 """ @@ -153,7 +171,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 """ @@ -163,7 +181,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 """ @@ -264,7 +282,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 """ diff --git a/package-lock.json b/package-lock.json index 0b55a12..9d57fa8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2846,6 +2846,12 @@ "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", "dev": true }, + "typescript": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz", + "integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==", + "dev": true + }, "uglify-js": { "version": "3.8.1", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.8.1.tgz", diff --git a/package.json b/package.json index 174025c..89170d3 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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": { @@ -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" } } diff --git a/src/Generator.js b/src/Generator.js index aa437f4..e6b9f89 100644 --- a/src/Generator.js +++ b/src/Generator.js @@ -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 filterScenarioByTag = (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(filterScenarioByTag); const populateHtmlIdentifiers = (feature) => { feature.featureId = idSequence;