How to use the jest-matcher-utils.matcherHint 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
matcherErrorMessage(
        matcherHint(`.${expectation}`, undefined, undefined, {isNot}),
        `${receivedColor(
          'received',
        )} value must be an @shopify/react-testing Root or Element object`,
        `Received an ${receivedColor(
          'array of Root or Element objects',
        )}.\nThis usually means that you passed in the result of \`.findAllX\`. Pass the result of \`.findX\` instead.`,
      ),
    );
  }

  if (!(node instanceof Root) && !(node instanceof Element)) {
    throw new Error(
      matcherErrorMessage(
        matcherHint(`.${expectation}`, undefined, undefined, {isNot}),
        `${receivedColor(
          'received',
        )} value must be an @shopify/react-testing Root or Element object`,
        printWithType('Received', node, printReceived),
      ),
    );
  }
}
github Shopify / quilt / packages / react-testing / src / matchers / context.ts View on Github external
? () =>
        `${matcherHint('.not.toProvideReactContext')}\n\n` +
        `Expected the React element:\n  ${receivedColor(node.toString())}\n` +
        `Not to contain context provider:\n  ${expectedColor(
          printType(Context.Provider),
        )}\n${
          value ? `With value matching:\n  ${printExpected(value)}\n` : ''
        }` +
        `But ${foundByValue.length} matching ${printType(Context.Provider)}${
          foundByValue.length === 1 ? 's were' : ' was'
        } found.\n`
    : () =>
github ifiokjr / remirror / @remirror / core / src / __tests__ / test-utils.tsx View on Github external
) => () =>
  matcherHint('.not.transformsNode') + '\n\n' + shouldChange
    ? chalk`Expected the node {bold not} to be:\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 to be different from:\n' +
      `${printExpected(expected.toString())}\n\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 Shopify / quilt / packages / react-testing / src / matchers / props.ts View on Github external
: () => {
        const diffString = diffPropsForNode(node, props, {
          expand: this.expand,
        });

        return (
          `${matcherHint('.toHaveReactProps', node.toString())}\n\n` +
          `Expected the React element:\n  ${receivedColor(node.toString())}\n` +
          `To have props:\n  ${printExpected(props)}\n` +
          `Received:\n  ${printReceived(node.props)}\n${
            diffString ? `Difference:\n${diffString}\n` : ''
          }`
        );
      };
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)}`;
github jest-community / jest-extended / src / matchers / toContainAnyEntries / index.js View on Github external
const failMessage = (object, entries) => () =>
  matcherHint('.toContainAnyEntries') +
  '\n\n' +
  'Expected object to contain any of the provided entries:\n' +
  `  ${printExpected(entries)}\n` +
  'Received:\n' +
  `  ${printReceived(object)}`;
github jest-community / jest-extended / src / matchers / toHaveBeenCalledBefore / index.js View on Github external
const failMessage = (firstInvocationCallOrder, secondInvocationCallOrder) => () =>
  matcherHint('.toHaveBeenCalledBefore') +
  '\n\n' +
  'Expected first mock to have been called before, invocationCallOrder:\n' +
  `  ${printExpected(firstInvocationCallOrder)}\n` +
  'Received second mock with invocationCallOrder:\n' +
  `  ${printReceived(secondInvocationCallOrder)}`;
github lerna / lerna / helpers / figgy-pudding-matchers / index.js View on Github external
message: () =>
      `${matcherHint(".toBeFiggyPudding", "received", "", {
        isNot: this.isNot,
      })}\n\nReceived: ${printReceived(received)}`,
  };
github jest-community / jest-extended / src / matchers / toBeNaN / index.js View on Github external
const passMessage = received => () =>
  matcherHint('.not.toBeNaN', 'received', '') +
  '\n\n' +
  'Expected value to be a number received:\n' +
  `  ${printReceived(received)}`;
github jest-community / jest-extended / src / matchers / toBeNaN / index.js View on Github external
const failMessage = received => () =>
  matcherHint('.toBeNaN', 'received', '') +
  '\n\n' +
  'Expected value to not be a number received:\n' +
  `  ${printReceived(received)}`;