@vitest/pretty-format
Advanced tools
+63
-106
@@ -178,6 +178,6 @@ import styles from 'tinyrainbow'; | ||
| }; | ||
| const test$6 = (val) => val && val.$$typeof === asymmetricMatcher; | ||
| const test$5 = (val) => val && val.$$typeof === asymmetricMatcher; | ||
| const plugin$5 = { | ||
| serialize: serialize$5, | ||
| test: test$6 | ||
| test: test$5 | ||
| }; | ||
@@ -191,3 +191,3 @@ | ||
| } | ||
| const test$5 = (val) => val && val.constructor && !!val.constructor.name && testName(val.constructor.name); | ||
| const test$4 = (val) => val && val.constructor && !!val.constructor.name && testName(val.constructor.name); | ||
| function isNamedNodeMap(collection) { | ||
@@ -208,3 +208,3 @@ return collection.constructor.name === "NamedNodeMap"; | ||
| serialize: serialize$4, | ||
| test: test$5 | ||
| test: test$4 | ||
| }; | ||
@@ -273,8 +273,8 @@ | ||
| const ELEMENT_NODE$1 = 1; | ||
| const TEXT_NODE$1 = 3; | ||
| const COMMENT_NODE$1 = 8; | ||
| const FRAGMENT_NODE$1 = 11; | ||
| const ELEMENT_REGEXP$1 = /^(?:(?:HTML|SVG)\w*)?Element$/; | ||
| function testHasAttribute$1(val) { | ||
| const ELEMENT_NODE = 1; | ||
| const TEXT_NODE = 3; | ||
| const COMMENT_NODE = 8; | ||
| const FRAGMENT_NODE = 11; | ||
| const ELEMENT_REGEXP = /^(?:(?:HTML|SVG)\w*)?Element$/; | ||
| function testHasAttribute(val) { | ||
| try { | ||
@@ -286,37 +286,66 @@ return typeof val.hasAttribute === "function" && val.hasAttribute("is"); | ||
| } | ||
| function testNode$1(val) { | ||
| function testNode(val) { | ||
| const constructorName = val.constructor.name; | ||
| const { nodeType, tagName } = val; | ||
| const isCustomElement = typeof tagName === "string" && tagName.includes("-") || testHasAttribute$1(val); | ||
| return nodeType === ELEMENT_NODE$1 && (ELEMENT_REGEXP$1.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE$1 && constructorName === "Text" || nodeType === COMMENT_NODE$1 && constructorName === "Comment" || nodeType === FRAGMENT_NODE$1 && constructorName === "DocumentFragment"; | ||
| const isCustomElement = typeof tagName === "string" && tagName.includes("-") || testHasAttribute(val); | ||
| return nodeType === ELEMENT_NODE && (ELEMENT_REGEXP.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE && constructorName === "Text" || nodeType === COMMENT_NODE && constructorName === "Comment" || nodeType === FRAGMENT_NODE && constructorName === "DocumentFragment"; | ||
| } | ||
| const test$4 = (val) => val?.constructor?.name && testNode$1(val); | ||
| function nodeIsText$1(node) { | ||
| return node.nodeType === TEXT_NODE$1; | ||
| const test$3 = (val) => val?.constructor?.name && testNode(val); | ||
| function nodeIsText(node) { | ||
| return node.nodeType === TEXT_NODE; | ||
| } | ||
| function nodeIsComment$1(node) { | ||
| return node.nodeType === COMMENT_NODE$1; | ||
| function nodeIsComment(node) { | ||
| return node.nodeType === COMMENT_NODE; | ||
| } | ||
| function nodeIsFragment$1(node) { | ||
| return node.nodeType === FRAGMENT_NODE$1; | ||
| function nodeIsFragment(node) { | ||
| return node.nodeType === FRAGMENT_NODE; | ||
| } | ||
| const serialize$3 = (node, config, indentation, depth, refs, printer) => { | ||
| if (nodeIsText$1(node)) { | ||
| function filterChildren(children, filterNode) { | ||
| // Filter out text nodes that only contain whitespace to prevent empty lines | ||
| // This is done regardless of whether a filterNode is provided | ||
| let filtered = children.filter((node) => { | ||
| // Filter out text nodes that are only whitespace | ||
| if (node.nodeType === TEXT_NODE) { | ||
| const text = node.data || ""; | ||
| // Keep text nodes that have non-whitespace content | ||
| return text.trim().length > 0; | ||
| } | ||
| return true; | ||
| }); | ||
| // Apply additional user-provided filter if specified | ||
| if (filterNode) { | ||
| filtered = filtered.filter(filterNode); | ||
| } | ||
| return filtered; | ||
| } | ||
| function serializeDOM(node, config, indentation, depth, refs, printer, filterNode) { | ||
| if (nodeIsText(node)) { | ||
| return printText(node.data, config); | ||
| } | ||
| if (nodeIsComment$1(node)) { | ||
| if (nodeIsComment(node)) { | ||
| return printComment(node.data, config); | ||
| } | ||
| const type = nodeIsFragment$1(node) ? "DocumentFragment" : node.tagName.toLowerCase(); | ||
| const type = nodeIsFragment(node) ? "DocumentFragment" : node.tagName.toLowerCase(); | ||
| if (++depth > config.maxDepth) { | ||
| return printElementAsLeaf(type, config); | ||
| } | ||
| return printElement(type, printProps(nodeIsFragment$1(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment$1(node) ? {} : [...node.attributes].reduce((props, attribute) => { | ||
| const children = Array.prototype.slice.call(node.childNodes || node.children); | ||
| const shadowChildren = nodeIsFragment(node) || !node.shadowRoot ? [] : Array.prototype.slice.call(node.shadowRoot.children); | ||
| const resolvedChildren = filterNode ? filterChildren(children, filterNode) : children; | ||
| const resolvedShadowChildren = filterNode ? filterChildren(shadowChildren, filterNode) : shadowChildren; | ||
| return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => { | ||
| props[attribute.name] = attribute.value; | ||
| return props; | ||
| }, {}), config, indentation + config.indent, depth, refs, printer), (nodeIsFragment$1(node) || !node.shadowRoot ? "" : printShadowRoot(Array.prototype.slice.call(node.shadowRoot.children), config, indentation + config.indent, depth, refs, printer)) + printChildren(Array.prototype.slice.call(node.childNodes || node.children), config, indentation + config.indent, depth, refs, printer), config, indentation); | ||
| }; | ||
| }, {}), config, indentation + config.indent, depth, refs, printer), (resolvedShadowChildren.length > 0 ? printShadowRoot(resolvedShadowChildren, config, indentation + config.indent, depth, refs, printer) : "") + printChildren(resolvedChildren, config, indentation + config.indent, depth, refs, printer), config, indentation); | ||
| } | ||
| const serialize$3 = (node, config, indentation, depth, refs, printer) => serializeDOM(node, config, indentation, depth, refs, printer); | ||
| function createDOMElementFilter(filterNode) { | ||
| return { | ||
| test: test$3, | ||
| serialize: (node, config, indentation, depth, refs, printer) => serializeDOM(node, config, indentation, depth, refs, printer, filterNode) | ||
| }; | ||
| } | ||
| const plugin$3 = { | ||
| serialize: serialize$3, | ||
| test: test$4 | ||
| test: test$3 | ||
| }; | ||
@@ -399,6 +428,6 @@ | ||
| // when mock identity-obj-proxy returns the key as the value for any key. | ||
| const test$3 = (val) => val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true); | ||
| const test$2 = (val) => val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true); | ||
| const plugin$2 = { | ||
| serialize: serialize$2, | ||
| test: test$3 | ||
| test: test$2 | ||
| }; | ||
@@ -687,6 +716,6 @@ | ||
| const serialize$1 = (element, config, indentation, depth, refs, printer) => ++depth > config.maxDepth ? printElementAsLeaf(getType(element), config) : printElement(getType(element), printProps(getPropKeys$1(element), element.props, config, indentation + config.indent, depth, refs, printer), printChildren(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer), config, indentation); | ||
| const test$2 = (val) => val != null && ReactIs.isElement(val); | ||
| const test$1 = (val) => val != null && ReactIs.isElement(val); | ||
| const plugin$1 = { | ||
| serialize: serialize$1, | ||
| test: test$2 | ||
| test: test$1 | ||
| }; | ||
@@ -700,80 +729,8 @@ | ||
| const serialize = (object, config, indentation, depth, refs, printer) => ++depth > config.maxDepth ? printElementAsLeaf(object.type, config) : printElement(object.type, object.props ? printProps(getPropKeys(object), object.props, config, indentation + config.indent, depth, refs, printer) : "", object.children ? printChildren(object.children, config, indentation + config.indent, depth, refs, printer) : "", config, indentation); | ||
| const test$1 = (val) => val && val.$$typeof === testSymbol; | ||
| const test = (val) => val && val.$$typeof === testSymbol; | ||
| const plugin = { | ||
| serialize, | ||
| test: test$1 | ||
| test | ||
| }; | ||
| const ELEMENT_NODE = 1; | ||
| const TEXT_NODE = 3; | ||
| const COMMENT_NODE = 8; | ||
| const FRAGMENT_NODE = 11; | ||
| const ELEMENT_REGEXP = /^(?:(?:HTML|SVG)\w*)?Element$/; | ||
| function testHasAttribute(val) { | ||
| try { | ||
| return typeof val.hasAttribute === "function" && val.hasAttribute("is"); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| function testNode(val) { | ||
| const constructorName = val.constructor.name; | ||
| const { nodeType, tagName } = val; | ||
| const isCustomElement = typeof tagName === "string" && tagName.includes("-") || testHasAttribute(val); | ||
| return nodeType === ELEMENT_NODE && (ELEMENT_REGEXP.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE && constructorName === "Text" || nodeType === COMMENT_NODE && constructorName === "Comment" || nodeType === FRAGMENT_NODE && constructorName === "DocumentFragment"; | ||
| } | ||
| const test = (val) => val?.constructor?.name && testNode(val); | ||
| function nodeIsText(node) { | ||
| return node.nodeType === TEXT_NODE; | ||
| } | ||
| function nodeIsComment(node) { | ||
| return node.nodeType === COMMENT_NODE; | ||
| } | ||
| function nodeIsFragment(node) { | ||
| return node.nodeType === FRAGMENT_NODE; | ||
| } | ||
| function filterChildren(children, filterNode) { | ||
| // Filter out text nodes that only contain whitespace to prevent empty lines | ||
| // This is done regardless of whether a filterNode is provided | ||
| let filtered = children.filter((node) => { | ||
| // Filter out text nodes that are only whitespace | ||
| if (node.nodeType === TEXT_NODE) { | ||
| const text = node.data || ""; | ||
| // Keep text nodes that have non-whitespace content | ||
| return text.trim().length > 0; | ||
| } | ||
| return true; | ||
| }); | ||
| // Apply additional user-provided filter if specified | ||
| if (filterNode) { | ||
| filtered = filtered.filter(filterNode); | ||
| } | ||
| return filtered; | ||
| } | ||
| function createDOMElementFilter(filterNode) { | ||
| return { | ||
| test, | ||
| serialize: (node, config, indentation, depth, refs, printer) => { | ||
| if (nodeIsText(node)) { | ||
| return printText(node.data, config); | ||
| } | ||
| if (nodeIsComment(node)) { | ||
| return printComment(node.data, config); | ||
| } | ||
| const type = nodeIsFragment(node) ? "DocumentFragment" : node.tagName.toLowerCase(); | ||
| if (++depth > config.maxDepth) { | ||
| return printElementAsLeaf(type, config); | ||
| } | ||
| const children = Array.prototype.slice.call(node.childNodes || node.children); | ||
| const filteredChildren = filterChildren(children, filterNode); | ||
| const shadowChildren = nodeIsFragment(node) || !node.shadowRoot ? [] : Array.prototype.slice.call(node.shadowRoot.children); | ||
| const filteredShadowChildren = filterChildren(shadowChildren, filterNode); | ||
| return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => { | ||
| props[attribute.name] = attribute.value; | ||
| return props; | ||
| }, {}), config, indentation + config.indent, depth, refs, printer), (filteredShadowChildren.length > 0 ? printShadowRoot(filteredShadowChildren, config, indentation + config.indent, depth, refs, printer) : "") + printChildren(filteredChildren, config, indentation + config.indent, depth, refs, printer), config, indentation); | ||
| } | ||
| }; | ||
| } | ||
| const toString = Object.prototype.toString; | ||
@@ -780,0 +737,0 @@ const toISOString = Date.prototype.toISOString; |
+1
-1
| { | ||
| "name": "@vitest/pretty-format", | ||
| "type": "module", | ||
| "version": "4.1.0-beta.3", | ||
| "version": "4.1.0-beta.4", | ||
| "description": "Fork of pretty-format with support for ESM", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
46890
-3.85%1158
-3.66%