-
Notifications
You must be signed in to change notification settings - Fork 51
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
improved collection of failed specs #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
const FAILED_LINE = /at \[object Object\]\.<anonymous> \((.*)\)/g; | ||
const FAILED_LINES = /at \[object Object\]\.<anonymous> \((.*?):.*\)/g; | ||
|
||
export default function (output = '') { | ||
// this could all probably fit into one regex... | ||
var failedSpecLines = output.match(FAILED_LINE); | ||
var output = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a need for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was actually copy&pasted from the code that npm install protractor-flake delivered. Otherwise I agree that it's not necessary. |
||
|
||
if (!failedSpecLines) { return []; } | ||
|
||
return failedSpecLines.map(function (line) { | ||
let path = line.match(/\((.*):/)[1]; | ||
return path.slice(0, [path.length - 2]); | ||
}); | ||
} | ||
var failedSpecLines = []; | ||
var match; | ||
//iterate over all matches and prevent adding a spec twice (e.g. when using multiCapabilities) | ||
while (match = FAILED_LINES.exec(output)) { | ||
if (failedSpecLines.indexOf(match[1]) == -1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an awesome improvement. I wonder if this might be a good use case for a Set which would accomplish the same thing without the need for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A Set would basically be the same, seeing how internally it also has to check for duplicates when adding a new element, but might improve code readability. |
||
failedSpecLines.push(match[1]); | ||
} | ||
} | ||
return failedSpecLines; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should define this as a non-constant within the body of the function, since
exec
modifies the state of the regex it is invoked on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.