jest-snapshot
Advanced tools
Comparing version 28.0.0-alpha.5 to 28.0.0-alpha.6
@@ -123,15 +123,11 @@ 'use strict'; | ||
const hasHint = hint.length !== 0; | ||
return ( | ||
'Snapshot name: `' + | ||
(hasNames ? (0, _utils.escapeBacktickString)(concatenatedBlockNames) : '') + | ||
(hasNames && hasHint ? ': ' : '') + | ||
(hasHint | ||
return `Snapshot name: \`${ | ||
hasNames ? (0, _utils.escapeBacktickString)(concatenatedBlockNames) : '' | ||
}${hasNames && hasHint ? ': ' : ''}${ | ||
hasHint | ||
? (0, _jestMatcherUtils.BOLD_WEIGHT)( | ||
(0, _utils.escapeBacktickString)(hint) | ||
) | ||
: '') + | ||
' ' + | ||
count + | ||
'`' | ||
); | ||
: '' | ||
} ${count}\``; | ||
}; | ||
@@ -185,3 +181,3 @@ | ||
const cleanup = (hasteFS, update, snapshotResolver, testPathIgnorePatterns) => { | ||
const pattern = '\\.' + _SnapshotResolver.EXTENSION + '$'; | ||
const pattern = `\\.${_SnapshotResolver.EXTENSION}$`; | ||
const files = hasteFS.matchFiles(pattern); | ||
@@ -384,11 +380,9 @@ let testIgnorePatternsRegex = null; | ||
throw new Error( | ||
(0, _printSnapshot.matcherHintFromConfig)(config, false) + | ||
'\n\n' + | ||
`${(0, _printSnapshot.matcherHintFromConfig)(config, false)}\n\n` + | ||
'Snapshot state must be initialized' + | ||
'\n\n' + | ||
(0, _jestMatcherUtils.printWithType)( | ||
`\n\n${(0, _jestMatcherUtils.printWithType)( | ||
'Snapshot state', | ||
snapshotState, | ||
_jestMatcherUtils.stringify | ||
) | ||
)}` | ||
); | ||
@@ -431,11 +425,11 @@ } | ||
const message = () => | ||
(0, _printSnapshot.matcherHintFromConfig)(config, false) + | ||
'\n\n' + | ||
printSnapshotName(currentTestName, hint, count) + | ||
'\n\n' + | ||
(0, _printSnapshot.printPropertiesAndReceived)( | ||
`${(0, _printSnapshot.matcherHintFromConfig)( | ||
config, | ||
false | ||
)}\n\n${printSnapshotName(currentTestName, hint, count)}\n\n${(0, | ||
_printSnapshot.printPropertiesAndReceived)( | ||
properties, | ||
received, | ||
snapshotState.expand | ||
); | ||
)}`; | ||
@@ -471,6 +465,6 @@ return { | ||
? () => | ||
(0, _printSnapshot.matcherHintFromConfig)(config, true) + | ||
'\n\n' + | ||
printSnapshotName(currentTestName, hint, count) + | ||
'\n\n' + | ||
`${(0, _printSnapshot.matcherHintFromConfig)( | ||
config, | ||
true | ||
)}\n\n${printSnapshotName(currentTestName, hint, count)}\n\n` + | ||
`New snapshot was ${(0, _jestMatcherUtils.BOLD_WEIGHT)( | ||
@@ -485,7 +479,7 @@ 'not written' | ||
: () => | ||
(0, _printSnapshot.matcherHintFromConfig)(config, true) + | ||
'\n\n' + | ||
printSnapshotName(currentTestName, hint, count) + | ||
'\n\n' + | ||
(0, _printSnapshot.printSnapshotAndReceived)( | ||
`${(0, _printSnapshot.matcherHintFromConfig)( | ||
config, | ||
true | ||
)}\n\n${printSnapshotName(currentTestName, hint, count)}\n\n${(0, | ||
_printSnapshot.printSnapshotAndReceived)( | ||
expected, | ||
@@ -495,3 +489,3 @@ actual, | ||
snapshotState.expand | ||
); // Passing the actual and expected objects so that a custom reporter | ||
)}`; // Passing the actual and expected objects so that a custom reporter | ||
// could access them, for example in order to display a custom visual diff, | ||
@@ -632,5 +626,6 @@ // or create a different error message | ||
throw new Error( | ||
(0, _printSnapshot.matcherHintFromConfig)(config, false) + | ||
'\n\n' + | ||
DID_NOT_THROW | ||
`${(0, _printSnapshot.matcherHintFromConfig)( | ||
config, | ||
false | ||
)}\n\n${DID_NOT_THROW}` | ||
); | ||
@@ -637,0 +632,0 @@ } |
@@ -17,3 +17,3 @@ 'use strict'; | ||
const name = val.getMockName(); | ||
const nameString = name === 'jest.fn()' ? '' : ' ' + name; | ||
const nameString = name === 'jest.fn()' ? '' : ` ${name}`; | ||
let callsString = ''; | ||
@@ -23,20 +23,20 @@ | ||
const indentationNext = indentation + config.indent; | ||
callsString = | ||
' {' + | ||
config.spacingOuter + | ||
indentationNext + | ||
'"calls": ' + | ||
printer(val.mock.calls, config, indentationNext, depth, refs) + | ||
(config.min ? ', ' : ',') + | ||
config.spacingOuter + | ||
indentationNext + | ||
'"results": ' + | ||
printer(val.mock.results, config, indentationNext, depth, refs) + | ||
(config.min ? '' : ',') + | ||
config.spacingOuter + | ||
indentation + | ||
'}'; | ||
callsString = ` {${config.spacingOuter}${indentationNext}"calls": ${printer( | ||
val.mock.calls, | ||
config, | ||
indentationNext, | ||
depth, | ||
refs | ||
)}${config.min ? ', ' : ','}${ | ||
config.spacingOuter | ||
}${indentationNext}"results": ${printer( | ||
val.mock.results, | ||
config, | ||
indentationNext, | ||
depth, | ||
refs | ||
)}${config.min ? '' : ','}${config.spacingOuter}${indentation}}`; | ||
} | ||
return '[MockFunction' + nameString + ']' + callsString; | ||
return `[MockFunction${nameString}]${callsString}`; | ||
}; | ||
@@ -43,0 +43,0 @@ |
@@ -266,9 +266,5 @@ 'use strict'; | ||
); | ||
return ( | ||
printLabel(aAnnotation) + | ||
printExpected(properties) + | ||
'\n' + | ||
printLabel(bAnnotation) + | ||
printReceived(received) | ||
); | ||
return `${printLabel(aAnnotation) + printExpected(properties)}\n${printLabel( | ||
bAnnotation | ||
)}${printReceived(received)}`; | ||
}; | ||
@@ -329,6 +325,4 @@ | ||
); | ||
aQuoted = | ||
'"' + joinDiffs(diffs, _jestDiff.DIFF_DELETE, hasCommon) + '"'; | ||
bQuoted = | ||
'"' + joinDiffs(diffs, _jestDiff.DIFF_INSERT, hasCommon) + '"'; | ||
aQuoted = `"${joinDiffs(diffs, _jestDiff.DIFF_DELETE, hasCommon)}"`; | ||
bQuoted = `"${joinDiffs(diffs, _jestDiff.DIFF_INSERT, hasCommon)}"`; | ||
} | ||
@@ -340,9 +334,5 @@ | ||
); | ||
return ( | ||
printLabel(aAnnotation) + | ||
aColor(aQuoted) + | ||
'\n' + | ||
printLabel(bAnnotation) + | ||
bColor(bQuoted) | ||
); | ||
return `${printLabel(aAnnotation) + aColor(aQuoted)}\n${printLabel( | ||
bAnnotation | ||
)}${bColor(bQuoted)}`; | ||
} // Else either string is multiline, so display as unquoted strings. | ||
@@ -395,11 +385,7 @@ | ||
); | ||
return ( | ||
printLabel(aAnnotation) + | ||
aColor(a) + | ||
'\n' + | ||
printLabel(bAnnotation) + | ||
bColor(b) | ||
); | ||
return `${printLabel(aAnnotation) + aColor(a)}\n${printLabel( | ||
bAnnotation | ||
)}${bColor(b)}`; | ||
}; | ||
exports.printSnapshotAndReceived = printSnapshotAndReceived; |
@@ -74,3 +74,3 @@ 'use strict'; | ||
exports.EXTENSION = EXTENSION; | ||
const DOT_EXTENSION = '.' + EXTENSION; | ||
const DOT_EXTENSION = `.${EXTENSION}`; | ||
exports.DOT_EXTENSION = DOT_EXTENSION; | ||
@@ -159,8 +159,5 @@ | ||
function mustImplement(propName, requiredType) { | ||
return ( | ||
_chalk.default.bold( | ||
`Custom snapshot resolver must implement a \`${propName}\` as a ${requiredType}.` | ||
) + | ||
'\nDocumentation: https://jestjs.io/docs/configuration#snapshotresolver-string' | ||
); | ||
return `${_chalk.default.bold( | ||
`Custom snapshot resolver must implement a \`${propName}\` as a ${requiredType}.` | ||
)}\nDocumentation: https://jestjs.io/docs/configuration#snapshotresolver-string`; | ||
} | ||
@@ -167,0 +164,0 @@ |
@@ -127,3 +127,3 @@ 'use strict'; | ||
if (version < SNAPSHOT_VERSION) { | ||
return new Error( | ||
return new Error( // eslint-disable-next-line prefer-template | ||
_chalk.default.red( | ||
@@ -136,4 +136,5 @@ `${_chalk.default.red.bold( | ||
'the same version of Jest. ' + | ||
'Please update all snapshots during this upgrade of Jest.\n\n' | ||
'Please update all snapshots during this upgrade of Jest.' | ||
) + | ||
'\n\n' + | ||
`Expected: v${SNAPSHOT_VERSION}\n` + | ||
@@ -146,3 +147,3 @@ `Received: v${version}\n\n` + | ||
if (version > SNAPSHOT_VERSION) { | ||
return new Error( | ||
return new Error( // eslint-disable-next-line prefer-template | ||
_chalk.default.red( | ||
@@ -155,4 +156,5 @@ `${_chalk.default.red.bold( | ||
'that all developers on a project are using the same version of ' + | ||
'Jest. Please update your version of Jest and re-run the tests.\n\n' | ||
'Jest. Please update your version of Jest and re-run the tests.' | ||
) + | ||
'\n\n' + | ||
`Expected: v${SNAPSHOT_VERSION}\n` + | ||
@@ -170,3 +172,3 @@ `Received: v${version}` | ||
const testNameToKey = (testName, count) => testName + ' ' + count; | ||
const testNameToKey = (testName, count) => `${testName} ${count}`; | ||
@@ -284,3 +286,3 @@ exports.testNameToKey = testNameToKey; | ||
const printBacktickString = str => '`' + escapeBacktickString(str) + '`'; | ||
const printBacktickString = str => `\`${escapeBacktickString(str)}\``; | ||
@@ -304,7 +306,5 @@ const ensureDirectoryExists = filePath => { | ||
key => | ||
'exports[' + | ||
printBacktickString(key) + | ||
'] = ' + | ||
printBacktickString(normalizeNewlines(snapshotData[key])) + | ||
';' | ||
`exports[${printBacktickString(key)}] = ${printBacktickString( | ||
normalizeNewlines(snapshotData[key]) | ||
)};` | ||
); | ||
@@ -314,3 +314,3 @@ ensureDirectoryExists(snapshotPath); | ||
snapshotPath, | ||
writeSnapshotVersion() + '\n\n' + snapshots.join('\n\n') + '\n' | ||
`${writeSnapshotVersion()}\n\n${snapshots.join('\n\n')}\n` | ||
); | ||
@@ -317,0 +317,0 @@ }; |
{ | ||
"name": "jest-snapshot", | ||
"version": "28.0.0-alpha.5", | ||
"version": "28.0.0-alpha.6", | ||
"repository": { | ||
@@ -25,5 +25,5 @@ "type": "git", | ||
"@babel/types": "^7.0.0", | ||
"@jest/expect-utils": "^28.0.0-alpha.5", | ||
"@jest/transform": "^28.0.0-alpha.5", | ||
"@jest/types": "^28.0.0-alpha.5", | ||
"@jest/expect-utils": "^28.0.0-alpha.6", | ||
"@jest/transform": "^28.0.0-alpha.6", | ||
"@jest/types": "^28.0.0-alpha.6", | ||
"@types/babel__traverse": "^7.0.4", | ||
@@ -33,12 +33,12 @@ "@types/prettier": "^2.1.5", | ||
"chalk": "^4.0.0", | ||
"expect": "^28.0.0-alpha.5", | ||
"expect": "^28.0.0-alpha.6", | ||
"graceful-fs": "^4.2.9", | ||
"jest-diff": "^28.0.0-alpha.5", | ||
"jest-diff": "^28.0.0-alpha.6", | ||
"jest-get-type": "^28.0.0-alpha.3", | ||
"jest-haste-map": "^28.0.0-alpha.5", | ||
"jest-matcher-utils": "^28.0.0-alpha.5", | ||
"jest-message-util": "^28.0.0-alpha.5", | ||
"jest-util": "^28.0.0-alpha.5", | ||
"jest-haste-map": "^28.0.0-alpha.6", | ||
"jest-matcher-utils": "^28.0.0-alpha.6", | ||
"jest-message-util": "^28.0.0-alpha.6", | ||
"jest-util": "^28.0.0-alpha.6", | ||
"natural-compare": "^1.4.0", | ||
"pretty-format": "^28.0.0-alpha.5", | ||
"pretty-format": "^28.0.0-alpha.6", | ||
"semver": "^7.3.2" | ||
@@ -49,3 +49,3 @@ }, | ||
"@babel/preset-react": "^7.7.2", | ||
"@jest/test-utils": "^28.0.0-alpha.5", | ||
"@jest/test-utils": "^28.0.0-alpha.6", | ||
"@types/graceful-fs": "^4.1.3", | ||
@@ -64,3 +64,3 @@ "@types/natural-compare": "^1.4.0", | ||
}, | ||
"gitHead": "46fb19b2628bd87676c10730ba19592c30b05478" | ||
"gitHead": "6284ada4adb7008f5f8673b1a7b1c789d2e508fb" | ||
} |
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
81305
2365
Updated@jest/types@^28.0.0-alpha.6
Updatedexpect@^28.0.0-alpha.6
Updatedjest-diff@^28.0.0-alpha.6
Updatedjest-util@^28.0.0-alpha.6