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

Fix for screenshot attachments & sanitized hyperlinks with plain text title #95

Merged
merged 7 commits into from
Jul 10, 2017
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
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,23 @@ Pass the _Key-Value_ pair as per your need, as shown in below example,

Capture and Attach screenshots to the Cucumber Scenario and HTML report will render the screenshot image

**for Cucumber V1**
```javascript

driver.takeScreenshot().then(function (buffer) {
return scenario.attach(new Buffer(buffer, 'base64'), 'image/png');
}
};

```

**for Cucumber V2**
```javascript

var world = this;

driver.takeScreenshot().then(function (buffer) {
return world.attach(buffer, 'image/png');
};

```

Expand Down
7 changes: 5 additions & 2 deletions lib/hierarchyReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ var findOrCreateSubSuite = function (suite, hierarchy) {
*/
function newSubSuite(name, parent) {
return {
name: name,
name: {
plain: name,
sanitized: name
},
passed: 0,
failed: 0,
ambiguous: 0,
Expand All @@ -89,7 +92,7 @@ var findOrCreateSubSuite = function (suite, hierarchy) {
suite.suites = [];
}
var subSuite = suite.suites.find(function (s) {
return s.name === subSuiteName;
return s.name.plain === subSuiteName;
});
if (!subSuite) {
subSuite = newSubSuite(subSuiteName, suite);
Expand Down
6 changes: 4 additions & 2 deletions lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ var generateReport = function (options) {
};

var suite = {
name: sanitize(options.name || packageJson && packageJson.name, /[^a-z|0-9]/g),
name: {
plain: options.name || packageJson && packageJson.name,
sanitized: sanitize(options.name || packageJson && packageJson.name, /[^a-z|0-9]/g)
},
brandTitle: options.brandTitle,
version: packageJson && packageJson.version,
time: new Date(),
Expand Down Expand Up @@ -236,7 +239,6 @@ var generateReport = function (options) {
name = name + '_' + Math.round(Math.random() * 10000) + '.png'; //randomize the file name
var filename = path.join(screenshotsDirectory, name);
fs.writeFileSync(filename, embedding.data, 'base64');
step.image = filename;
}
}
});
Expand Down
Loading