Skip to content

Commit

Permalink
Merge pull request jls#44 from martineez/multiple_screenshots
Browse files Browse the repository at this point in the history
multiple screenshots fix
  • Loading branch information
jls authored May 24, 2017
2 parents 12224ea + aa81345 commit deb77c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
24 changes: 17 additions & 7 deletions lib/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ var _ = require('lodash'),
logger = require('./logger'),
getRelativePath = require('./relativePath');

function getScreenshotPath(sysout) {
return sysout[0].replace(/\n/g, '').replace('.png]]', '.png').replace('[[ATTACHMENT|', '').trim();
function getScreenshotPaths(sysout) {
var re = /\[\[ATTACHMENT\|([^\]]*)\]\]/g;
var result = [], matches = [];

while (matches = re.exec(sysout[0])) {
result.push(matches[1]);
}

return result;
}

function concatErrMessages(concatTo, errs) {
Expand Down Expand Up @@ -114,11 +121,14 @@ var normalizers = {
assert.failure = caseData.failure[0].$.message;

if (caseData['system-out']) {
var sspath = getScreenshotPath(caseData['system-out']);
if (options.relativeScreenshots) {
sspath = getRelativePath(options.fullOutputFilename, sspath);
}
assert.screenshots.push(sspath);
var sspaths = getScreenshotPaths(caseData['system-out']);

sspaths.map(function(sspath) {
if (options.relativeScreenshots) {
sspath = getRelativePath(options.fullOutputFilename, sspath);
}
assert.screenshots.push(sspath);
});
}

assert.isFailure = assert.failure;
Expand Down
2 changes: 1 addition & 1 deletion test/mockdata/parsedxmlobjs_0-6-4.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = {
}
],
'system-out': [
'[[ATTACHMENT|/Users/userOne/code/nightwatch/nightwatch-tests/tests/nightwatch/screenshots/ERROR_Mon-Apr-20-2015-175522-GMT-0400.png]]'
'[[ATTACHMENT|/Users/userOne/code/nightwatch/nightwatch-tests/tests/nightwatch/screenshots/ERROR_Mon-Apr-20-2015-175522-GMT-0400.png]][[ATTACHMENT|/Users/userOne/code/nightwatch/nightwatch-tests/tests/nightwatch/screenshots/ERROR_Mon-Apr-20-2015-175523-GMT-0400.png]]'
]
}
]
Expand Down
4 changes: 3 additions & 1 deletion test/normalize_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ exports['normalize xml object'] = {
test.equal(run.packages[1].suites[0].cases[0].message, 'Failing test Google');
test.equal(run.packages[1].suites[0].cases[0].failure,
'Timed out while waiting for element <button[name=btnGFAIL]> to be present for 1000 milliseconds.');
test.equal(run.packages[1].suites[0].cases[0].screenshots.length, 1);
test.equal(run.packages[1].suites[0].cases[0].screenshots.length, 2);

// jscs:disable
test.equal(run.packages[1].suites[0].cases[0].screenshots[0],
'/Users/userOne/code/nightwatch/nightwatch-tests/tests/nightwatch/screenshots/ERROR_Mon-Apr-20-2015-175522-GMT-0400.png');
test.equal(run.packages[1].suites[0].cases[0].screenshots[1],
'/Users/userOne/code/nightwatch/nightwatch-tests/tests/nightwatch/screenshots/ERROR_Mon-Apr-20-2015-175523-GMT-0400.png');
// jscs:enable

test.equal(run.packages[2].suites[0].cases.length, 2);
Expand Down

0 comments on commit deb77c9

Please sign in to comment.