當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript jest-util.replacePathSepForGlob函數代碼示例

本文整理匯總了TypeScript中jest-util.replacePathSepForGlob函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript replacePathSepForGlob函數的具體用法?TypeScript replacePathSepForGlob怎麽用?TypeScript replacePathSepForGlob使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了replacePathSepForGlob函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: replacePathSepForGlob

 collectCoverageFrom = collectCoverageFrom.reduce((patterns, filename) => {
   if (
     !micromatch.some(
       replacePathSepForGlob(path.relative(options.rootDir, filename)),
       newOptions.collectCoverageFrom!,
     )
   ) {
     return patterns;
   }
   return [...patterns, filename];
 }, newOptions.collectCoverageFrom);
開發者ID:Volune,項目名稱:jest,代碼行數:11,代碼來源:normalize.ts

示例2: matchFilesWithGlob

 matchFilesWithGlob(
   globs: Array<Config.Glob>,
   root: Config.Path | null,
 ): Set<Config.Path> {
   const files = new Set();
   for (const file of this.getAbsoluteFileIterator()) {
     const filePath = root ? fastPath.relative(root, file) : file;
     if (micromatch.some(replacePathSepForGlob(filePath), globs)) {
       files.add(file);
     }
   }
   return files;
 }
開發者ID:Volune,項目名稱:jest,代碼行數:13,代碼來源:HasteFS.ts

示例3: switch


//.........這裏部分代碼省略.........
            key: 'haste.hasteImplModulePath',
            rootDir: options.rootDir,
          });

          value.hasteImplModulePath = resolvedHasteImpl || undefined;
        }
        break;
      case 'projects':
        value = (oldOptions[key] || [])
          .map(project =>
            typeof project === 'string'
              ? _replaceRootDirTags(options.rootDir, project)
              : project,
          )
          .reduce((projects, project) => {
            // Project can be specified as globs. If a glob matches any files,
            // We expand it to these paths. If not, we keep the original path
            // for the future resolution.
            const globMatches =
              typeof project === 'string' ? glob.sync(project) : [];
            return projects.concat(globMatches.length ? globMatches : project);
          }, []);
        break;
      case 'moduleDirectories':
      case 'testMatch':
        {
          const replacedRootDirTags = _replaceRootDirTags(
            escapeGlobCharacters(options.rootDir),
            oldOptions[key],
          );

          if (replacedRootDirTags) {
            value = Array.isArray(replacedRootDirTags)
              ? replacedRootDirTags.map(replacePathSepForGlob)
              : replacePathSepForGlob(replacedRootDirTags);
          } else {
            value = replacedRootDirTags;
          }
        }
        break;
      case 'testRegex':
        {
          const option = oldOptions[key];
          value = option
            ? (Array.isArray(option) ? option : [option]).map(
                replacePathSepForRegex,
              )
            : [];
        }
        break;
      case 'moduleFileExtensions': {
        value = oldOptions[key];

        if (
          Array.isArray(value) && // If it's the wrong type, it can throw at a later time
          (options.runner === undefined ||
            options.runner === DEFAULT_CONFIG.runner) && // Only require 'js' for the default jest-runner
          !value.includes('js')
        ) {
          const errorMessage =
            `  moduleFileExtensions must include 'js':\n` +
            `  but instead received:\n` +
            `    ${chalk.bold.red(JSON.stringify(value))}`;

          // If `js` is not included, any dependency Jest itself injects into
          // the environment, like jasmine or sourcemap-support, will need to
開發者ID:Volune,項目名稱:jest,代碼行數:67,代碼來源:normalize.ts

示例4: return

 return (path: Config.Path) =>
   micromatch.some(replacePathSepForGlob(path), globs, {dot: true});
開發者ID:Volune,項目名稱:jest,代碼行數:2,代碼來源:SearchSource.ts

示例5: shouldInstrument

export default function shouldInstrument(
  filename: Config.Path,
  options: ShouldInstrumentOptions,
  config: Config.ProjectConfig,
): boolean {
  if (!options.collectCoverage) {
    return false;
  }

  if (
    config.forceCoverageMatch.length &&
    micromatch.any(filename, config.forceCoverageMatch)
  ) {
    return true;
  }

  if (
    !config.testPathIgnorePatterns.some(pattern => !!filename.match(pattern))
  ) {
    if (config.testRegex.some(regex => new RegExp(regex).test(filename))) {
      return false;
    }

    if (micromatch.some(replacePathSepForGlob(filename), config.testMatch)) {
      return false;
    }
  }

  if (
    // This configuration field contains an object in the form of:
    // {'path/to/file.js': true}
    options.collectCoverageOnlyFrom &&
    !options.collectCoverageOnlyFrom[filename]
  ) {
    return false;
  }

  if (
    // still cover if `only` is specified
    !options.collectCoverageOnlyFrom &&
    options.collectCoverageFrom &&
    !micromatch.some(
      replacePathSepForGlob(path.relative(config.rootDir, filename)),
      options.collectCoverageFrom,
    )
  ) {
    return false;
  }

  if (
    config.coveragePathIgnorePatterns.some(pattern => !!filename.match(pattern))
  ) {
    return false;
  }

  if (config.globalSetup === filename) {
    return false;
  }

  if (config.globalTeardown === filename) {
    return false;
  }

  if (config.setupFiles.some(setupFile => setupFile === filename)) {
    return false;
  }

  if (config.setupFilesAfterEnv.some(setupFile => setupFile === filename)) {
    return false;
  }

  if (MOCKS_PATTERN.test(filename)) {
    return false;
  }

  if (options.changedFiles && !options.changedFiles.has(filename)) {
    return false;
  }

  return true;
}
開發者ID:Volune,項目名稱:jest,代碼行數:81,代碼來源:shouldInstrument.ts


注:本文中的jest-util.replacePathSepForGlob函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。