Updating NPM dependencies
This commit is contained in:
95
node_modules/jest-snapshot/build/State.js
generated
vendored
95
node_modules/jest-snapshot/build/State.js
generated
vendored
@@ -5,23 +5,60 @@ Object.defineProperty(exports, '__esModule', {
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _fs = _interopRequireDefault(require('fs'));
|
||||
var fs = _interopRequireWildcard(require('graceful-fs'));
|
||||
|
||||
var _jestMessageUtil = require('jest-message-util');
|
||||
|
||||
var _InlineSnapshots = require('./InlineSnapshots');
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
var _inline_snapshots = require('./inline_snapshots');
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
|
||||
var jestExistsFile =
|
||||
global[Symbol.for('jest-native-exists-file')] || _fs.default.existsSync;
|
||||
global[Symbol.for('jest-native-exists-file')] || fs.existsSync;
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
@@ -38,7 +75,7 @@ function _defineProperty(obj, key, value) {
|
||||
}
|
||||
|
||||
class SnapshotState {
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
constructor(snapshotPath, options) {
|
||||
_defineProperty(this, '_counters', void 0);
|
||||
|
||||
@@ -73,14 +110,10 @@ class SnapshotState {
|
||||
_defineProperty(this, 'updated', void 0);
|
||||
|
||||
this._snapshotPath = snapshotPath;
|
||||
|
||||
const _getSnapshotData = (0, _utils.getSnapshotData)(
|
||||
this._snapshotPath,
|
||||
options.updateSnapshot
|
||||
),
|
||||
data = _getSnapshotData.data,
|
||||
dirty = _getSnapshotData.dirty;
|
||||
|
||||
const {data, dirty} = (0, _utils.getSnapshotData)(
|
||||
this._snapshotPath,
|
||||
options.updateSnapshot
|
||||
);
|
||||
this._initialData = data;
|
||||
this._snapshotData = data;
|
||||
this._dirty = dirty;
|
||||
@@ -111,7 +144,9 @@ class SnapshotState {
|
||||
|
||||
if (options.isInline) {
|
||||
const error = options.error || new Error();
|
||||
const lines = (0, _jestMessageUtil.getStackTraceLines)(error.stack || '');
|
||||
const lines = (0, _jestMessageUtil.getStackTraceLines)(
|
||||
(0, _utils.removeLinesBeforeExternalMatcherTrap)(error.stack || '')
|
||||
);
|
||||
const frame = (0, _jestMessageUtil.getTopFrame)(lines);
|
||||
|
||||
if (!frame) {
|
||||
@@ -159,7 +194,7 @@ class SnapshotState {
|
||||
|
||||
const babelTraverse = this._getBabelTraverse(); // Load lazily
|
||||
|
||||
(0, _inline_snapshots.saveInlineSnapshots)(
|
||||
(0, _InlineSnapshots.saveInlineSnapshots)(
|
||||
this._inlineSnapshots,
|
||||
prettier,
|
||||
babelTraverse
|
||||
@@ -169,7 +204,7 @@ class SnapshotState {
|
||||
status.saved = true;
|
||||
} else if (!hasExternalSnapshots && jestExistsFile(this._snapshotPath)) {
|
||||
if (this._updateSnapshot === 'all') {
|
||||
_fs.default.unlinkSync(this._snapshotPath);
|
||||
fs.unlinkSync(this._snapshotPath);
|
||||
}
|
||||
|
||||
status.deleted = true;
|
||||
@@ -196,11 +231,10 @@ class SnapshotState {
|
||||
}
|
||||
}
|
||||
|
||||
match({testName, received, key, inlineSnapshot, error}) {
|
||||
match({testName, received, key, inlineSnapshot, isInline, error}) {
|
||||
this._counters.set(testName, (this._counters.get(testName) || 0) + 1);
|
||||
|
||||
const count = Number(this._counters.get(testName));
|
||||
const isInline = inlineSnapshot !== undefined;
|
||||
|
||||
if (!key) {
|
||||
key = (0, _utils.testNameToKey)(testName, count);
|
||||
@@ -208,19 +242,17 @@ class SnapshotState {
|
||||
// there's an external snapshot. This way the external snapshot can be
|
||||
// removed with `--updateSnapshot`.
|
||||
|
||||
if (!(isInline && this._snapshotData[key])) {
|
||||
if (!(isInline && this._snapshotData[key] !== undefined)) {
|
||||
this._uncheckedKeys.delete(key);
|
||||
}
|
||||
|
||||
const receivedSerialized = (0, _utils.serialize)(received);
|
||||
const receivedSerialized = (0, _utils.addExtraLineBreaks)(
|
||||
(0, _utils.serialize)(received)
|
||||
);
|
||||
const expected = isInline ? inlineSnapshot : this._snapshotData[key];
|
||||
const pass = expected === receivedSerialized;
|
||||
const hasSnapshot = isInline
|
||||
? inlineSnapshot !== ''
|
||||
: this._snapshotData[key] !== undefined;
|
||||
|
||||
const snapshotIsPersisted =
|
||||
isInline || _fs.default.existsSync(this._snapshotPath);
|
||||
const hasSnapshot = expected !== undefined;
|
||||
const snapshotIsPersisted = isInline || fs.existsSync(this._snapshotPath);
|
||||
|
||||
if (pass && !isInline) {
|
||||
// Executing a snapshot file as JavaScript and writing the strings back
|
||||
@@ -278,9 +310,12 @@ class SnapshotState {
|
||||
if (!pass) {
|
||||
this.unmatched++;
|
||||
return {
|
||||
actual: (0, _utils.unescape)(receivedSerialized),
|
||||
actual: (0, _utils.removeExtraLineBreaks)(receivedSerialized),
|
||||
count,
|
||||
expected: expected ? (0, _utils.unescape)(expected) : null,
|
||||
expected:
|
||||
expected !== undefined
|
||||
? (0, _utils.removeExtraLineBreaks)(expected)
|
||||
: undefined,
|
||||
key,
|
||||
pass: false
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user