diff --git a/packages/jest-enzyme/src/index.js b/packages/jest-enzyme/src/index.js index 9f228e4..deb5b5f 100644 --- a/packages/jest-enzyme/src/index.js +++ b/packages/jest-enzyme/src/index.js @@ -25,22 +25,22 @@ beforeEach(() => { [matcherKey](wrapper, ...args) { const result = enzymeMatchers[matcherKey].call(this, wrapper, ...args); - if (this.isNot) { - result.message = result.negatedMessage; - } + let message = this.isNot ? result.negatedMessage : result.message; if (result.contextualInformation.expected) { - result.message += `\n${this.utils.RECEIVED_COLOR( + message += `\n${this.utils.RECEIVED_COLOR( result.contextualInformation.expected )}`; } if (result.contextualInformation.actual) { - result.message += `\n${this.utils.EXPECTED_COLOR( + message += `\n${this.utils.EXPECTED_COLOR( result.contextualInformation.actual )}`; } + result.message = () => message; + return result; }, }[matcherKey];