jest-matcher-utils
Advanced tools
Comparing version
@@ -131,2 +131,4 @@ /** | ||
export declare const SERIALIZABLE_PROPERTIES: unique symbol; | ||
export declare const stringify: ( | ||
@@ -133,0 +135,0 @@ object: unknown, |
@@ -88,4 +88,6 @@ /*! | ||
})); | ||
exports.SERIALIZABLE_PROPERTIES = void 0; | ||
exports["default"] = deepCyclicCopyReplaceable; | ||
var _prettyFormat = require("pretty-format"); | ||
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol; | ||
/** | ||
@@ -97,3 +99,2 @@ * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
*/ | ||
const builtInObject = [Array, Date, Float32Array, Float64Array, Int16Array, Int32Array, Int8Array, Map, Set, RegExp, Uint16Array, Uint32Array, Uint8Array, Uint8ClampedArray]; | ||
@@ -103,2 +104,3 @@ if (typeof Buffer !== 'undefined') { | ||
} | ||
const SERIALIZABLE_PROPERTIES = exports.SERIALIZABLE_PROPERTIES = Symbol.for('@jest/serializableProperties'); | ||
const isBuiltInObject = object => builtInObject.includes(object.constructor); | ||
@@ -128,3 +130,12 @@ const isMap = value => value.constructor === Map; | ||
do { | ||
descriptors = Object.assign({}, Object.getOwnPropertyDescriptors(obj), descriptors); | ||
const serializableProperties = getSerializableProperties(obj); | ||
if (serializableProperties === undefined) { | ||
descriptors = Object.assign({}, Object.getOwnPropertyDescriptors(obj), descriptors); | ||
} else { | ||
for (const property of serializableProperties) { | ||
if (!descriptors[property]) { | ||
descriptors[property] = Object.getOwnPropertyDescriptor(obj, property); | ||
} | ||
} | ||
} | ||
} while ((obj = Object.getPrototypeOf(obj)) && obj !== Object.getPrototypeOf({})); | ||
@@ -169,2 +180,12 @@ cycles.set(object, newObject); | ||
} | ||
function getSerializableProperties(obj) { | ||
if (typeof obj !== 'object' || obj === null) { | ||
return; | ||
} | ||
const serializableProperties = obj[SERIALIZABLE_PROPERTIES]; | ||
if (!Array.isArray(serializableProperties)) { | ||
return; | ||
} | ||
return serializableProperties.filter(key => typeof key === 'string' || typeof key === 'symbol'); | ||
} | ||
@@ -209,3 +230,10 @@ /***/ }) | ||
})); | ||
exports.printReceived = exports.printExpected = exports.printDiffOrStringify = exports.pluralize = exports.matcherHint = exports.matcherErrorMessage = exports.highlightTrailingWhitespace = exports.getLabelPrinter = exports.ensureNumbers = exports.ensureNoExpected = exports.ensureExpectedIsNumber = exports.ensureExpectedIsNonNegativeInteger = exports.ensureActualIsNumber = exports.diff = exports.SUGGEST_TO_CONTAIN_EQUAL = exports.RECEIVED_COLOR = exports.INVERTED_COLOR = exports.EXPECTED_COLOR = exports.DIM_COLOR = exports.BOLD_WEIGHT = void 0; | ||
exports.RECEIVED_COLOR = exports.INVERTED_COLOR = exports.EXPECTED_COLOR = exports.DIM_COLOR = exports.BOLD_WEIGHT = void 0; | ||
Object.defineProperty(exports, "SERIALIZABLE_PROPERTIES", ({ | ||
enumerable: true, | ||
get: function () { | ||
return _deepCyclicCopyReplaceable.SERIALIZABLE_PROPERTIES; | ||
} | ||
})); | ||
exports.printReceived = exports.printExpected = exports.printDiffOrStringify = exports.pluralize = exports.matcherHint = exports.matcherErrorMessage = exports.highlightTrailingWhitespace = exports.getLabelPrinter = exports.ensureNumbers = exports.ensureNoExpected = exports.ensureExpectedIsNumber = exports.ensureExpectedIsNonNegativeInteger = exports.ensureActualIsNumber = exports.diff = exports.SUGGEST_TO_CONTAIN_EQUAL = void 0; | ||
exports.printWithType = printWithType; | ||
@@ -219,3 +247,5 @@ exports.replaceMatchedToAsymmetricMatcher = replaceMatchedToAsymmetricMatcher; | ||
var _Replaceable = _interopRequireDefault(__webpack_require__("./src/Replaceable.ts")); | ||
var _deepCyclicCopyReplaceable = _interopRequireDefault(__webpack_require__("./src/deepCyclicCopyReplaceable.ts")); | ||
var _deepCyclicCopyReplaceable = _interopRequireWildcard(__webpack_require__("./src/deepCyclicCopyReplaceable.ts")); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -222,0 +252,0 @@ /** |
{ | ||
"name": "jest-matcher-utils", | ||
"description": "A set of utility functions for expect and related packages", | ||
"version": "30.0.0-alpha.3", | ||
"version": "30.0.0-alpha.4", | ||
"repository": { | ||
@@ -27,8 +27,8 @@ "type": "git", | ||
"chalk": "^4.0.0", | ||
"jest-diff": "30.0.0-alpha.3", | ||
"jest-get-type": "30.0.0-alpha.3", | ||
"pretty-format": "30.0.0-alpha.3" | ||
"jest-diff": "30.0.0-alpha.4", | ||
"jest-get-type": "30.0.0-alpha.4", | ||
"pretty-format": "30.0.0-alpha.4" | ||
}, | ||
"devDependencies": { | ||
"@jest/test-utils": "30.0.0-alpha.3", | ||
"@jest/test-utils": "30.0.0-alpha.4", | ||
"@types/node": "*" | ||
@@ -39,3 +39,3 @@ }, | ||
}, | ||
"gitHead": "e267aff33d105399f2134bad7c8f82285104f3da" | ||
"gitHead": "32b966f988d47a7673d2ef4b92e834dab7d66f07" | ||
} |
@@ -24,2 +24,2 @@ # jest-matcher-utils | ||
`EXPECTED_COLOR` `RECEIVED_COLOR` `INVERTED_COLOR` `BOLD_WEIGHT` `DIM_COLOR` `SUGGEST_TO_CONTAIN_EQUAL` | ||
`EXPECTED_COLOR` `RECEIVED_COLOR` `INVERTED_COLOR` `BOLD_WEIGHT` `DIM_COLOR` `SUGGEST_TO_CONTAIN_EQUAL` `SERIALIZABLE_PROPERTIES` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
32811
6.71%695
5.14%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated