MCPcopy
hub / github.com/vitest-dev/vitest / serialize

Function serialize

packages/pretty-format/src/plugins/ReactElement.ts:107–138  ·  view source on GitHub ↗
(
  element: any,
  config: Config,
  indentation: string,
  depth: number,
  refs: Refs,
  printer: Printer,
)

Source from the content-addressed store, hash-verified

105}
106
107export const serialize: NewPlugin['serialize'] = (
108 element: any,
109 config: Config,
110 indentation: string,
111 depth: number,
112 refs: Refs,
113 printer: Printer,
114) =>
115 ++depth > config.maxDepth
116 ? printElementAsLeaf(getType(element), config)
117 : printElement(
118 getType(element),
119 printProps(
120 getPropKeys(element),
121 element.props,
122 config,
123 indentation + config.indent,
124 depth,
125 refs,
126 printer,
127 ),
128 printChildren(
129 getChildren(element.props.children),
130 config,
131 indentation + config.indent,
132 depth,
133 refs,
134 printer,
135 ),
136 config,
137 indentation,
138 )
139
140export const test: NewPlugin['test'] = (val: unknown) =>
141 val != null && ReactIs.isElement(val)

Callers

nothing calls this directly

Calls 7

printElementAsLeafFunction · 0.90
printElementFunction · 0.90
printPropsFunction · 0.90
printChildrenFunction · 0.90
getChildrenFunction · 0.85
getTypeFunction · 0.70
getPropKeysFunction · 0.70

Tested by

no test coverage detected