Updating NPM dependencies
This commit is contained in:
355
node_modules/@jest/core/build/SearchSource.js
generated
vendored
355
node_modules/@jest/core/build/SearchSource.js
generated
vendored
@@ -5,10 +5,20 @@ Object.defineProperty(exports, '__esModule', {
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
function os() {
|
||||
const data = _interopRequireWildcard(require('os'));
|
||||
|
||||
_path = function _path() {
|
||||
os = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -18,27 +28,7 @@ function _path() {
|
||||
function _micromatch() {
|
||||
const data = _interopRequireDefault(require('micromatch'));
|
||||
|
||||
_micromatch = function _micromatch() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestResolveDependencies() {
|
||||
const data = _interopRequireDefault(require('jest-resolve-dependencies'));
|
||||
|
||||
_jestResolveDependencies = function _jestResolveDependencies() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestRegexUtil() {
|
||||
const data = require('jest-regex-util');
|
||||
|
||||
_jestRegexUtil = function _jestRegexUtil() {
|
||||
_micromatch = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -48,7 +38,27 @@ function _jestRegexUtil() {
|
||||
function _jestConfig() {
|
||||
const data = require('jest-config');
|
||||
|
||||
_jestConfig = function _jestConfig() {
|
||||
_jestConfig = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestRegexUtil() {
|
||||
const data = require('jest-regex-util');
|
||||
|
||||
_jestRegexUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestResolveDependencies() {
|
||||
const data = _interopRequireDefault(require('jest-resolve-dependencies'));
|
||||
|
||||
_jestResolveDependencies = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -58,7 +68,7 @@ function _jestConfig() {
|
||||
function _jestSnapshot() {
|
||||
const data = require('jest-snapshot');
|
||||
|
||||
_jestSnapshot = function _jestSnapshot() {
|
||||
_jestSnapshot = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -68,7 +78,7 @@ function _jestSnapshot() {
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function _jestUtil() {
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -79,54 +89,46 @@ function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
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;
|
||||
})
|
||||
);
|
||||
}
|
||||
ownKeys.forEach(function(key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
|
||||
function _asyncToGenerator(fn) {
|
||||
return function() {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
@@ -143,17 +145,16 @@ function _defineProperty(obj, key, value) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
const globsToMatcher = globs => path =>
|
||||
_micromatch().default.some(
|
||||
(0, _jestUtil().replacePathSepForGlob)(path),
|
||||
globs,
|
||||
{
|
||||
dot: true
|
||||
}
|
||||
);
|
||||
const regexToMatcher = testRegex => {
|
||||
const regexes = testRegex.map(testRegex => new RegExp(testRegex));
|
||||
return path =>
|
||||
regexes.some(regex => {
|
||||
const result = regex.test(path); // prevent stateful regexes from breaking, just in case
|
||||
|
||||
const regexToMatcher = testRegex => path =>
|
||||
testRegex.some(testRegex => new RegExp(testRegex).test(path));
|
||||
regex.lastIndex = 0;
|
||||
return result;
|
||||
});
|
||||
};
|
||||
|
||||
const toTests = (context, tests) =>
|
||||
tests.map(path => ({
|
||||
@@ -162,19 +163,27 @@ const toTests = (context, tests) =>
|
||||
path
|
||||
}));
|
||||
|
||||
const hasSCM = changedFilesInfo => {
|
||||
const {repos} = changedFilesInfo; // no SCM (git/hg/...) is found in any of the roots.
|
||||
|
||||
const noSCM = Object.values(repos).every(scm => scm.size === 0);
|
||||
return !noSCM;
|
||||
};
|
||||
|
||||
class SearchSource {
|
||||
constructor(context) {
|
||||
_defineProperty(this, '_context', void 0);
|
||||
|
||||
_defineProperty(this, '_dependencyResolver', void 0);
|
||||
|
||||
_defineProperty(this, '_testPathCases', []);
|
||||
|
||||
const config = context.config;
|
||||
const {config} = context;
|
||||
this._context = context;
|
||||
this._dependencyResolver = null;
|
||||
const rootPattern = new RegExp(
|
||||
config.roots
|
||||
.map(dir =>
|
||||
(0, _jestRegexUtil().escapePathForRegex)(dir + _path().default.sep)
|
||||
)
|
||||
.map(dir => (0, _jestRegexUtil().escapePathForRegex)(dir + path().sep))
|
||||
.join('|')
|
||||
);
|
||||
|
||||
@@ -185,7 +194,7 @@ class SearchSource {
|
||||
|
||||
if (config.testMatch.length) {
|
||||
this._testPathCases.push({
|
||||
isMatch: globsToMatcher(config.testMatch),
|
||||
isMatch: (0, _jestUtil().globsToMatcher)(config.testMatch),
|
||||
stat: 'testMatch'
|
||||
});
|
||||
}
|
||||
@@ -209,6 +218,18 @@ class SearchSource {
|
||||
}
|
||||
}
|
||||
|
||||
_getOrBuildDependencyResolver() {
|
||||
if (!this._dependencyResolver) {
|
||||
this._dependencyResolver = new (_jestResolveDependencies().default)(
|
||||
this._context.resolver,
|
||||
this._context.hasteFS,
|
||||
(0, _jestSnapshot().buildSnapshotResolver)(this._context.config)
|
||||
);
|
||||
}
|
||||
|
||||
return this._dependencyResolver;
|
||||
}
|
||||
|
||||
_filterTestPathsWithStats(allPaths, testPathPattern) {
|
||||
const data = {
|
||||
stats: {
|
||||
@@ -234,11 +255,7 @@ class SearchSource {
|
||||
data.tests = allPaths.filter(test => {
|
||||
let filterResult = true;
|
||||
|
||||
for (var _i = 0; _i < testCases.length; _i++) {
|
||||
const _testCases$_i = testCases[_i],
|
||||
isMatch = _testCases$_i.isMatch,
|
||||
stat = _testCases$_i.stat;
|
||||
|
||||
for (const {isMatch, stat} of testCases) {
|
||||
if (isMatch(test.path)) {
|
||||
data.stats[stat]++;
|
||||
} else {
|
||||
@@ -267,11 +284,7 @@ class SearchSource {
|
||||
}
|
||||
|
||||
findRelatedTests(allPaths, collectCoverage) {
|
||||
const dependencyResolver = new (_jestResolveDependencies()).default(
|
||||
this._context.resolver,
|
||||
this._context.hasteFS,
|
||||
(0, _jestSnapshot().buildSnapshotResolver)(this._context.config)
|
||||
);
|
||||
const dependencyResolver = this._getOrBuildDependencyResolver();
|
||||
|
||||
if (!collectCoverage) {
|
||||
return {
|
||||
@@ -295,27 +308,28 @@ class SearchSource {
|
||||
skipNodeResolution: this._context.config.skipNodeResolution
|
||||
}
|
||||
);
|
||||
const allPathsAbsolute = Array.from(allPaths).map(p =>
|
||||
_path().default.resolve(p)
|
||||
);
|
||||
const allPathsAbsolute = Array.from(allPaths).map(p => path().resolve(p));
|
||||
const collectCoverageFrom = new Set();
|
||||
testModulesMap.forEach(testModule => {
|
||||
if (!testModule.dependencies) {
|
||||
return;
|
||||
}
|
||||
|
||||
testModule.dependencies
|
||||
.filter(p => allPathsAbsolute.includes(p))
|
||||
.map(filename => {
|
||||
filename = (0, _jestConfig().replaceRootDirInPath)(
|
||||
this._context.config.rootDir,
|
||||
filename
|
||||
);
|
||||
return _path().default.isAbsolute(filename)
|
||||
? _path().default.relative(this._context.config.rootDir, filename)
|
||||
: filename;
|
||||
})
|
||||
.forEach(filename => collectCoverageFrom.add(filename));
|
||||
testModule.dependencies.forEach(p => {
|
||||
if (!allPathsAbsolute.includes(p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const filename = (0, _jestConfig().replaceRootDirInPath)(
|
||||
this._context.config.rootDir,
|
||||
p
|
||||
);
|
||||
collectCoverageFrom.add(
|
||||
path().isAbsolute(filename)
|
||||
? path().relative(this._context.config.rootDir, filename)
|
||||
: filename
|
||||
);
|
||||
});
|
||||
});
|
||||
return {
|
||||
collectCoverageFrom,
|
||||
@@ -331,7 +345,7 @@ class SearchSource {
|
||||
tests: toTests(
|
||||
this._context,
|
||||
paths
|
||||
.map(p => _path().default.resolve(this._context.config.cwd, p))
|
||||
.map(p => path().resolve(this._context.config.cwd, p))
|
||||
.filter(this.isTestFilePath.bind(this))
|
||||
)
|
||||
};
|
||||
@@ -340,7 +354,7 @@ class SearchSource {
|
||||
findRelatedTestsFromPattern(paths, collectCoverage) {
|
||||
if (Array.isArray(paths) && paths.length) {
|
||||
const resolvedPaths = paths.map(p =>
|
||||
_path().default.resolve(this._context.config.cwd, p)
|
||||
path().resolve(this._context.config.cwd, p)
|
||||
);
|
||||
return this.findRelatedTests(new Set(resolvedPaths), collectCoverage);
|
||||
}
|
||||
@@ -351,21 +365,18 @@ class SearchSource {
|
||||
}
|
||||
|
||||
findTestRelatedToChangedFiles(changedFilesInfo, collectCoverage) {
|
||||
const repos = changedFilesInfo.repos,
|
||||
changedFiles = changedFilesInfo.changedFiles; // no SCM (git/hg/...) is found in any of the roots.
|
||||
if (!hasSCM(changedFilesInfo)) {
|
||||
return {
|
||||
noSCM: true,
|
||||
tests: []
|
||||
};
|
||||
}
|
||||
|
||||
const noSCM = Object.keys(repos).every(scm => repos[scm].size === 0);
|
||||
return noSCM
|
||||
? {
|
||||
noSCM: true,
|
||||
tests: []
|
||||
}
|
||||
: this.findRelatedTests(changedFiles, collectCoverage);
|
||||
const {changedFiles} = changedFilesInfo;
|
||||
return this.findRelatedTests(changedFiles, collectCoverage);
|
||||
}
|
||||
|
||||
_getTestPaths(globalConfig, changedFiles) {
|
||||
const paths = globalConfig.nonFlagArgs;
|
||||
|
||||
if (globalConfig.onlyChanged) {
|
||||
if (!changedFiles) {
|
||||
throw new Error('Changed files must be set when running with -o.');
|
||||
@@ -375,7 +386,33 @@ class SearchSource {
|
||||
changedFiles,
|
||||
globalConfig.collectCoverage
|
||||
);
|
||||
} else if (globalConfig.runTestsByPath && paths && paths.length) {
|
||||
}
|
||||
|
||||
let paths = globalConfig.nonFlagArgs;
|
||||
|
||||
if (globalConfig.findRelatedTests && 'win32' === os().platform()) {
|
||||
const allFiles = this._context.hasteFS.getAllFiles();
|
||||
|
||||
const options = {
|
||||
nocase: true,
|
||||
windows: false
|
||||
};
|
||||
paths = paths
|
||||
.map(p => {
|
||||
const relativePath = path()
|
||||
.resolve(this._context.config.cwd, p)
|
||||
.replace(/\\/g, '\\\\');
|
||||
const match = (0, _micromatch().default)(
|
||||
allFiles,
|
||||
relativePath,
|
||||
options
|
||||
);
|
||||
return match[0];
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
if (globalConfig.runTestsByPath && paths && paths.length) {
|
||||
return this.findTestsByPaths(paths);
|
||||
} else if (globalConfig.findRelatedTests && paths && paths.length) {
|
||||
return this.findRelatedTestsFromPattern(
|
||||
@@ -391,34 +428,52 @@ class SearchSource {
|
||||
}
|
||||
}
|
||||
|
||||
getTestPaths(globalConfig, changedFiles, filter) {
|
||||
var _this = this;
|
||||
async getTestPaths(globalConfig, changedFiles, filter) {
|
||||
const searchResult = this._getTestPaths(globalConfig, changedFiles);
|
||||
|
||||
return _asyncToGenerator(function*() {
|
||||
const searchResult = _this._getTestPaths(globalConfig, changedFiles);
|
||||
const filterPath = globalConfig.filter;
|
||||
|
||||
const filterPath = globalConfig.filter;
|
||||
if (filter) {
|
||||
const tests = searchResult.tests;
|
||||
const filterResult = await filter(tests.map(test => test.path));
|
||||
|
||||
if (filter) {
|
||||
const tests = searchResult.tests;
|
||||
const filterResult = yield filter(tests.map(test => test.path));
|
||||
|
||||
if (!Array.isArray(filterResult.filtered)) {
|
||||
throw new Error(
|
||||
`Filter ${filterPath} did not return a valid test list`
|
||||
);
|
||||
}
|
||||
|
||||
const filteredSet = new Set(
|
||||
filterResult.filtered.map(result => result.test)
|
||||
if (!Array.isArray(filterResult.filtered)) {
|
||||
throw new Error(
|
||||
`Filter ${filterPath} did not return a valid test list`
|
||||
);
|
||||
return _objectSpread({}, searchResult, {
|
||||
tests: tests.filter(test => filteredSet.has(test.path))
|
||||
});
|
||||
}
|
||||
|
||||
return searchResult;
|
||||
})();
|
||||
const filteredSet = new Set(
|
||||
filterResult.filtered.map(result => result.test)
|
||||
);
|
||||
return {
|
||||
...searchResult,
|
||||
tests: tests.filter(test => filteredSet.has(test.path))
|
||||
};
|
||||
}
|
||||
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
findRelatedSourcesFromTestsInChangedFiles(changedFilesInfo) {
|
||||
if (!hasSCM(changedFilesInfo)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const {changedFiles} = changedFilesInfo;
|
||||
|
||||
const dependencyResolver = this._getOrBuildDependencyResolver();
|
||||
|
||||
const relatedSourcesSet = new Set();
|
||||
changedFiles.forEach(filePath => {
|
||||
if (this.isTestFilePath(filePath)) {
|
||||
const sourcePaths = dependencyResolver.resolve(filePath, {
|
||||
skipNodeResolution: this._context.config.skipNodeResolution
|
||||
});
|
||||
sourcePaths.forEach(sourcePath => relatedSourcesSet.add(sourcePath));
|
||||
}
|
||||
});
|
||||
return Array.from(relatedSourcesSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user