How to use the enzyme/build/Debug.typeName 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 / utils.js View on Github external
export const extractTypeName = node => {
  const type = node.type.$$typeof;

  if (type === Symbol.for('react.lazy')) {
    return 'React.Lazy';
  }

  if (type === Symbol.for('react.memo')) {
    return 'React.Memo';
  }

  if (node.type === Symbol.for('react.suspense')) {
    return 'React.Suspense';
  }

  return typeName(node);
};
github adriantoine / enzyme-to-json / src / mount.js View on Github external
if (isNil(node) || node === false) {
    return '';
  }

  if (Array.isArray(node)) {
    return node.map(child => internalNodeToJson(child, options));
  }

  if (options.mode === 'deep' && typeof node.type === 'function') {
    return internalNodeToJson(node.rendered, options);
  }

  return applyMap(
    {
      node,
      type: typeName(node),
      props: getProps(node, options),
      children: getChildren(node, options),
      $$typeof: Symbol.for('react.test.json'),
    },
    options,
  );
}