Skip to content
Merged
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: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
coverage/
node_modules/
reports/
.DS_Store
16 changes: 14 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Multiple Cucumber HTML Reporter is a reporting module for Cucumber to parse the

> **NEW**

> Duration time can now be displayed tnx to [LennDG](https://github.com/LennDG). See [`displayDuration`](#displayDuration) for more info
> Duration time can now be displayed tnx to [LennDG](https://github.com/LennDG). See [`displayDuration`](#displayDuration) for more info


![Snapshot - Features overview](./docs/images/browsers-features-overview.jpg "Snapshot - Browsers features overview")
Expand Down Expand Up @@ -156,6 +156,19 @@ This expects the durations in the report to be in milliseconds, which might resu

> **NOTE: Only the duration of a feature can be shown in the features overview. A total duration over all features CAN NOT be given because the module doesn't know if all features have been run in parallel**

### `customStyle`
- **Type:** `path`
- **Mandatory:** No

If you need add some custom style to your report.

### `overrideStyle`
- **Type:** `path`
- **Mandatory:** No

If you need replace default style for your report.


### `metadata`
- **Type:** `JSON`
- **Mandatory:** No
Expand Down Expand Up @@ -391,4 +404,3 @@ In the search for a reporting tools for Cucumber I found a few tools that helped
- [cucumber-html-report](https://github.com/leinonen/cucumber-html-report)
- [cucumber-protractor-report](https://github.com/JesterXL/cucumber-protractor-report)
- [grunt-protractor-cucumber-html-report](https://github.com/robhil/grunt-protractor-cucumber-html-report)

45 changes: 37 additions & 8 deletions lib/generate-report.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ function generateReport(options) {

const customMetadata = options.customMetadata || false;
const customData = options.customData || null;
const style = options.overrideStyle || REPORT_STYLESHEET;
const customStyle = options.customStyle;
const disableLog = options.disableLog;
const openReportInBrowser = options.openReportInBrowser;
const reportName = options.reportName || DEFAULT_REPORTNAME;
Expand All @@ -65,6 +67,8 @@ function generateReport(options) {
app: 0,
customMetadata: customMetadata,
customData: customData,
style: style,
customStyle: customStyle,
displayDuration: displayDuration,
browser: 0,
name: '',
Expand Down Expand Up @@ -124,10 +128,10 @@ function generateReport(options) {

/* istanbul ignore else */
if (!disableLog) {
console.log(chalk.blue(`\n
console.log(chalk.blue(`\n
=====================================================================================
Multiple Cucumber HTML report generated in:

${path.join(reportPath, INDEX_HTML)}
=====================================================================================\n`));
}
Expand Down Expand Up @@ -295,22 +299,36 @@ function generateReport(options) {
if (step.embeddings !== undefined) {
const Base64 = require('js-base64').Base64;

step.attachments = [];
step.embeddings.forEach((embedding, embeddingIndex) => {
/* istanbul ignore else */
if (embedding.mime_type === 'application/json' || embedding.media && embedding.media.type === 'application/json') {
step.text = (step.text ? step.text : []).concat([JSON.parse(embedding.data)]);
} else if (embedding.mime_type === 'text/plain' || (embedding.media && embedding.media.type === 'text/plain')) {
step.text = (step.text ? step.text : []).concat([
_isBase64(embedding.data) ? Base64.decode(embedding.data)
: embedding.data]);
_isBase64(embedding.data) ? Base64.decode(embedding.data) :
embedding.data
]);
} else if (embedding.mime_type === 'image/png' || (embedding.media && embedding.media.type === 'image/png')) {
step.image = 'data:image/png;base64,' + embedding.data;
step.embeddings[embeddingIndex] = {};
} else {
let embeddingtype = "text/plain";
if ( embedding.mime_type ) {
embeddingtype = embedding.mime_type;
} else if ( embedding.media && embedding.media.type ) {
embeddingtype = embedding.media.type;
}
step.attachments.push({
data: 'data:' + embeddingtype + ';base64,' + embedding.data,
type: embeddingtype
});
step.embeddings[embeddingIndex] = {};
}
});
}

if (!step.result || (step.hidden && !step.text && !step.image)) {
if (!step.result || (step.hidden && !step.text && !step.image && _.size(step.attachments) === 0 )) {
return 0;
}

Expand Down Expand Up @@ -352,7 +370,16 @@ function generateReport(options) {
* @private
*/
function _readTemplateFile(fileName) {
return fs.readFileSync(path.join(__dirname, '..', 'templates', fileName), 'utf-8');
if (fileName) {
try {
fs.accessSync(fileName, fs.constants.R_OK);
return fs.readFileSync(fileName, 'utf-8');
} catch (err) {
return fs.readFileSync(path.join(__dirname, '..', 'templates', fileName), 'utf-8');
}
} else {
return "";
}
}

/**
Expand Down Expand Up @@ -408,7 +435,8 @@ function generateReport(options) {
suite: suite,
_: _
}),
styles: _readTemplateFile(REPORT_STYLESHEET),
customStyle: _readTemplateFile(suite.customStyle),
styles: _readTemplateFile(suite.style),
genericScript: _readTemplateFile(GENERIC_JS)
})
);
Expand Down Expand Up @@ -447,7 +475,8 @@ function generateReport(options) {
scenarios: feature.elements,
_: _
}),
styles: _readTemplateFile(REPORT_STYLESHEET),
customStyle: _readTemplateFile(suite.customStyle),
styles: _readTemplateFile(suite.style),
genericScript: _readTemplateFile(GENERIC_JS)
})
);
Expand Down
54 changes: 30 additions & 24 deletions package-lock.json

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

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"homepage": "https://github.com/wswebcreation/multiple-cucumber-html-reporter#readme",
"dependencies": {
"chalk": "1.1.3",
"find": "0.2.7",
"fs-extra": "2.1.2",
"js-base64": "2.1.9",
"jsonfile": "2.4.0",
"lodash": "4.17.4",
"find": "^0.2.9",
"fs-extra": "^5.0.0",
"js-base64": "^2.4.3",
"jsonfile": "^4.0.0",
"lodash": "^4.17.5",
"moment": "^2.20.1",
"opn": "5.0.0",
"uuid": "3.0.1"
"opn": "^5.2.0",
"uuid": "^3.2.1"
},
"devDependencies": {
"coveralls": "^2.13.1",
Expand Down
Loading