Comparing version 27.0.0-next.9 to 27.0.0-next.10
@@ -6,3 +6,14 @@ 'use strict'; | ||
}); | ||
exports.stringNotMatching = exports.stringMatching = exports.stringNotContaining = exports.stringContaining = exports.objectNotContaining = exports.objectContaining = exports.arrayNotContaining = exports.arrayContaining = exports.anything = exports.any = exports.AsymmetricMatcher = void 0; | ||
exports.stringNotMatching = | ||
exports.stringMatching = | ||
exports.stringNotContaining = | ||
exports.stringContaining = | ||
exports.objectNotContaining = | ||
exports.objectContaining = | ||
exports.arrayNotContaining = | ||
exports.arrayContaining = | ||
exports.anything = | ||
exports.any = | ||
exports.AsymmetricMatcher = | ||
void 0; | ||
@@ -9,0 +20,0 @@ var _jasmineUtils = require('./jasmineUtils'); |
@@ -29,13 +29,13 @@ 'use strict'; | ||
function _getRequireWildcardCache() { | ||
function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== 'function') return null; | ||
var cache = new WeakMap(); | ||
_getRequireWildcardCache = function () { | ||
return cache; | ||
}; | ||
return cache; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function (nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
} | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
function _interopRequireWildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) { | ||
return obj; | ||
@@ -46,3 +46,3 @@ } | ||
} | ||
var cache = _getRequireWildcardCache(); | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) { | ||
@@ -55,3 +55,3 @@ return cache.get(obj); | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor | ||
@@ -180,85 +180,85 @@ ? Object.getOwnPropertyDescriptor(obj, key) | ||
const makeResolveMatcher = (matcherName, matcher, isNot, actual, outerErr) => ( | ||
...args | ||
) => { | ||
const options = { | ||
isNot, | ||
promise: 'resolves' | ||
}; | ||
const makeResolveMatcher = | ||
(matcherName, matcher, isNot, actual, outerErr) => | ||
(...args) => { | ||
const options = { | ||
isNot, | ||
promise: 'resolves' | ||
}; | ||
if (!isPromise(actual)) { | ||
throw new JestAssertionError( | ||
matcherUtils.matcherErrorMessage( | ||
matcherUtils.matcherHint(matcherName, undefined, '', options), | ||
`${matcherUtils.RECEIVED_COLOR('received')} value must be a promise`, | ||
matcherUtils.printWithType( | ||
'Received', | ||
actual, | ||
matcherUtils.printReceived | ||
if (!isPromise(actual)) { | ||
throw new JestAssertionError( | ||
matcherUtils.matcherErrorMessage( | ||
matcherUtils.matcherHint(matcherName, undefined, '', options), | ||
`${matcherUtils.RECEIVED_COLOR('received')} value must be a promise`, | ||
matcherUtils.printWithType( | ||
'Received', | ||
actual, | ||
matcherUtils.printReceived | ||
) | ||
) | ||
) | ||
); | ||
} | ||
const innerErr = new JestAssertionError(); | ||
return actual.then( | ||
result => | ||
makeThrowingMatcher(matcher, isNot, 'resolves', result, innerErr).apply( | ||
null, | ||
args | ||
), | ||
reason => { | ||
outerErr.message = | ||
matcherUtils.matcherHint(matcherName, undefined, '', options) + | ||
'\n\n' + | ||
`Received promise rejected instead of resolved\n` + | ||
`Rejected to value: ${matcherUtils.printReceived(reason)}`; | ||
return Promise.reject(outerErr); | ||
); | ||
} | ||
); | ||
}; | ||
const makeRejectMatcher = (matcherName, matcher, isNot, actual, outerErr) => ( | ||
...args | ||
) => { | ||
const options = { | ||
isNot, | ||
promise: 'rejects' | ||
const innerErr = new JestAssertionError(); | ||
return actual.then( | ||
result => | ||
makeThrowingMatcher(matcher, isNot, 'resolves', result, innerErr).apply( | ||
null, | ||
args | ||
), | ||
reason => { | ||
outerErr.message = | ||
matcherUtils.matcherHint(matcherName, undefined, '', options) + | ||
'\n\n' + | ||
`Received promise rejected instead of resolved\n` + | ||
`Rejected to value: ${matcherUtils.printReceived(reason)}`; | ||
return Promise.reject(outerErr); | ||
} | ||
); | ||
}; | ||
const actualWrapper = typeof actual === 'function' ? actual() : actual; | ||
if (!isPromise(actualWrapper)) { | ||
throw new JestAssertionError( | ||
matcherUtils.matcherErrorMessage( | ||
matcherUtils.matcherHint(matcherName, undefined, '', options), | ||
`${matcherUtils.RECEIVED_COLOR( | ||
'received' | ||
)} value must be a promise or a function returning a promise`, | ||
matcherUtils.printWithType( | ||
'Received', | ||
actual, | ||
matcherUtils.printReceived | ||
const makeRejectMatcher = | ||
(matcherName, matcher, isNot, actual, outerErr) => | ||
(...args) => { | ||
const options = { | ||
isNot, | ||
promise: 'rejects' | ||
}; | ||
const actualWrapper = typeof actual === 'function' ? actual() : actual; | ||
if (!isPromise(actualWrapper)) { | ||
throw new JestAssertionError( | ||
matcherUtils.matcherErrorMessage( | ||
matcherUtils.matcherHint(matcherName, undefined, '', options), | ||
`${matcherUtils.RECEIVED_COLOR( | ||
'received' | ||
)} value must be a promise or a function returning a promise`, | ||
matcherUtils.printWithType( | ||
'Received', | ||
actual, | ||
matcherUtils.printReceived | ||
) | ||
) | ||
) | ||
); | ||
} | ||
const innerErr = new JestAssertionError(); | ||
return actualWrapper.then( | ||
result => { | ||
outerErr.message = | ||
matcherUtils.matcherHint(matcherName, undefined, '', options) + | ||
'\n\n' + | ||
`Received promise resolved instead of rejected\n` + | ||
`Resolved to value: ${matcherUtils.printReceived(result)}`; | ||
return Promise.reject(outerErr); | ||
}, | ||
reason => | ||
makeThrowingMatcher(matcher, isNot, 'rejects', reason, innerErr).apply( | ||
null, | ||
args | ||
) | ||
); | ||
} | ||
}; | ||
const innerErr = new JestAssertionError(); | ||
return actualWrapper.then( | ||
result => { | ||
outerErr.message = | ||
matcherUtils.matcherHint(matcherName, undefined, '', options) + | ||
'\n\n' + | ||
`Received promise resolved instead of rejected\n` + | ||
`Resolved to value: ${matcherUtils.printReceived(result)}`; | ||
return Promise.reject(outerErr); | ||
}, | ||
reason => | ||
makeThrowingMatcher(matcher, isNot, 'rejects', reason, innerErr).apply( | ||
null, | ||
args | ||
) | ||
); | ||
}; | ||
const makeThrowingMatcher = (matcher, isNot, promise, actual, err) => | ||
@@ -265,0 +265,0 @@ function throwingMatcher(...args) { |
@@ -6,3 +6,8 @@ 'use strict'; | ||
}); | ||
exports.setMatchers = exports.getMatchers = exports.setState = exports.getState = exports.INTERNAL_MATCHER_FLAG = void 0; | ||
exports.setMatchers = | ||
exports.getMatchers = | ||
exports.setState = | ||
exports.getState = | ||
exports.INTERNAL_MATCHER_FLAG = | ||
void 0; | ||
@@ -9,0 +14,0 @@ var _asymmetricMatchers = require('./asymmetricMatchers'); |
@@ -6,3 +6,11 @@ 'use strict'; | ||
}); | ||
exports.printReceivedConstructorNameNot = exports.printReceivedConstructorName = exports.printExpectedConstructorNameNot = exports.printExpectedConstructorName = exports.printCloseTo = exports.printReceivedArrayContainExpectedItem = exports.printReceivedStringContainExpectedResult = exports.printReceivedStringContainExpectedSubstring = void 0; | ||
exports.printReceivedConstructorNameNot = | ||
exports.printReceivedConstructorName = | ||
exports.printExpectedConstructorNameNot = | ||
exports.printExpectedConstructorName = | ||
exports.printCloseTo = | ||
exports.printReceivedArrayContainExpectedItem = | ||
exports.printReceivedStringContainExpectedResult = | ||
exports.printReceivedStringContainExpectedSubstring = | ||
void 0; | ||
@@ -35,3 +43,4 @@ var _jestMatcherUtils = require('jest-matcher-utils'); | ||
exports.printReceivedStringContainExpectedSubstring = printReceivedStringContainExpectedSubstring; | ||
exports.printReceivedStringContainExpectedSubstring = | ||
printReceivedStringContainExpectedSubstring; | ||
@@ -49,3 +58,4 @@ const printReceivedStringContainExpectedResult = (received, result) => | ||
exports.printReceivedStringContainExpectedResult = printReceivedStringContainExpectedResult; | ||
exports.printReceivedStringContainExpectedResult = | ||
printReceivedStringContainExpectedResult; | ||
@@ -66,3 +76,4 @@ const printReceivedArrayContainExpectedItem = (received, index) => | ||
exports.printReceivedArrayContainExpectedItem = printReceivedArrayContainExpectedItem; | ||
exports.printReceivedArrayContainExpectedItem = | ||
printReceivedArrayContainExpectedItem; | ||
@@ -69,0 +80,0 @@ const printCloseTo = (receivedDiff, expectedDiff, precision, isNot) => { |
@@ -7,3 +7,12 @@ 'use strict'; | ||
exports.emptyObject = emptyObject; | ||
exports.isOneline = exports.isError = exports.partition = exports.sparseArrayEquality = exports.typeEquality = exports.subsetEquality = exports.iterableEquality = exports.getObjectSubset = exports.getPath = void 0; | ||
exports.isOneline = | ||
exports.isError = | ||
exports.partition = | ||
exports.sparseArrayEquality = | ||
exports.typeEquality = | ||
exports.subsetEquality = | ||
exports.iterableEquality = | ||
exports.getObjectSubset = | ||
exports.getPath = | ||
void 0; | ||
@@ -290,38 +299,37 @@ var _jestGetType = require('jest-get-type'); | ||
// there are circular references in the subset passed to it. | ||
const subsetEqualityWithContext = (seenReferences = new WeakMap()) => ( | ||
object, | ||
subset | ||
) => { | ||
if (!isObjectWithKeys(subset)) { | ||
return undefined; | ||
} | ||
const subsetEqualityWithContext = | ||
(seenReferences = new WeakMap()) => | ||
(object, subset) => { | ||
if (!isObjectWithKeys(subset)) { | ||
return undefined; | ||
} | ||
return Object.keys(subset).every(key => { | ||
if (isObjectWithKeys(subset[key])) { | ||
if (seenReferences.has(subset[key])) { | ||
return (0, _jasmineUtils.equals)(object[key], subset[key], [ | ||
iterableEquality | ||
]); | ||
return Object.keys(subset).every(key => { | ||
if (isObjectWithKeys(subset[key])) { | ||
if (seenReferences.has(subset[key])) { | ||
return (0, _jasmineUtils.equals)(object[key], subset[key], [ | ||
iterableEquality | ||
]); | ||
} | ||
seenReferences.set(subset[key], true); | ||
} | ||
seenReferences.set(subset[key], true); | ||
} | ||
const result = | ||
object != null && | ||
hasPropertyInObject(object, key) && | ||
(0, _jasmineUtils.equals)(object[key], subset[key], [ | ||
iterableEquality, | ||
subsetEqualityWithContext(seenReferences) | ||
]); // The main goal of using seenReference is to avoid circular node on tree. | ||
// It will only happen within a parent and its child, not a node and nodes next to it (same level) | ||
// We should keep the reference for a parent and its child only | ||
// Thus we should delete the reference immediately so that it doesn't interfere | ||
// other nodes within the same level on tree. | ||
const result = | ||
object != null && | ||
hasPropertyInObject(object, key) && | ||
(0, _jasmineUtils.equals)(object[key], subset[key], [ | ||
iterableEquality, | ||
subsetEqualityWithContext(seenReferences) | ||
]); // The main goal of using seenReference is to avoid circular node on tree. | ||
// It will only happen within a parent and its child, not a node and nodes next to it (same level) | ||
// We should keep the reference for a parent and its child only | ||
// Thus we should delete the reference immediately so that it doesn't interfere | ||
// other nodes within the same level on tree. | ||
seenReferences.delete(subset[key]); | ||
return result; | ||
}); | ||
}; | ||
seenReferences.delete(subset[key]); | ||
return result; | ||
}); | ||
}; | ||
return subsetEqualityWithContext()(object, subset); | ||
@@ -368,7 +376,3 @@ }; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
case '[object Error]': | ||
return true; | ||
case '[object Exception]': | ||
return true; | ||
case '[object DOMException]': | ||
@@ -375,0 +379,0 @@ return true; |
{ | ||
"name": "expect", | ||
"version": "27.0.0-next.9", | ||
"version": "27.0.0-next.10", | ||
"repository": { | ||
@@ -18,11 +18,11 @@ "type": "git", | ||
"dependencies": { | ||
"@jest/types": "^27.0.0-next.8", | ||
"@jest/types": "^27.0.0-next.10", | ||
"ansi-styles": "^5.0.0", | ||
"jest-get-type": "^27.0.0-next.9", | ||
"jest-matcher-utils": "^27.0.0-next.9", | ||
"jest-message-util": "^27.0.0-next.9", | ||
"jest-matcher-utils": "^27.0.0-next.10", | ||
"jest-message-util": "^27.0.0-next.10", | ||
"jest-regex-util": "^27.0.0-next.0" | ||
}, | ||
"devDependencies": { | ||
"@jest/test-utils": "^27.0.0-next.9", | ||
"@jest/test-utils": "^27.0.0-next.10", | ||
"chalk": "^4.0.0", | ||
@@ -38,3 +38,3 @@ "fast-check": "^2.0.0", | ||
}, | ||
"gitHead": "d836f33f98845794b4eae8149548a81ddcfc6521" | ||
"gitHead": "6f44529270310b7dbdf9a0b72b21b5cd50fda4b1" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
163740
4851