Skip to content

Commit

Permalink
Jest 21.0.0: Make message in matchers a function
Browse files Browse the repository at this point in the history
Jest 21.0.0 and above expect `result.message` to be a function.

See Jest commit:
jestjs/jest@b3d944e
  • Loading branch information
myabc committed Sep 5, 2017
1 parent fa771a6 commit 5f64df6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/toHaveStyleRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) {
Expand All @@ -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' +
Expand Down

0 comments on commit 5f64df6

Please sign in to comment.