How to use the jest-matcher-utils.printExpected 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 testing-library / react-testing-library / src / jest-extensions.js View on Github external
const assertMessage = (assertionName, message, received, expected) =>
  `${matcherHint(`${assertionName}`, 'received', '')} \n${message}: ` +
  `${printExpected(expected)} \nReceived: ${printReceived(received)}`
github Shopify / quilt / packages / react-testing / src / matchers / props.ts View on Github external
? () =>
        `${matcherHint('.not.toHaveReactProps', node.toString())}\n\n` +
        `Expected the React element:\n  ${receivedColor(node.toString())}\n` +
        `Not to have props:\n  ${printExpected(props)}\n` +
        `Received:\n  ${printReceived(node.props)}\n`
    : () => {
github Shopify / quilt / packages / graphql-testing / src / matchers / operations.ts View on Github external
? () =>
        `${matcherHint('.not.toHavePerformedGraphQLOperation')}\n\n` +
        `Expected not to have performed GraphQL ${type}:\n  ${expectedColor(
          name,
        )}\n${
          variables
            ? `With variables matching:\n  ${printExpected(variables)}\n`
            : ''
        }` +
        `But ${foundByVariables.length} matching ${
          foundByVariables.length === 1 ? 'operation was' : 'operations were'
        } found.\n`
    : () =>
github testing-library / jest-dom / src / to-have-focus.js View on Github external
message: () => {
      return [
        matcherHint(`${this.isNot ? '.not' : ''}.toHaveFocus`, 'element', ''),
        '',
        'Expected',
        `  ${printExpected(element)}`,
        'Received:',
        `  ${printReceived(element.ownerDocument.activeElement)}`,
      ].join('\n')
    },
  }
github ifiokjr / remirror / packages / jest-prosemirror / src / jest-prosemirror-messages.ts View on Github external
) => () =>
  `${matcherHint('.toTransformNode')}\n\n${shouldChange}`
    ? 'Expected the node to be transformed to:\n' +
      `${printExpected(expected.toString())}\n` +
      `Position: { from: ${selectionFor(expected).from}, to: ${selectionFor(expected).to} }\n\n` +
      'Received:\n' +
      `${printReceived(actual.toString())}\n` +
      `Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`
    : 'Expected the node not to be changed from:\n' +
      `${printExpected(expected.toString())}\n` +
      `Position: { from: ${selectionFor(expected).from} to: ${selectionFor(expected).to} }\n\n` +
      'Received:\n' +
      `${printReceived(actual.toString())}\n` +
      `Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`;
github JamieMason / expect-more / packages / expect-more-jest / src / lib / create-result.ts View on Github external
message: () =>
      message(
        matcherHint(`.${matcherName}`, `Function ${fn.name}`),
        printExpected(result.permutation),
        chalk.red(result.error.stack)
      ),
    notMessage: () =>
github Dean177 / jest-to-match-shape-of / src / toBeTypeOf.ts View on Github external
message: () => pass ? '' :
      `${matcherHint('.toBeTypeOf')}\n` +
      `\n` +
      `Received:\n` +
      `  ${printReceived(getType(received))}\n` +
      `Expected:\n` +
      `  ${printExpected(getType(expected))}\n` +
      `For value:\n` +
      JSON.stringify(received, null, 2),
    pass,
github Shopify / quilt / packages / ast-utilities / src / matchers.ts View on Github external
: () =>
        `${matcherHint('.toBeFormated', formatedReceived)}\n\n` +
        `Expected:\n  ${receivedColor(formatedReceived)}\n` +
        `To be equal to:\n  ${printExpected(formatedExpected)}\n`;
github facebook / jest / packages / jest-circus / src / formatNodeAssertErrors.ts View on Github external
trimmedStack
    );
  }

  if (operatorName === 'fail') {
    return (
      buildHintString(assertMatcherHint(operator, operatorName, expected)) +
      chalk.reset(hasCustomMessage ? 'Message:\n  ' + message : '') +
      trimmedStack
    );
  }

  return (
    buildHintString(assertMatcherHint(operator, operatorName, expected)) +
    chalk.reset(`Expected value ${operatorMessage(operator)}`) +
    `  ${printExpected(expected)}\n` +
    chalk.reset(`Received:\n`) +
    `  ${printReceived(actual)}` +
    chalk.reset(hasCustomMessage ? '\n\nMessage:\n  ' + message : '') +
    (diffString ? `\n\nDifference:\n\n${diffString}` : '') +
    trimmedStack
  );
}
github jest-community / jest-extended / src / matchers / toContainAnyEntries / index.js View on Github external
const passMessage = (object, entries) => () =>
  matcherHint('.not.toContainAnyEntries') +
  '\n\n' +
  'Expected object to not contain any of the provided entries:\n' +
  `  ${printExpected(entries)}\n` +
  'Received:\n' +
  `  ${printReceived(object)}`;