utils.d.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. declare type ResolveOptions = {
  9. rootDir: Config.Path;
  10. key: string;
  11. filePath: Config.Path;
  12. optional?: boolean;
  13. };
  14. export declare const BULLET: string;
  15. export declare const DOCUMENTATION_NOTE: string;
  16. export declare const resolve: (resolver: string | null | undefined, { key, filePath, rootDir, optional }: ResolveOptions) => string;
  17. export declare const escapeGlobCharacters: (path: Config.Path) => Config.Glob;
  18. export declare const replaceRootDirInPath: (rootDir: Config.Path, filePath: Config.Path) => string;
  19. declare type OrArray<T> = T | Array<T>;
  20. declare type ReplaceRootDirConfigObj = Record<string, Config.Path>;
  21. declare type ReplaceRootDirConfigValues = OrArray<ReplaceRootDirConfigObj> | OrArray<RegExp> | OrArray<Config.Path>;
  22. export declare const _replaceRootDirTags: <T extends ReplaceRootDirConfigValues>(rootDir: Config.Path, config: T) => T;
  23. export declare const resolveWithPrefix: (resolver: string | undefined | null, { filePath, humanOptionName, optionName, prefix, rootDir, }: {
  24. filePath: string;
  25. humanOptionName: string;
  26. optionName: string;
  27. prefix: string;
  28. rootDir: Config.Path;
  29. }) => string;
  30. /**
  31. * Finds the test environment to use:
  32. *
  33. * 1. looks for jest-environment-<name> relative to project.
  34. * 1. looks for jest-environment-<name> relative to Jest.
  35. * 1. looks for <name> relative to project.
  36. * 1. looks for <name> relative to Jest.
  37. */
  38. export declare const getTestEnvironment: ({ rootDir, testEnvironment: filePath, }: {
  39. rootDir: Config.Path;
  40. testEnvironment: string;
  41. }) => string;
  42. /**
  43. * Finds the watch plugins to use:
  44. *
  45. * 1. looks for jest-watch-<name> relative to project.
  46. * 1. looks for jest-watch-<name> relative to Jest.
  47. * 1. looks for <name> relative to project.
  48. * 1. looks for <name> relative to Jest.
  49. */
  50. export declare const getWatchPlugin: (resolver: string | undefined | null, { filePath, rootDir }: {
  51. filePath: string;
  52. rootDir: Config.Path;
  53. }) => string;
  54. /**
  55. * Finds the runner to use:
  56. *
  57. * 1. looks for jest-runner-<name> relative to project.
  58. * 1. looks for jest-runner-<name> relative to Jest.
  59. * 1. looks for <name> relative to project.
  60. * 1. looks for <name> relative to Jest.
  61. */
  62. export declare const getRunner: (resolver: string | undefined | null, { filePath, rootDir }: {
  63. filePath: string;
  64. rootDir: Config.Path;
  65. }) => string;
  66. declare type JSONString = string & {
  67. readonly $$type: never;
  68. };
  69. export declare const isJSONString: (text?: string | JSONString | undefined) => text is JSONString;
  70. export declare const getSequencer: (resolver: string | undefined | null, { filePath, rootDir }: {
  71. filePath: string;
  72. rootDir: Config.Path;
  73. }) => string;
  74. export {};