Class ProjectJestConfig

Configuration of project tests utilizing Jest.

Hierarchy (view full)

Constructors

Accessors

  • get options(): Promise<Partial<{
        automock: boolean;
        bail: number | boolean;
        cache: boolean;
        cacheDirectory: string;
        changedFilesWithAncestor: boolean;
        changedSince: string;
        ci: boolean;
        clearMocks: boolean;
        collectCoverage: boolean;
        collectCoverageFrom: string[];
        coverageDirectory: string;
        coveragePathIgnorePatterns: string[];
        coverageProvider: CoverageProvider;
        coverageReporters: CoverageReporters;
        coverageThreshold: CoverageThreshold;
        dependencyExtractor: string;
        detectLeaks: boolean;
        detectOpenHandles: boolean;
        displayName: string | DisplayName;
        errorOnDeprecated: boolean;
        expand: boolean;
        extensionsToTreatAsEsm: string[];
        fakeTimers: FakeTimers;
        filter: string;
        findRelatedTests: boolean;
        forceCoverageMatch: string[];
        forceExit: boolean;
        globals: ConfigGlobals;
        globalSetup: undefined | null | string;
        globalTeardown: undefined | null | string;
        haste: HasteConfig;
        id: string;
        injectGlobals: boolean;
        json: boolean;
        lastCommit: boolean;
        listTests: boolean;
        logHeapUsage: boolean;
        maxConcurrency: number;
        maxWorkers: string | number;
        moduleDirectories: string[];
        moduleFileExtensions: string[];
        moduleNameMapper: {
            [key: string]: string | string[];
        };
        modulePathIgnorePatterns: string[];
        modulePaths: string[];
        noStackTrace: boolean;
        notify: boolean;
        notifyMode: string;
        onlyChanged: boolean;
        onlyFailures: boolean;
        openHandlesTimeout: number;
        outputFile: string;
        passWithNoTests: boolean;
        preset: undefined | null | string;
        prettierPath: undefined | null | string;
        projects: (string | InitialProjectOptions)[];
        randomize: boolean;
        replname: undefined | null | string;
        reporters: (string | ReporterConfig)[];
        resetMocks: boolean;
        resetModules: boolean;
        resolver: undefined | null | string;
        restoreMocks: boolean;
        rootDir: string;
        roots: string[];
        runner: string;
        runTestsByPath: boolean;
        runtime: string;
        sandboxInjectedGlobals: string[];
        setupFiles: string[];
        setupFilesAfterEnv: string[];
        showSeed: boolean;
        silent: boolean;
        skipFilter: boolean;
        skipNodeResolution: boolean;
        slowTestThreshold: number;
        snapshotFormat: {
            callToJSON?: boolean;
            compareKeys?: null;
            escapeRegex?: boolean;
            escapeString?: boolean;
            highlight?: boolean;
            indent?: number;
            maxDepth?: number;
            maxWidth?: number;
            min?: boolean;
            printBasicPrototype?: boolean;
            printFunctionName?: boolean;
            theme?: {
                comment?: string;
                content?: string;
                prop?: string;
                tag?: string;
                value?: string;
            };
        };
        snapshotResolver: string;
        snapshotSerializers: string[];
        testEnvironment: string;
        testEnvironmentOptions: Record<string, unknown>;
        testFailureExitCode: string | number;
        testLocationInResults: boolean;
        testMatch: string[];
        testNamePattern: string;
        testPathIgnorePatterns: string[];
        testRegex: string | string[];
        testResultsProcessor: string;
        testRunner: string;
        testSequencer: string;
        testTimeout: number;
        transform: {
            [regex: string]: string | TransformerConfig;
        };
        transformIgnorePatterns: string[];
        unmockedModulePathPatterns: string[];
        updateSnapshot: boolean;
        useStderr: boolean;
        verbose?: boolean;
        watch: boolean;
        watchAll: boolean;
        watchman: boolean;
        watchPathIgnorePatterns: string[];
        watchPlugins: (string | [string, Record<string, unknown>])[];
        workerIdleMemoryLimit: string | number;
        workerThreads: boolean;
    }>>
  • Promise resolved to customized Jest options.

    Returns Promise<Partial<{
        automock: boolean;
        bail: number | boolean;
        cache: boolean;
        cacheDirectory: string;
        changedFilesWithAncestor: boolean;
        changedSince: string;
        ci: boolean;
        clearMocks: boolean;
        collectCoverage: boolean;
        collectCoverageFrom: string[];
        coverageDirectory: string;
        coveragePathIgnorePatterns: string[];
        coverageProvider: CoverageProvider;
        coverageReporters: CoverageReporters;
        coverageThreshold: CoverageThreshold;
        dependencyExtractor: string;
        detectLeaks: boolean;
        detectOpenHandles: boolean;
        displayName: string | DisplayName;
        errorOnDeprecated: boolean;
        expand: boolean;
        extensionsToTreatAsEsm: string[];
        fakeTimers: FakeTimers;
        filter: string;
        findRelatedTests: boolean;
        forceCoverageMatch: string[];
        forceExit: boolean;
        globals: ConfigGlobals;
        globalSetup: undefined | null | string;
        globalTeardown: undefined | null | string;
        haste: HasteConfig;
        id: string;
        injectGlobals: boolean;
        json: boolean;
        lastCommit: boolean;
        listTests: boolean;
        logHeapUsage: boolean;
        maxConcurrency: number;
        maxWorkers: string | number;
        moduleDirectories: string[];
        moduleFileExtensions: string[];
        moduleNameMapper: {
            [key: string]: string | string[];
        };
        modulePathIgnorePatterns: string[];
        modulePaths: string[];
        noStackTrace: boolean;
        notify: boolean;
        notifyMode: string;
        onlyChanged: boolean;
        onlyFailures: boolean;
        openHandlesTimeout: number;
        outputFile: string;
        passWithNoTests: boolean;
        preset: undefined | null | string;
        prettierPath: undefined | null | string;
        projects: (string | InitialProjectOptions)[];
        randomize: boolean;
        replname: undefined | null | string;
        reporters: (string | ReporterConfig)[];
        resetMocks: boolean;
        resetModules: boolean;
        resolver: undefined | null | string;
        restoreMocks: boolean;
        rootDir: string;
        roots: string[];
        runner: string;
        runTestsByPath: boolean;
        runtime: string;
        sandboxInjectedGlobals: string[];
        setupFiles: string[];
        setupFilesAfterEnv: string[];
        showSeed: boolean;
        silent: boolean;
        skipFilter: boolean;
        skipNodeResolution: boolean;
        slowTestThreshold: number;
        snapshotFormat: {
            callToJSON?: boolean;
            compareKeys?: null;
            escapeRegex?: boolean;
            escapeString?: boolean;
            highlight?: boolean;
            indent?: number;
            maxDepth?: number;
            maxWidth?: number;
            min?: boolean;
            printBasicPrototype?: boolean;
            printFunctionName?: boolean;
            theme?: {
                comment?: string;
                content?: string;
                prop?: string;
                tag?: string;
                value?: string;
            };
        };
        snapshotResolver: string;
        snapshotSerializers: string[];
        testEnvironment: string;
        testEnvironmentOptions: Record<string, unknown>;
        testFailureExitCode: string | number;
        testLocationInResults: boolean;
        testMatch: string[];
        testNamePattern: string;
        testPathIgnorePatterns: string[];
        testRegex: string | string[];
        testResultsProcessor: string;
        testRunner: string;
        testSequencer: string;
        testTimeout: number;
        transform: {
            [regex: string]: string | TransformerConfig;
        };
        transformIgnorePatterns: string[];
        unmockedModulePathPatterns: string[];
        updateSnapshot: boolean;
        useStderr: boolean;
        verbose?: boolean;
        watch: boolean;
        watchAll: boolean;
        watchman: boolean;
        watchPathIgnorePatterns: string[];
        watchPlugins: (string | [string, Record<string, unknown>])[];
        workerIdleMemoryLimit: string | number;
        workerThreads: boolean;
    }>>

  • get runner(): Promise<"ts-jest" | "swc">
  • Test runner.

    Test may be run either with swc, or with ts-jest.

    Returns Promise<"ts-jest" | "swc">

    Promise resolved to auto-detected test runner, unless overridden by RUNZ_TEST_RUNNER environment variable.

Methods

  • Replaces custom Rollup options with autogenerated ones.

    Clears custom options, and forces automatic generation.

    Parameters

    • options: Partial<{
          automock: boolean;
          bail: number | boolean;
          cache: boolean;
          cacheDirectory: string;
          changedFilesWithAncestor: boolean;
          changedSince: string;
          ci: boolean;
          clearMocks: boolean;
          collectCoverage: boolean;
          collectCoverageFrom: string[];
          coverageDirectory: string;
          coveragePathIgnorePatterns: string[];
          coverageProvider: CoverageProvider;
          coverageReporters: CoverageReporters;
          coverageThreshold: CoverageThreshold;
          dependencyExtractor: string;
          detectLeaks: boolean;
          detectOpenHandles: boolean;
          displayName: string | DisplayName;
          errorOnDeprecated: boolean;
          expand: boolean;
          extensionsToTreatAsEsm: string[];
          fakeTimers: FakeTimers;
          filter: string;
          findRelatedTests: boolean;
          forceCoverageMatch: string[];
          forceExit: boolean;
          globals: ConfigGlobals;
          globalSetup: undefined | null | string;
          globalTeardown: undefined | null | string;
          haste: HasteConfig;
          id: string;
          injectGlobals: boolean;
          json: boolean;
          lastCommit: boolean;
          listTests: boolean;
          logHeapUsage: boolean;
          maxConcurrency: number;
          maxWorkers: string | number;
          moduleDirectories: string[];
          moduleFileExtensions: string[];
          moduleNameMapper: {
              [key: string]: string | string[];
          };
          modulePathIgnorePatterns: string[];
          modulePaths: string[];
          noStackTrace: boolean;
          notify: boolean;
          notifyMode: string;
          onlyChanged: boolean;
          onlyFailures: boolean;
          openHandlesTimeout: number;
          outputFile: string;
          passWithNoTests: boolean;
          preset: undefined | null | string;
          prettierPath: undefined | null | string;
          projects: (string | InitialProjectOptions)[];
          randomize: boolean;
          replname: undefined | null | string;
          reporters: (string | ReporterConfig)[];
          resetMocks: boolean;
          resetModules: boolean;
          resolver: undefined | null | string;
          restoreMocks: boolean;
          rootDir: string;
          roots: string[];
          runner: string;
          runTestsByPath: boolean;
          runtime: string;
          sandboxInjectedGlobals: string[];
          setupFiles: string[];
          setupFilesAfterEnv: string[];
          showSeed: boolean;
          silent: boolean;
          skipFilter: boolean;
          skipNodeResolution: boolean;
          slowTestThreshold: number;
          snapshotFormat: {
              callToJSON?: boolean;
              compareKeys?: null;
              escapeRegex?: boolean;
              escapeString?: boolean;
              highlight?: boolean;
              indent?: number;
              maxDepth?: number;
              maxWidth?: number;
              min?: boolean;
              printBasicPrototype?: boolean;
              printFunctionName?: boolean;
              theme?: {
                  comment?: string;
                  content?: string;
                  prop?: string;
                  tag?: string;
                  value?: string;
              };
          };
          snapshotResolver: string;
          snapshotSerializers: string[];
          testEnvironment: string;
          testEnvironmentOptions: Record<string, unknown>;
          testFailureExitCode: string | number;
          testLocationInResults: boolean;
          testMatch: string[];
          testNamePattern: string;
          testPathIgnorePatterns: string[];
          testRegex: string | string[];
          testResultsProcessor: string;
          testRunner: string;
          testSequencer: string;
          testTimeout: number;
          transform: {
              [regex: string]: string | TransformerConfig;
          };
          transformIgnorePatterns: string[];
          unmockedModulePathPatterns: string[];
          updateSnapshot: boolean;
          useStderr: boolean;
          verbose?: boolean;
          watch: boolean;
          watchAll: boolean;
          watchman: boolean;
          watchPathIgnorePatterns: string[];
          watchPlugins: (string | [string, Record<string, unknown>])[];
          workerIdleMemoryLimit: string | number;
          workerThreads: boolean;
      }>

      Jest options extending autogenerated ones.

    Returns this

    Updated instance.

  • Extends Jest options.

    Parameters

    • extension: Partial<{
          automock: boolean;
          bail: number | boolean;
          cache: boolean;
          cacheDirectory: string;
          changedFilesWithAncestor: boolean;
          changedSince: string;
          ci: boolean;
          clearMocks: boolean;
          collectCoverage: boolean;
          collectCoverageFrom: string[];
          coverageDirectory: string;
          coveragePathIgnorePatterns: string[];
          coverageProvider: CoverageProvider;
          coverageReporters: CoverageReporters;
          coverageThreshold: CoverageThreshold;
          dependencyExtractor: string;
          detectLeaks: boolean;
          detectOpenHandles: boolean;
          displayName: string | DisplayName;
          errorOnDeprecated: boolean;
          expand: boolean;
          extensionsToTreatAsEsm: string[];
          fakeTimers: FakeTimers;
          filter: string;
          findRelatedTests: boolean;
          forceCoverageMatch: string[];
          forceExit: boolean;
          globals: ConfigGlobals;
          globalSetup: undefined | null | string;
          globalTeardown: undefined | null | string;
          haste: HasteConfig;
          id: string;
          injectGlobals: boolean;
          json: boolean;
          lastCommit: boolean;
          listTests: boolean;
          logHeapUsage: boolean;
          maxConcurrency: number;
          maxWorkers: string | number;
          moduleDirectories: string[];
          moduleFileExtensions: string[];
          moduleNameMapper: {
              [key: string]: string | string[];
          };
          modulePathIgnorePatterns: string[];
          modulePaths: string[];
          noStackTrace: boolean;
          notify: boolean;
          notifyMode: string;
          onlyChanged: boolean;
          onlyFailures: boolean;
          openHandlesTimeout: number;
          outputFile: string;
          passWithNoTests: boolean;
          preset: undefined | null | string;
          prettierPath: undefined | null | string;
          projects: (string | InitialProjectOptions)[];
          randomize: boolean;
          replname: undefined | null | string;
          reporters: (string | ReporterConfig)[];
          resetMocks: boolean;
          resetModules: boolean;
          resolver: undefined | null | string;
          restoreMocks: boolean;
          rootDir: string;
          roots: string[];
          runner: string;
          runTestsByPath: boolean;
          runtime: string;
          sandboxInjectedGlobals: string[];
          setupFiles: string[];
          setupFilesAfterEnv: string[];
          showSeed: boolean;
          silent: boolean;
          skipFilter: boolean;
          skipNodeResolution: boolean;
          slowTestThreshold: number;
          snapshotFormat: {
              callToJSON?: boolean;
              compareKeys?: null;
              escapeRegex?: boolean;
              escapeString?: boolean;
              highlight?: boolean;
              indent?: number;
              maxDepth?: number;
              maxWidth?: number;
              min?: boolean;
              printBasicPrototype?: boolean;
              printFunctionName?: boolean;
              theme?: {
                  comment?: string;
                  content?: string;
                  prop?: string;
                  tag?: string;
                  value?: string;
              };
          };
          snapshotResolver: string;
          snapshotSerializers: string[];
          testEnvironment: string;
          testEnvironmentOptions: Record<string, unknown>;
          testFailureExitCode: string | number;
          testLocationInResults: boolean;
          testMatch: string[];
          testNamePattern: string;
          testPathIgnorePatterns: string[];
          testRegex: string | string[];
          testResultsProcessor: string;
          testRunner: string;
          testSequencer: string;
          testTimeout: number;
          transform: {
              [regex: string]: string | TransformerConfig;
          };
          transformIgnorePatterns: string[];
          unmockedModulePathPatterns: string[];
          updateSnapshot: boolean;
          useStderr: boolean;
          verbose?: boolean;
          watch: boolean;
          watchAll: boolean;
          watchman: boolean;
          watchPathIgnorePatterns: string[];
          watchPlugins: (string | [string, Record<string, unknown>])[];
          workerIdleMemoryLimit: string | number;
          workerThreads: boolean;
      }>

      Jest options extending previous ones.

    Returns this

    Updated instance instance.

  • Replaces Jest options with custom ones.

    Clears custom options, and prevents automatic generation.

    Parameters

    • options: Partial<{
          automock: boolean;
          bail: number | boolean;
          cache: boolean;
          cacheDirectory: string;
          changedFilesWithAncestor: boolean;
          changedSince: string;
          ci: boolean;
          clearMocks: boolean;
          collectCoverage: boolean;
          collectCoverageFrom: string[];
          coverageDirectory: string;
          coveragePathIgnorePatterns: string[];
          coverageProvider: CoverageProvider;
          coverageReporters: CoverageReporters;
          coverageThreshold: CoverageThreshold;
          dependencyExtractor: string;
          detectLeaks: boolean;
          detectOpenHandles: boolean;
          displayName: string | DisplayName;
          errorOnDeprecated: boolean;
          expand: boolean;
          extensionsToTreatAsEsm: string[];
          fakeTimers: FakeTimers;
          filter: string;
          findRelatedTests: boolean;
          forceCoverageMatch: string[];
          forceExit: boolean;
          globals: ConfigGlobals;
          globalSetup: undefined | null | string;
          globalTeardown: undefined | null | string;
          haste: HasteConfig;
          id: string;
          injectGlobals: boolean;
          json: boolean;
          lastCommit: boolean;
          listTests: boolean;
          logHeapUsage: boolean;
          maxConcurrency: number;
          maxWorkers: string | number;
          moduleDirectories: string[];
          moduleFileExtensions: string[];
          moduleNameMapper: {
              [key: string]: string | string[];
          };
          modulePathIgnorePatterns: string[];
          modulePaths: string[];
          noStackTrace: boolean;
          notify: boolean;
          notifyMode: string;
          onlyChanged: boolean;
          onlyFailures: boolean;
          openHandlesTimeout: number;
          outputFile: string;
          passWithNoTests: boolean;
          preset: undefined | null | string;
          prettierPath: undefined | null | string;
          projects: (string | InitialProjectOptions)[];
          randomize: boolean;
          replname: undefined | null | string;
          reporters: (string | ReporterConfig)[];
          resetMocks: boolean;
          resetModules: boolean;
          resolver: undefined | null | string;
          restoreMocks: boolean;
          rootDir: string;
          roots: string[];
          runner: string;
          runTestsByPath: boolean;
          runtime: string;
          sandboxInjectedGlobals: string[];
          setupFiles: string[];
          setupFilesAfterEnv: string[];
          showSeed: boolean;
          silent: boolean;
          skipFilter: boolean;
          skipNodeResolution: boolean;
          slowTestThreshold: number;
          snapshotFormat: {
              callToJSON?: boolean;
              compareKeys?: null;
              escapeRegex?: boolean;
              escapeString?: boolean;
              highlight?: boolean;
              indent?: number;
              maxDepth?: number;
              maxWidth?: number;
              min?: boolean;
              printBasicPrototype?: boolean;
              printFunctionName?: boolean;
              theme?: {
                  comment?: string;
                  content?: string;
                  prop?: string;
                  tag?: string;
                  value?: string;
              };
          };
          snapshotResolver: string;
          snapshotSerializers: string[];
          testEnvironment: string;
          testEnvironmentOptions: Record<string, unknown>;
          testFailureExitCode: string | number;
          testLocationInResults: boolean;
          testMatch: string[];
          testNamePattern: string;
          testPathIgnorePatterns: string[];
          testRegex: string | string[];
          testResultsProcessor: string;
          testRunner: string;
          testSequencer: string;
          testTimeout: number;
          transform: {
              [regex: string]: string | TransformerConfig;
          };
          transformIgnorePatterns: string[];
          unmockedModulePathPatterns: string[];
          updateSnapshot: boolean;
          useStderr: boolean;
          verbose?: boolean;
          watch: boolean;
          watchAll: boolean;
          watchman: boolean;
          watchPathIgnorePatterns: string[];
          watchPlugins: (string | [string, Record<string, unknown>])[];
          workerIdleMemoryLimit: string | number;
          workerThreads: boolean;
      }>

      Jest options to apply.

    Returns this

    Updated instance.

  • Configures and run project tests with Jest.

    Parameters

    • Optionalargs: string[]

      Array of Jest command line arguments. Defaults to arguments from process.argv.

    Returns Promise<void>

    Promise resolved when tests executed.