SearchSource.d.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. import type { Config } from '@jest/types';
  8. import type { ChangedFiles } from 'jest-changed-files';
  9. import type { Test } from 'jest-runner';
  10. import type { Context } from 'jest-runtime';
  11. import type { Filter, Stats } from './types';
  12. export declare type SearchResult = {
  13. noSCM?: boolean;
  14. stats?: Stats;
  15. collectCoverageFrom?: Set<string>;
  16. tests: Array<Test>;
  17. total?: number;
  18. };
  19. export declare type TestSelectionConfig = {
  20. input?: string;
  21. findRelatedTests?: boolean;
  22. onlyChanged?: boolean;
  23. paths?: Array<Config.Path>;
  24. shouldTreatInputAsPattern?: boolean;
  25. testPathPattern?: string;
  26. watch?: boolean;
  27. };
  28. export default class SearchSource {
  29. private _context;
  30. private _dependencyResolver;
  31. private _testPathCases;
  32. constructor(context: Context);
  33. private _getOrBuildDependencyResolver;
  34. private _filterTestPathsWithStats;
  35. private _getAllTestPaths;
  36. isTestFilePath(path: Config.Path): boolean;
  37. findMatchingTests(testPathPattern?: string): SearchResult;
  38. findRelatedTests(allPaths: Set<Config.Path>, collectCoverage: boolean): SearchResult;
  39. findTestsByPaths(paths: Array<Config.Path>): SearchResult;
  40. findRelatedTestsFromPattern(paths: Array<Config.Path>, collectCoverage: boolean): SearchResult;
  41. findTestRelatedToChangedFiles(changedFilesInfo: ChangedFiles, collectCoverage: boolean): SearchResult;
  42. private _getTestPaths;
  43. getTestPaths(globalConfig: Config.GlobalConfig, changedFiles: ChangedFiles | undefined, filter?: Filter): Promise<SearchResult>;
  44. findRelatedSourcesFromTestsInChangedFiles(changedFilesInfo: ChangedFiles): Array<string>;
  45. }