How to use the pretty-format function in pretty-format

To help you get started, we’ve selected a few pretty-format 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 / dom-testing-library / src / pretty-dom.js View on Github external
}

  let domTypeName = typeof dom
  if (domTypeName === 'object') {
    domTypeName = dom.constructor.name
  } else {
    // To don't fall with `in` operator
    dom = {}
  }
  if (!('outerHTML' in dom)) {
    throw new TypeError(
      `Expected an element or document but got ${domTypeName}`,
    )
  }

  const debugContent = prettyFormat(dom, {
    plugins: [DOMElement, DOMCollection],
    printFunctionName: false,
    highlight: inNode(),
    ...options,
  })
  return maxLength !== undefined && dom.outerHTML.length > maxLength
    ? `${debugContent.slice(0, maxLength)}...`
    : debugContent
}
github borela-tech / js-toolbox / src / configs / webpack / plugins / Html / index.js View on Github external
this._template,
    )

    // Add companion chunks to the end of the body.
    for (let chunk of CHUNKS) {
      appendChild(BODY, createTagNode({
        tagName: 'script',
        attrs: [{
          name: 'src',
          value: `${chunk.id}.js?${chunk.hash}`,
        }],
      }))
    }

    if (this._hot) {
      log(`Injecting hot listener: ${prettyFormat(TEMPLATE_PATH)}`)

      appendChild(BODY, createTagNode({
        tagName: 'script',
        attrs: [{
          name: 'src',
          value: '//localhost:8196/socket.io/socket.io.js',
        }],
      }))

      appendChild(BODY, createTagNode({
        tagName: 'script',
        childNodes: [createTextNode(generateHotListener(this._template))],
      }))
    }

    log(`Emitting final HTML: ${prettyFormat(TEMPLATE_PATH)}`)
github borela-tech / js-toolbox / src / configs / webpack / plugins / Html / utils.js View on Github external
export function * getCompanionChunks(chunks, template:Template) {
  let {fullPath} = template
  const MAIN_CHUNK = findMainCompanionChunk(chunks, template)

  if (!MAIN_CHUNK) {
    log(`Companion chunk NOT found for: ${prettyFormat(fullPath)}`)
    return
  }

  log(`Companion chunk found for: ${prettyFormat({
    chunk: MAIN_CHUNK.id,
    template: fullPath,
  })}`)

  if (MAIN_CHUNK.getNumberOfGroups() > 1) {
    log(`Companion chunk is inside multiple groups: ${prettyFormat(fullPath)}`)
    return
  }

  // The companion chunk must be on its own group, with that in mind, we are
  // getting the first group from the groups set.
  const GROUP = MAIN_CHUNK.groupsIterable.values()
github ehmicky / gulp-execa / test / helpers / test_each / name.js View on Github external
const serialize = function(param) {
  return prettyFormat(param, PRETTY_FORMAT_OPTS)
}
github trivago / melody / packages / melody-test-utils / src / index.js View on Github external
debug() {
        return prettyFormat(this, {
            escapeRegex: true,
            plugins: [{ test, print }, prettyFormat.plugins.DOMElement],
            printFunctionName: false,
        });
    }
github borela-tech / js-toolbox / src / system.js View on Github external
function internalRunCommand(spawn:Function, cmd:string, options?:RunOptions) {
  log('Spawning...')

  let {
    args = [],
    env = {},
    stdio = 'inherit',
  } = options || {}

  log('cmd: ', prettyFormat(cmd))
  log('options: ', prettyFormat(options))

  const COMPUTED_OPTIONS = {
    cwd: getProjectDir() || process.cwd(),
    env: calculateEnv(env),
    shell: true,
    stdio,
  }

  const RESULT = spawn(cmd, args, COMPUTED_OPTIONS)

  log('COMPUTED_OPTIONS: ', prettyFormat(COMPUTED_OPTIONS))
  log('Result: ', prettyFormat(RESULT))

  return RESULT
}
github jamiebuilds / react-jeff / example / app.tsx View on Github external
type="password"
					placeholder="•••••••"
					{...confirmPassword.props}
				/>
			
			
				<label>I accept the terms and conditions</label>
				
			
			<button type="reset">
				Reset
			</button>
			<button type="submit">Sign Up</button>
			<pre>				{"form = "}
				{format(form, {
					printFunctionName: false,
				})}
			</pre>
		
	)
}
github expo / expo / packages / expo / src / logs / LogSerialization.ts View on Github external
async function _serializeErrorAsync(error: Error, message?: string): Promise {
  if (message == null) {
    message = error.message;
  }

  if (!error.stack || !error.stack.length) {
    return prettyFormat(error);
  }

  let stack = await _symbolicateErrorAsync(error);
  let formattedStack = _formatStack(stack);

  return { message, stack: formattedStack };
}
github apollographql / apollo-server / packages / apollo-gateway / src / QueryPlan.ts View on Github external
export function serializeQueryPlan(queryPlan: QueryPlan) {
  return prettyFormat(queryPlan, {
    plugins: [queryPlanSerializer, astSerializer],
  });
}