Class that handles configuration for TAP.

Typically, @tapjs/config!index.TapConfig.load is the way to get one of these.

Type Parameters

Constructors

  • Type Parameters

    • C extends ConfigSet = ConfigSetFromMetaSet<"string", true, {
          plugin: {
              default: string[];
              description: string;
              hint: string;
          };
      }> & ConfigSetFromMetaSet<"string", false, {
          reporter: {
              description: string;
              hint: string;
              short: string;
          };
          reporter-file: {
              description: string;
              hint: string;
              short: string;
          };
      }> & ConfigSetFromMetaSet<"string", true, {
          reporter-arg: {
              description: string;
              hint: string;
              short: string;
          };
      }> & ConfigSetFromMetaSet<"string", true, {
          coverage-report: {
              default: string[];
              description: string;
              hint: string;
          };
      }> & ConfigSetFromMetaSet<"boolean", false, {
          browser: {
              default: true;
              description: string;
          };
          no-browser: {
              description: string;
          };
          show-full-coverage: {
              description: string;
          };
      }> & ConfigSetFromMetaSet<"string", false, {
          coverage-map: {
              description: string;
              hint: string;
          };
      }> & ConfigSetFromMetaSet<"boolean", false, {
          allow-empty-coverage: {
              description: string;
          };
          allow-incomplete-coverage: {
              description: string;
          };
          disable-coverage: {
              description: string;
          };
      }> & ConfigSetFromMetaSet<"boolean", false, {
          bail: {
              description: string;
              short: string;
          };
          changed: {
              description: string;
              short: string;
          };
          color: {
              description: string;
              short: string;
          };
          comments: {
              description: string;
          };
          fail-only: {
              description: string;
          };
          fail-skip: {
              description: string;
          };
          fail-todo: {
              description: string;
          };
          no-bail: {
              description: string;
              short: string;
          };
          no-color: {
              description: string;
              short: string;
          };
          passes: {
              description: string;
          };
      }> & ConfigSetFromMetaSet<"string", false, {
          save: {
              description: string;
              hint: string;
              short: string;
          };
      }> & ConfigSetFromMetaSet<"boolean", false, {
          diag: {
              description: string;
          };
          no-diag: {
              description: string;
          };
      }> & ConfigSetFromMetaSet<"number", false, {
          timeout: {
              default: number;
              description: string;
              hint: string;
              short: string;
          };
      }> & ConfigSetFromMetaSet<"string", true, {
          files: {
              description: string;
              hint: string;
          };
      }> & ConfigSetFromMetaSet<"number", false, {
          jobs: {
              default: number;
              description: string;
              hint: string;
              short: string;
          };
      }> & ConfigSetFromMetaSet<"string", false, {
          after: {
              description: string;
              hint: string;
          };
          before: {
              description: string;
              hint: string;
          };
          output-dir: {
              description: string;
              hint: string;
              short: string;
          };
          output-file: {
              description: string;
              hint: string;
              short: string;
          };
      }> & ConfigSetFromMetaSet<"string", true, {
          exclude: {
              default: string[];
              description: string;
              hint: string;
          };
          include: {
              default: string[];
              description: string;
              hint: string;
          };
          node-arg: {
              default: never[];
              description: string;
              hint: string;
          };
          serial: {
              description: string;
              hint: string;
          };
          test-arg: {
              default: never[];
              description: string;
              hint: string;
          };
          test-env: {
              default: never[];
              description: string;
              hint: string;
          };
      }> & ConfigSetFromMetaSet<"boolean", false, {
          debug: {
              description: string;
          };
          help: {
              description: string;
              short: string;
              type: "boolean";
          };
          no-omit-whitespace: {
              description: string;
          };
          omit-version: {
              description: string;
          };
          omit-whitespace: {
              description: string;
          };
          version: {
              description: string;
              short: string;
          };
          versions: {
              description: string;
              short: string;
          };
      }>

    Parameters

    • jack: Jack<C> = ...

    Returns TapConfig<C>

Properties

configFile?: string

The file providing configuration, either a package.json or .taprc. If undefined, it means that we don't have a config file.

jack: Jack<C>

The JackSpeak object representing TAP's configuration

positionals?: string[]

positional arguments to the TAP process

projectRoot: string = cwd

The effective current working directory for various globbing actions. The root of the project where a .taprc, package.json, or .git was found.

testFileExtensions: Set<string> = testFileExtensions

The file extensions that tap knows how to load, updated by plugins

values?: OptionsResults<C>

Parsed values in effect

valuesFromConfigFile?: OptionsResults<C>

values read from the config file, if loaded

Accessors

  • get pluginList(): string[]
  • The list of all plugins that ought to be loaded.

    Returns string[]

  • get pluginSignature(): string
  • The signature of all plugin modules that ought to be loaded.

    Returns string

Methods

  • load the file, and write the fields in data. If the file is not present, create it.

    Parameters

    • data: OptionsResults<C>
    • configFile: undefined | string = ...
    • overwrite: boolean = false

    Returns Promise<void>

  • Edit the "tap" section of a package.json file

    Parameters

    • data: OptionsResults<C>
    • configFile: string
    • overwrite: boolean = false

    Returns Promise<void>

  • Edit a yaml .taprc file

    Parameters

    • data: OptionsResults<C>
    • configFile: string
    • overwrite: boolean = false

    Returns Promise<void>

  • replace __EXTENSIONS__ in a glob with the actual testFileExtensions

    Parameters

    • inc: string

    Returns string

  • Apply the extension from a resolved extends field in the config.

    Parameters

    • data: Record<string, any>
    • file: string

    Returns Promise<void>

  • Get a configuration value, as we currently know it

    Type Parameters

    • K extends string | number | symbol

    Parameters

    Returns OptionsResults<C>[K]

  • Load some configuration fields from a config file

    Parameters

    • data: any
    • configFile: string

    Returns Promise<TapConfig<C> & {
        configFile: string;
        valuesFromConfigFile: OptionsResults<C>;
    }>

  • Load configuration from a file

    Returns Promise<TapConfig<C> & {
        configFile: string;
        valuesFromConfigFile: OptionsResults<C>;
    }>

  • Load configuration fields exported by active plugins

    Returns TapConfig<C & ConfigSetFromMetaSet<"boolean", false, {
        only: {
            description: string;
            nodeArgs: ((v: boolean) => string[]);
            short: string;
            type: string;
        } & {
            default?: boolean;
            description?: string;
            hint?: undefined;
            short?: string;
            type: "boolean";
            validOptions?: undefined;
            validate?: ((v: unknown) => v is boolean);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }> & ConfigSetFromMetaSet<"string", true, {
        grep: {
            description: string;
            hint: string;
            multiple: boolean;
            nodeArgs: ((value: string[]) => string[]);
            short: string;
            type: string;
        } & {
            default?: string[];
            description?: string;
            hint?: string;
            short?: string;
            type: "string";
            validOptions?: readonly string[];
            validate?: ((v: unknown) => v is string[]);
        } & {
            delim?: string;
            multiple: true;
        };
    }> & ConfigSetFromMetaSet<"boolean", false, {
        invert: {
            description: string;
            short: string;
            type: string;
        } & {
            default?: boolean;
            description?: string;
            hint?: undefined;
            short?: string;
            type: "boolean";
            validOptions?: undefined;
            validate?: ((v: unknown) => v is boolean);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }> & ConfigSetFromMetaSet<"boolean", false, {
        no-invert: {
            description: string;
            short: string;
            type: string;
        } & {
            default?: boolean;
            description?: string;
            hint?: undefined;
            short?: string;
            type: "boolean";
            validOptions?: undefined;
            validate?: ((v: unknown) => v is boolean);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }> & ConfigSetFromMetaSet<"boolean", false, {
        filter-quietly: {
            description: string;
            type: string;
        } & {
            default?: boolean;
            description?: string;
            hint?: undefined;
            short?: string;
            type: "boolean";
            validOptions?: undefined;
            validate?: ((v: unknown) => v is boolean);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }> & ConfigSetFromMetaSet<"boolean", false, {
        no-filter-quietly: {
            description: string;
            type: string;
        } & {
            default?: boolean;
            description?: string;
            hint?: undefined;
            short?: string;
            type: "boolean";
            validOptions?: undefined;
            validate?: ((v: unknown) => v is boolean);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }> & ConfigSetFromMetaSet<"boolean", false, {
        save-fixture: {
            description: string;
            short: string;
            type: string;
        } & {
            default?: boolean;
            description?: string;
            hint?: undefined;
            short?: string;
            type: "boolean";
            validOptions?: undefined;
            validate?: ((v: unknown) => v is boolean);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }> & ConfigSetFromMetaSet<"boolean", false, {
        snapshot: {
            description: string;
            short: string;
            type: string;
        } & {
            default?: boolean;
            description?: string;
            hint?: undefined;
            short?: string;
            type: "boolean";
            validOptions?: undefined;
            validate?: ((v: unknown) => v is boolean);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }> & ConfigSetFromMetaSet<"boolean", false, {
        snapshot-clean-cwd: {
            default: boolean;
            description: string;
            type: string;
        } & {
            default?: boolean;
            description?: string;
            hint?: undefined;
            short?: string;
            type: "boolean";
            validOptions?: undefined;
            validate?: ((v: unknown) => v is boolean);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }> & ConfigSetFromMetaSet<"boolean", false, {
        no-snapshot-clean-cwd: {
            description: string;
            type: string;
        } & {
            default?: boolean;
            description?: string;
            hint?: undefined;
            short?: string;
            type: "boolean";
            validOptions?: undefined;
            validate?: ((v: unknown) => v is boolean);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }> & ConfigSetFromMetaSet<"boolean", false, {
        typecheck: {
            description: string;
            type: string;
        } & {
            default?: boolean;
            description?: string;
            hint?: undefined;
            short?: string;
            type: "boolean";
            validOptions?: undefined;
            validate?: ((v: unknown) => v is boolean);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }> & ConfigSetFromMetaSet<"string", false, {
        tsconfig: {
            description: string;
            type: string;
        } & {
            default?: string;
            description?: string;
            hint?: string;
            short?: string;
            type: "string";
            validOptions?: readonly string[];
            validate?: ((v: unknown) => v is string);
        } & {
            delim?: undefined;
            multiple?: false;
        };
    }>>

  • Load the reporter that ought to be used, based on the configured value, the TAP environment variable, and whether or not we have colors enabled.

    Returns TapConfig<C>

  • Parse the arguments and set configuration and positionals accordingly.

    Parameters

    • args: string[] = argv

    Returns TapConfig<C> & {
        positionals: string[];
        values: OptionsResults<C>;
    }

  • Read the configuration from a dependency

    Parameters

    • file: string

    Returns Promise<undefined | OptionsResults<C>>

  • Read a package.json file

    Parameters

    • pj: string
    • silent: boolean = false

    Returns Promise<undefined | {
        tap?: OptionsResults<C>;
    }>

  • Read the configuration from the "tap" object in a package.json file

    Parameters

    • pj: string

    Returns Promise<undefined | OptionsResults<C>>

  • Read configuration from a yaml .taprc file

    Parameters

    • rc: string
    • silent: boolean = false

    Returns Promise<undefined | OptionsResults<C>>

  • Resolve the source of an extends field in TAP configs

    Parameters

    • ext: string
    • file: string

    Returns Promise<string>

  • Parameters

    • conf: undefined | OptionsResults<C>
    • file: string

    Returns undefined | OptionsResults<C>