Skip to content

Instantly share code, notes, and snippets.

@sbycrosz
Last active December 6, 2020 19:36
Show Gist options
  • Save sbycrosz/9adfd5065fa97c4802f54c9339fa5039 to your computer and use it in GitHub Desktop.
Save sbycrosz/9adfd5065fa97c4802f54c9339fa5039 to your computer and use it in GitHub Desktop.
Custom jest reporter for wix/detox that surpress printing of the entire page's UI hierarchy on failed spec
// HierarchylessDetoxReporter.js
// Custom jest reporter for wix/detox that surpress printing of the entire page's UI hierarchy on failed spec
// Github issue: https://github.com/wix/Detox/issues/992
// Usage (in your jest config): "reporters": ["./e2e/HierarchylessDetoxReporter.js"],
const StreamlineReporter = require('detox/runners/jest/streamlineReporter');
const HIERARCHY_REGEX_TRIMMER = /[\s\S]+?(?=Hierarchy)/;
class HierarchylessDetoxReporter extends StreamlineReporter {
printTestFileFailureMessage(testPath, config, result) {
if (result.failureMessage) {
const trimmedMessage = HIERARCHY_REGEX_TRIMMER.exec(result.failureMessage);
this.log(trimmedMessage);
}
super.printTestFileFailureMessage(testPath, config, { ...result, failureMessage: null });
}
}
module.exports = HierarchylessDetoxReporter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment