Skip to content

Commit

Permalink
Merge bad5aa2 into 09bef88
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHaigh committed Sep 15, 2019
2 parents 09bef88 + bad5aa2 commit 7531a3e
Show file tree
Hide file tree
Showing 34 changed files with 2,397 additions and 1,475 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ playground/
coverage/
dist/
/src/samples/sample.html

# Cucumber
features/**/*.steps.js
reports/**/*.json
reports/
reports/**/*.html
.nyc_output/
.coveralls.yml
*.tgz

e2e/reportOutput
# Transpiled E2E
e2e/**/*.js
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
node_js:
- '8.12'
script:
- npm ci
- npm run ci

after_success:
- export GIT_TAG=build-$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER
Expand Down
30 changes: 24 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
{
"workbench.colorCustomizations": {
"titleBar.activeBackground": "#38224c",
"titleBar.inactiveBackground": "#38224c99",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveForeground": "#e7e7e799"
"activityBar.background": "#52326f",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#000000",
"activityBarBadge.foreground": "#e7e7e7",
"titleBar.activeBackground": "#38224c",
"titleBar.inactiveBackground": "#38224c99",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveForeground": "#e7e7e799",
"statusBar.background": "#38224c",
"statusBarItem.hoverBackground": "#52326f",
"statusBar.foreground": "#e7e7e7"
},
"python.linting.pylintEnabled": true
}
"python.linting.pylintEnabled": true,
"cucumberautocomplete.steps": [
"e2e/step_definitions/**/*.ts"
],
"cucumberautocomplete.syncfeatures": "e2e/features/**/*.feature",
"cucumberautocomplete.strictGherkinCompletion": true,
"cucumberautocomplete.smartSnippets": true,
"cucumberautocomplete.stepsInvariants": true,
"cucumberautocomplete.onTypeFormat": true,
"cucumberautocomplete.gherkinDefinitionPart": "(Given|When|Then)\\(",
"peacock.color": "#38224c"
}
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# YACHR
[![Build Status](https://travis-ci.org/yachr/yachr.svg?branch=GH-13-CodeCoverage)](https://travis-ci.org/yachr/yachr/branches)
[![Coverage Status](https://coveralls.io/repos/github/yachr/yachr/badge.svg?branch=GH-13-CodeCoverage)](https://coveralls.io/github/yachr/yachr?branch=GH-13-CodeCoverage)
[![Build Status](https://travis-ci.org/yachr/yachr.svg?branch=GH-18-Roll-up-steps-to-scenarios-to-features)](https://travis-ci.org/yachr/yachr/branches)
[![Coverage Status](https://coveralls.io/repos/github/yachr/yachr/badge.svg?branch=GH-18-Roll-up-steps-to-scenarios-to-features)](https://coveralls.io/github/yachr/yachr?branch=GH-18-Roll-up-steps-to-scenarios-to-features)

Yet another cucumber html reporter is a simple html reporter that runs off the standard json file produced by cucumberjs.

Expand Down Expand Up @@ -91,6 +91,22 @@ From the root:

Should produced `dist/samples/report.html`

## Testing out changes to the html template
When making changes to the template its good to see those changes applied as you go.

One option to do this if you're using the templating system, is to get the unit tests to run as you make changes.

As a starting point, the 'should generate a report' test in the reporter.spec.ts will generate a basic looking report.

This can be run on its own by updating the test's `it` to use the only function:

```
it.only('should generate a report', () => {
```

Don't commit this line though!

One last step is to comment out the code that cleans up the test and removes the generated html. This should be the last line of the test, and has a helpful comment to point it out for you.
# CI
yachr is monitored by Travis-ci. when a change is detected Travis-ci will pull the repo and execute `npm run ci`. Travis will run `ci` before accepting a pull request.

Expand Down
8 changes: 8 additions & 0 deletions cucumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var common = [
'--require ./e2e/step_definitions/**/*.steps.js',
'--format json:./reports/cucumber-report.json',
].join(' ');

module.exports = {
default: common,
};
52 changes: 52 additions & 0 deletions e2e/features/abilities/user/view-report-summary.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Ability: View report summary

As a user
I would like to see the summary of features and scenarios in my project
So that I can gauge my project's health and progress.

The status of a Scenario behaves like a hierarchy that rolls up.
The scenario status will be the 'worst' status of its child steps as follows:
ambiguous, failed, undefined, pending, passed
Although a step can be skipped, a scneario cannot.

Ambiguous is the worst because it is similar to a compile erorr. There are
two or more implementations that match one step, and the test simply can't be run.

Failed is next because a step has been implemented, and failed, which is unexpected.

Undefined is then next, because no implementation has been put together.

Pending is where the implementation exists, but returns the string pending.

Finally, if all steps pass, then the scenario passes.

Scenario: All passing
Given a passing scenario
| Feature | Scenario | Step | Step Status |
| Feature One | Scenario One | Step 1 | passed |
| Feature One | Scenario One | Step 2 | passed |
| Feature One | Scenario One | Step 3 | passed |
When I run yachr against it
Then a summary showing one passing feature and one passing scenario

Scenario: Handle mixed states
Given the following scenarios
| Feature | Scenario | Step | Step Status |
| Feature One | Scenario One | Step 1 | passed |
| Feature One | Scenario One | Step 2 | ambiguous |

| Feature Two | Scenario One | Step 1 | passed |
| Feature Two | Scenario One | Step 2 | failed |

| Feature Three | Scenario One | Step 1 | passed |
| Feature Three | Scenario One | Step 2 | pending |

| Feature Four | Scenario One | Step 1 | undefined |

When I run yachr against it
Then I will see the following in the summary
| Feature | Status |
| Feature One | ambiguous |
| Feature Two | failed |
| Feature three | pending |
| Feature four | undefined |
Empty file added e2e/reportOutput/.gitkeep
Empty file.
72 changes: 72 additions & 0 deletions e2e/resources/allStatuses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[
{
"description": "Feature One",
"keyword": "Ability",
"name": "View report summary",
"id": "view-report-summary",
"tags": [],
"elements": [
{
"id": "view-report-summary;feature-summary",
"keyword": "Scenario",
"line": 7,
"name": "Feature summary",
"tags": [],
"type": "scenario",
"steps": [
{
"arguments": [],
"keyword": "Given ",
"result": {
"status": "passed",
"duration": 1000000
}
},
{
"arguments": [],
"keyword": "Then",
"result": {
"status": "ambigious",
"duration": 1000000
}
}
]
}
]
},
{
"description": "Feature Two",
"keyword": "Ability",
"name": "View report summary",
"id": "view-report-summary",
"tags": [],
"elements": [
{
"id": "view-report-summary;feature-summary",
"keyword": "Scenario",
"line": 7,
"name": "Feature summary",
"tags": [],
"type": "scenario",
"steps": [
{
"arguments": [],
"keyword": "Given ",
"result": {
"status": "passed",
"duration": 1000000
}
},
{
"arguments": [],
"keyword": "Then",
"result": {
"status": "failed",
"duration": 1000000
}
}
]
}
]
}
]
98 changes: 98 additions & 0 deletions e2e/resources/onePassingScenario.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
[
{
"description": " As a user\n I would like to see the summary of features and scenarios in my project\n So that I can gauge my project's health and progress.",
"keyword": "Ability",
"name": "View report summary",
"line": 1,
"id": "view-report-summary",
"tags": [],
"uri": "e2e\\features\\abilities\\user\\view-report-summary.feature",
"elements": [
{
"id": "view-report-summary;feature-summary",
"keyword": "Scenario",
"line": 7,
"name": "Feature summary",
"tags": [],
"type": "scenario",
"steps": [
{
"arguments": [
{
"rows": [
{
"cells": [
"Feature",
"Scenario",
"Step",
"Step Status"
]
},
{
"cells": [
"Feature One",
"Scenario One",
"Step 1",
"passed"
]
},
{
"cells": [
"Feature One",
"Scenario One",
"Step 2",
"passed"
]
},
{
"cells": [
"Feature One",
"Scenario One",
"Step 3",
"passed"
]
}
]
}
],
"keyword": "Given ",
"line": 8,
"name": "a passing step",
"match": {
"location": "e2e\\step_definitions\\view-report-summary.steps.js:4"
},
"result": {
"status": "passed",
"duration": 1000000
}
},
{
"arguments": [],
"keyword": "When ",
"line": 13,
"name": "I run yachr against it",
"match": {
"location": "e2e\\step_definitions\\view-report-summary.steps.js:7"
},
"result": {
"status": "passed",
"duration": 1000000
}
},
{
"arguments": [],
"keyword": "Then ",
"line": 14,
"name": "a summary showing one passing feature and one passing scenario",
"match": {
"location": "e2e\\step_definitions\\view-report-summary.steps.js:10"
},
"result": {
"status": "passed"
}
}
]
}
]
}
]
41 changes: 41 additions & 0 deletions e2e/step_definitions/view-report-summary.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { expect } from 'chai';
import { Given, Then, When } from 'cucumber';
import * as fs from 'fs';
import { IReportOptions } from '../../dist/src/models/reportOptions';

import { Reporter } from '../../dist/src/reporter';
import * as passingScenario from '../resources/onePassingScenario.json';

import * as cherrio from 'cheerio';
const reportLocation = 'e2e/reportOutput/report.html';
const jsonOutput = 'e2e/resources/onePassingScenario.json';

let reporter: Reporter;
let reportOptions: IReportOptions;

Given('a passing scenario', table => {
reportOptions = <IReportOptions> {
jsonFile: jsonOutput,
output: reportLocation,
};
});

Given('the following scenarios', table =>
'pending');

When('I run yachr against it', () => {
reporter = new Reporter();
reporter.generate(reportOptions);
});

Then('a summary showing one passing feature and one passing scenario', async () => {
const $ = cherrio.load(fs.readFileSync(reportLocation, 'utf8'));
const pageText = $('html').text();

// ([.\n\s]*)1/ Match all spaces and new line chars
const passedFeatures = /Ability: View report summary([.\n\s]*)done1/;
expect(passedFeatures.test(pageText)).eql(true);
});

Then('I will see the following in the summary', () =>
'pending');
18 changes: 18 additions & 0 deletions e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"lib": ["es2015"],
"target": "es5",
"moduleResolution": "node",
"strict": true,
"typeRoots": [
"/node_modules/@types"
],
"resolveJsonModule": true,
"types": [
"node", // Added to allow the use of nodes fs
],
},
"include": [
"./step_definitions/**/*.steps.ts"
],
}

0 comments on commit 7531a3e

Please sign in to comment.