index.d.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  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. export declare class TestPathPatterns {
  8. readonly patterns: Array<string>;
  9. constructor(patterns: Array<string>);
  10. /**
  11. * Return true if there are any patterns.
  12. */
  13. isSet(): boolean;
  14. /**
  15. * Return true if the patterns are valid.
  16. */
  17. isValid(): boolean;
  18. /**
  19. * Return a human-friendly version of the pattern regex.
  20. */
  21. toPretty(): string;
  22. /**
  23. * Return a TestPathPatternsExecutor that can execute the patterns.
  24. */
  25. toExecutor(
  26. options: TestPathPatternsExecutorOptions,
  27. ): TestPathPatternsExecutor;
  28. /** For jest serializers */
  29. toJSON(): any;
  30. }
  31. export declare class TestPathPatternsExecutor {
  32. readonly patterns: TestPathPatterns;
  33. private readonly options;
  34. constructor(
  35. patterns: TestPathPatterns,
  36. options: TestPathPatternsExecutorOptions,
  37. );
  38. private toRegex;
  39. /**
  40. * Return true if there are any patterns.
  41. */
  42. isSet(): boolean;
  43. /**
  44. * Return true if the patterns are valid.
  45. */
  46. isValid(): boolean;
  47. /**
  48. * Return true if the given ABSOLUTE path matches the patterns.
  49. *
  50. * Throws an error if the patterns form an invalid regex (see `validate`).
  51. */
  52. isMatch(absPath: string): boolean;
  53. /**
  54. * Return a human-friendly version of the pattern regex.
  55. */
  56. toPretty(): string;
  57. }
  58. export declare type TestPathPatternsExecutorOptions = {
  59. rootDir: string;
  60. };
  61. export {};