How to use the jest-matcher-utils.diff function in jest-matcher-utils

To help you get started, we’ve selected a few jest-matcher-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shopify / quilt / packages / react-testing / src / matchers / utilities.ts View on Github external
export function diffPropsForNode(
  node: Node,
  props: object,
  {expand = false},
) {
  return diff(props, getObjectSubset(node.props, props), {
    expand,
  });
}
github Shopify / quilt / packages / graphql-testing / src / matchers / utilities.ts View on Github external
export function diffVariablesForOperation(
  operation: Operation,
  variables: object,
  {expand = false},
) {
  return diff(variables, getObjectSubset(operation.variables, variables), {
    expand,
  });
}
github facebook / jest / packages / jest-circus / src / formatNodeAssertErrors.ts View on Github external
function assertionErrorMessage(
  error: AssertionErrorWithStack,
  options: DiffOptions,
) {
  const {expected, actual, generatedMessage, message, operator, stack} = error;
  const diffString = diff(expected, actual, options);
  const hasCustomMessage = !generatedMessage;
  const operatorName = getOperatorName(operator, stack);
  const trimmedStack = stack
    .replace(message, '')
    .replace(/AssertionError(.*)/g, '');

  if (operatorName === 'doesNotThrow') {
    return (
      buildHintString(assertThrowingMatcherHint(operatorName)) +
      chalk.reset(`Expected the function not to throw an error.\n`) +
      chalk.reset(`Instead, it threw:\n`) +
      `  ${printReceived(actual)}` +
      chalk.reset(hasCustomMessage ? '\n\nMessage:\n  ' + message : '') +
      trimmedStack
    );
  }