How to use the enzyme-to-json.default function in enzyme-to-json

To help you get started, we’ve selected a few enzyme-to-json 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 wellguimaraes / mocha-snapshots / index.js View on Github external
function getNormalizedTarget(target) {
  if (target instanceof ShallowWrapper || target instanceof ReactWrapper)
    target = clearClassNames(toJson(target));

  target = normalize(target);

  return target;
}
github wellguimaraes / mocha-snapshots / src / getNormalizedTarget.js View on Github external
module.exports = function (value) {
  const options = getOptions()

  const isReactComponent      = value instanceof ShallowWrapper || value instanceof ReactWrapper
  const shouldClearClassNames = options.sanitizeClassNames && isReactComponent

  if (shouldClearClassNames) {
    return clearClassNames(normalize(toJson(value)))
  }

  return isReactComponent
    ? normalize(toJson(value))
    : normalize(value)
}

enzyme-to-json

convert enzyme wrapper to a format compatible with Jest snapshot

MIT
Latest version published 4 years ago

Package Health Score

77 / 100
Full package analysis