microsoft/TypeScript · error · Error

Provided test options exceeded the maximum number of variati

Error message

Provided test options exceeded the maximum number of variations: ${varyBy.map(v => `'@${v}'`).join(", ")}

What it means

Thrown in getFileBasedTestConfigurations (harnessIO.ts:1175) when the cross-product of all `@<varyBy>` settings exceeds 25. The harness caps the variation matrix to keep combinatorial explosion bounded; the running product `variationCount *= entries.length` is checked after each dimension is added.

Source

Thrown at src/harness/harnessIO.ts:1175

            })));
        }
    }
}

/**
 * Compute FileBasedTestConfiguration variations based on a supplied list of variable settings.
 */
export function getFileBasedTestConfigurations(settings: TestCaseParser.CompilerSettings, varyBy: readonly string[]): FileBasedTestConfiguration[] | undefined {
    let varyByEntries: [string, string[]][] | undefined;
    let variationCount = 1;
    for (const varyByKey of varyBy) {
        if (ts.hasProperty(settings, varyByKey)) {
            // we only consider variations when there are 2 or more variable entries.
            const entries = splitVaryBySettingValue(settings[varyByKey], varyByKey);
            if (entries) {
                if (!varyByEntries) varyByEntries = [];
                variationCount *= entries.length;
                if (variationCount > 25) throw new Error(`Provided test options exceeded the maximum number of variations: ${varyBy.map(v => `'@${v}'`).join(", ")}`);
                varyByEntries.push([varyByKey, entries]);
            }
        }
    }

    if (!varyByEntries) return undefined;

    const configurations: FileBasedTestConfiguration[] = [];
    computeFileBasedTestConfigurationVariations(configurations, /*variationState*/ {}, varyByEntries, /*offset*/ 0);
    return configurations;
}

/**
 * Compute a description for this configuration based on its entries
 */
export function getFileBasedTestConfigurationDescription(configuration: FileBasedTestConfiguration): string {
    let name = "";
    if (configuration) {

View on GitHub (pinned to b465fdbfe1)

Solutions

  1. Reduce the number of values in one or more `@<varyBy>` directives so the product is at most 25.
  2. Split the single test file into two or more files, each covering a subset of the variation dimensions.
  3. Remove the least important varyBy dimension entirely.
  4. Use `exclude=` to drop values you do not need from a high-cardinality option.

Example fix

// before — 6 targets x 5 modules = 30 > 25
// @target: es5,es6,es2015,es2017,es2019,esnext
// @module: commonjs,es2015,system,amd,umd

// after — trim to 5 x 5 = 25
// @target: es5,es6,es2017,es2019,esnext
// @module: commonjs,es2015,system,amd,umd
Defensive patterns

Strategy: validation

Validate before calling

// Pre-compute the cross-product size and surface a clearer error before the harness throws.
function variationProduct(varyByEntries: [string, string[]][]): number {
  return varyByEntries.reduce((acc, [, vals]) => acc * vals.length, 1);
}
const product = variationProduct(myVaryByEntries);
if (product > 25) {
  throw new Error(`Refactor the test: ${product} variations > 25 cap. Split files or trim a dimension.`);
}

Type guard

function isWithinVariationCap(varyByEntries: [string, string[]][], cap = 25): boolean {
  return varyByEntries.reduce((acc, [, v]) => acc * v.length, 1) <= cap;
}

Prevention

When it happens

Trigger: A test file stacks several varyBy directives — e.g. `@module`, `@target`, `@jsx`, `@moduleResolution` — whose value counts multiply past 25 (5 x 6 = 30 already trips it). The thrown message lists every key in `varyBy` joined with commas.

Common situations: Adding a new varyBy dimension to a test that already had several; expanding an option's value list (e.g. target across es5/es6/es2015..esnext); bulk test generation that combines many options.

Related errors


AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12). Data as JSON: /api/errors/f94f010af50fd1fb. Report an issue: GitHub.