From d5f18db3c3fca51e5908b683a0ce279c3c4e3893 Mon Sep 17 00:00:00 2001 From: Neil Gentleman Date: Tue, 15 Aug 2017 13:06:22 -0700 Subject: [PATCH] Jest 21 expects result.message to always be a function ref: https://github.com/facebook/jest/issues/3921 ref: https://github.com/facebook/jest/pull/3972 --- packages/jest-enzyme/src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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];