src/to-have-style.js
function expectedDiff(expected, computedStyles) {
  const received = Array.from(computedStyles)
    .filter(prop => expected[prop])
    .reduce(
      (obj, prop) =>
        Object.assign(obj, {[prop]: computedStyles.getPropertyValue(prop)}),
      {},
    )
  const diffOutput = jestDiff(
    printoutStyles(expected),
    printoutStyles(received),
  )
  // Remove the "+ Received" annotation because this is a one-way diff
  return diffOutput.replace(`${chalk.red('+ Received')}\n`, '')
}
function expectedDiff(expected, computedStyles) {
  const received = Array.from(computedStyles)
    .filter(prop => expected[prop])
    .reduce(
      (obj, prop) =>
        Object.assign(obj, {[prop]: computedStyles.getPropertyValue(prop)}),
      {},
    )
  const diffOutput = jestDiff(
    printoutStyles(expected),
    printoutStyles(received),
  )
  // Remove the "+ Received" annotation because this is a one-way diff
  return diffOutput.replace(`${chalk.red('+ Received')}\n`, '')
}
function expectedDiff ( expected , computedStyles ) { const received = Array . from ( computedStyles ) . filter ( prop => expected [ prop ] ) . reduce ( ( obj , prop ) => Object . assign ( obj , { [ prop ] : computedStyles . getPropertyValue ( prop ) } ) , { } , ) const diffOutput = jestDiff ( printoutStyles ( expected ) , printoutStyles ( received ) , ) // Remove the "+ Received" annotation because this is a one-way diff return diffOutput . replace ( ` ${ chalk . red ( '+ Received' ) } \n ` , '' ) }
Highlights only style rules that were expected but were not found in the received computed styles
Highlights only style rules that were expected but were not found in the received computed styles