Updating NPM dependencies
This commit is contained in:
181
node_modules/jest-snapshot/build/utils.js
generated
vendored
181
node_modules/jest-snapshot/build/utils.js
generated
vendored
@@ -3,18 +3,16 @@
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.deepMerge = exports.saveSnapshotFile = exports.ensureDirectoryExists = exports.escapeBacktickString = exports.unescape = exports.serialize = exports.getSnapshotData = exports.keyToTestName = exports.testNameToKey = exports.SNAPSHOT_VERSION_WARNING = exports.SNAPSHOT_GUIDE_LINK = exports.SNAPSHOT_VERSION = void 0;
|
||||
exports.deepMerge = exports.saveSnapshotFile = exports.ensureDirectoryExists = exports.escapeBacktickString = exports.deserializeString = exports.minify = exports.serialize = exports.removeLinesBeforeExternalMatcherTrap = exports.removeExtraLineBreaks = exports.addExtraLineBreaks = exports.getSnapshotData = exports.keyToTestName = exports.testNameToKey = exports.SNAPSHOT_VERSION_WARNING = exports.SNAPSHOT_GUIDE_LINK = exports.SNAPSHOT_VERSION = void 0;
|
||||
|
||||
var _fs = _interopRequireDefault(require('fs'));
|
||||
|
||||
var _path = _interopRequireDefault(require('path'));
|
||||
|
||||
var _mkdirp = _interopRequireDefault(require('mkdirp'));
|
||||
|
||||
var _naturalCompare = _interopRequireDefault(require('natural-compare'));
|
||||
var path = _interopRequireWildcard(require('path'));
|
||||
|
||||
var _chalk = _interopRequireDefault(require('chalk'));
|
||||
|
||||
var fs = _interopRequireWildcard(require('graceful-fs'));
|
||||
|
||||
var _naturalCompare = _interopRequireDefault(require('natural-compare'));
|
||||
|
||||
var _prettyFormat = _interopRequireDefault(require('pretty-format'));
|
||||
|
||||
var _plugins = require('./plugins');
|
||||
@@ -23,55 +21,58 @@ function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(
|
||||
Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
})
|
||||
);
|
||||
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];
|
||||
}
|
||||
}
|
||||
ownKeys.forEach(function(key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return obj;
|
||||
return newObj;
|
||||
}
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
var jestWriteFile =
|
||||
global[Symbol.for('jest-native-write-file')] || _fs.default.writeFileSync;
|
||||
|
||||
global[Symbol.for('jest-native-write-file')] || fs.writeFileSync;
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
|
||||
var jestReadFile =
|
||||
global[Symbol.for('jest-native-read-file')] || _fs.default.readFileSync;
|
||||
|
||||
global[Symbol.for('jest-native-read-file')] || fs.readFileSync;
|
||||
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;
|
||||
const SNAPSHOT_VERSION = '1';
|
||||
exports.SNAPSHOT_VERSION = SNAPSHOT_VERSION;
|
||||
const SNAPSHOT_VERSION_REGEXP = /^\/\/ Jest Snapshot v(.+),/;
|
||||
@@ -171,7 +172,7 @@ const getSnapshotData = (snapshotPath, update) => {
|
||||
|
||||
const populate = new Function('exports', snapshotContents);
|
||||
populate(data);
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const validationResult = validateSnapshotVersion(snapshotContents);
|
||||
@@ -189,30 +190,69 @@ const getSnapshotData = (snapshotPath, update) => {
|
||||
data,
|
||||
dirty
|
||||
};
|
||||
}; // Extra line breaks at the beginning and at the end of the snapshot are useful
|
||||
// to make the content of the snapshot easier to read
|
||||
}; // Add extra line breaks at beginning and end of multiline snapshot
|
||||
// to make the content easier to read.
|
||||
|
||||
exports.getSnapshotData = getSnapshotData;
|
||||
|
||||
const addExtraLineBreaks = string =>
|
||||
string.includes('\n') ? `\n${string}\n` : string;
|
||||
string.includes('\n') ? `\n${string}\n` : string; // Remove extra line breaks at beginning and end of multiline snapshot.
|
||||
// Instead of trim, which can remove additional newlines or spaces
|
||||
// at beginning or end of the content from a custom serializer.
|
||||
|
||||
const serialize = data =>
|
||||
addExtraLineBreaks(
|
||||
normalizeNewlines(
|
||||
(0, _prettyFormat.default)(data, {
|
||||
escapeRegex: true,
|
||||
plugins: (0, _plugins.getSerializers)(),
|
||||
printFunctionName: false
|
||||
})
|
||||
)
|
||||
); // unescape double quotes
|
||||
exports.addExtraLineBreaks = addExtraLineBreaks;
|
||||
|
||||
const removeExtraLineBreaks = string =>
|
||||
string.length > 2 && string.startsWith('\n') && string.endsWith('\n')
|
||||
? string.slice(1, -1)
|
||||
: string;
|
||||
|
||||
exports.removeExtraLineBreaks = removeExtraLineBreaks;
|
||||
|
||||
const removeLinesBeforeExternalMatcherTrap = stack => {
|
||||
const lines = stack.split('\n');
|
||||
|
||||
for (let i = 0; i < lines.length; i += 1) {
|
||||
// It's a function name specified in `packages/expect/src/index.ts`
|
||||
// for external custom matchers.
|
||||
if (lines[i].includes('__EXTERNAL_MATCHER_TRAP__')) {
|
||||
return lines.slice(i + 1).join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
};
|
||||
|
||||
exports.removeLinesBeforeExternalMatcherTrap = removeLinesBeforeExternalMatcherTrap;
|
||||
const escapeRegex = true;
|
||||
const printFunctionName = false;
|
||||
|
||||
const serialize = (val, indent = 2) =>
|
||||
normalizeNewlines(
|
||||
(0, _prettyFormat.default)(val, {
|
||||
escapeRegex,
|
||||
indent,
|
||||
plugins: (0, _plugins.getSerializers)(),
|
||||
printFunctionName
|
||||
})
|
||||
);
|
||||
|
||||
exports.serialize = serialize;
|
||||
|
||||
const unescape = data => data.replace(/\\(")/g, '$1');
|
||||
const minify = val =>
|
||||
(0, _prettyFormat.default)(val, {
|
||||
escapeRegex,
|
||||
min: true,
|
||||
plugins: (0, _plugins.getSerializers)(),
|
||||
printFunctionName
|
||||
}); // Remove double quote marks and unescape double quotes and backslashes.
|
||||
|
||||
exports.unescape = unescape;
|
||||
exports.minify = minify;
|
||||
|
||||
const deserializeString = stringified =>
|
||||
stringified.slice(1, -1).replace(/\\("|\\)/g, '$1');
|
||||
|
||||
exports.deserializeString = deserializeString;
|
||||
|
||||
const escapeBacktickString = str => str.replace(/`|\\|\${/g, '\\$&');
|
||||
|
||||
@@ -222,11 +262,10 @@ const printBacktickString = str => '`' + escapeBacktickString(str) + '`';
|
||||
|
||||
const ensureDirectoryExists = filePath => {
|
||||
try {
|
||||
_mkdirp.default.sync(
|
||||
_path.default.join(_path.default.dirname(filePath)),
|
||||
'777'
|
||||
);
|
||||
} catch (e) {}
|
||||
fs.mkdirSync(path.join(path.dirname(filePath)), {
|
||||
recursive: true
|
||||
});
|
||||
} catch {}
|
||||
};
|
||||
|
||||
exports.ensureDirectoryExists = ensureDirectoryExists;
|
||||
@@ -268,12 +307,11 @@ const deepMergeArray = (target, source) => {
|
||||
}
|
||||
});
|
||||
return mergedOutput;
|
||||
};
|
||||
}; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
|
||||
const deepMerge = (target, source) => {
|
||||
const mergedOutput = _objectSpread({}, target);
|
||||
|
||||
if (isObject(target) && isObject(source)) {
|
||||
const mergedOutput = {...target};
|
||||
Object.keys(source).forEach(key => {
|
||||
if (isObject(source[key]) && !source[key].$$typeof) {
|
||||
if (!(key in target))
|
||||
@@ -289,9 +327,12 @@ const deepMerge = (target, source) => {
|
||||
});
|
||||
}
|
||||
});
|
||||
return mergedOutput;
|
||||
} else if (Array.isArray(target) && Array.isArray(source)) {
|
||||
return deepMergeArray(target, source);
|
||||
}
|
||||
|
||||
return mergedOutput;
|
||||
return target;
|
||||
};
|
||||
|
||||
exports.deepMerge = deepMerge;
|
||||
|
||||
Reference in New Issue
Block a user