How to use the enzyme/build/RSTTraversal.propsOfNode function in enzyme

To help you get started, we’ve selected a few enzyme 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 adriantoine / enzyme-to-json / src / shallow.js View on Github external
function getProps(node, options) {
  const props = omitBy(Object.assign({}, propsOfNode(node)), (val, key) => {
    if (key === 'children' || val === undefined) {
      return true;
    }

    if (
      options.ignoreDefaultProps === true &&
      typeof node.type === 'function' &&
      node.type.defaultProps &&
      key in node.type.defaultProps &&
      node.type.defaultProps[key] === val
    ) {
      return true;
    }
  });

  if (!isNil(node.key) && options.noKey !== true) {
github adriantoine / enzyme-to-json / src / mount.js View on Github external
function getProps(node, options) {
  const props = omitBy(
    {
      ...propsOfNode(node),
    },
    (val, key) => {
      return key === 'children' || val === undefined;
    },
  );

  if (!isNil(node.key) && options.noKey !== true) {
    props.key = node.key;
  }

  return props;
}