Last active
December 6, 2020 19:36
-
-
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
This file contains hidden or 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
// 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