From 5f64df60276611739160d9bbbabaa2701b46e21d Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Tue, 5 Sep 2017 12:29:08 +0100 Subject: [PATCH] Jest 21.0.0: Make message in matchers a function Jest 21.0.0 and above expect `result.message` to be a function. See Jest commit: https://github.com/facebook/jest/commit/b3d944e79699fb9a4f399b163b5f0a64cdbf44c4 --- src/toHaveStyleRule.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/toHaveStyleRule.js b/src/toHaveStyleRule.js index 7f0bec0..e3962db 100644 --- a/src/toHaveStyleRule.js +++ b/src/toHaveStyleRule.js @@ -62,7 +62,7 @@ const getDeclarations = (rules, property) => const die = (utils, property) => ({ pass: false, - message: `Property not found: ${utils.printReceived(property)}`, + message: () => `Property not found: ${utils.printReceived(property)}`, }) function toHaveStyleRule(received, property, value, options = {}) { @@ -87,7 +87,7 @@ function toHaveStyleRule(received, property, value, options = {}) { ? value.test(declaration.value) : value === declaration.value - const message = + const message = () => `Expected ${property}${pass ? ' not ' : ' '}to match:\n` + ` ${this.utils.printExpected(value)}\n` + 'Received:\n' +