Created
March 29, 2019 13:10
Star
You must be signed in to star a gist
Hacky script to process Detox failure output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (process.argv.length !== 3) { | |
console.error("Expects exactly one argument"); | |
return; | |
} | |
const path = process.argv[2]; | |
console.log(path + "\n"); | |
const lineReader = require('readline').createInterface({ | |
input: require('fs').createReadStream(path) | |
}); | |
lineReader.on('line', function (line) { | |
const prefix = line.substr(0, line.indexOf("<")); // indentation | |
if (!prefix) return; | |
const element = line.substr(line.indexOf("<") + 1, line.indexOf(":") - line.indexOf("<") - 1); // e.g., RCTView | |
const label = getAttributeValue(line, "AX.label"); // text, if available | |
const id = getAttributeValue(line, "AX.id"); // testID prop, if provided | |
console.log(`${prefix} <${element}> \t\t ${label ? label : ""} ${id ? `[ID=${id}]` : ""}`); | |
}); | |
const getAttributeValue = (line, attr) => { | |
// attr='value' ---> returns value | |
const index = line.indexOf(attr + "='"); | |
if (index === -1) return ""; | |
const l = line.substr(index + attr.length + 2); | |
return l.substr(0, l.indexOf("'")); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment