Skip to content

Instantly share code, notes, and snippets.

@pwfcurry
Created March 29, 2019 13:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pwfcurry/43662b572dc9863b68820c6500f9c4f7 to your computer and use it in GitHub Desktop.
Hacky script to process Detox failure output
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