Skip to content

Commit bd079a6

Browse files
[wrangler] Deduplicate unenv-preset e2e tests and bump beforeAll timeout (#12863)
1 parent 077c4d5 commit bd079a6

1 file changed

Lines changed: 61 additions & 3 deletions

File tree

packages/wrangler/e2e/unenv-preset/preset.test.ts

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,14 @@ const localTestConfigs: TestConfig[] = [
776776
],
777777
].flat() as TestConfig[];
778778

779-
describe.each(localTestConfigs)(
779+
// Many test configs share the same (compatibilityDate, compatibilityFlags) combination
780+
// and therefore produce identical wrangler dev instances. Group them to avoid redundant
781+
// startups and test executions (84 configs → 58 unique wrangler instances).
782+
const groupedLocalConfigs = groupByWranglerConfig(localTestConfigs);
783+
784+
describe.each(groupedLocalConfigs)(
780785
`Local preset test: $name`,
781-
({ compatibilityDate, compatibilityFlags = [], expectRuntimeFlags = {} }) => {
786+
({ compatibilityDate, compatibilityFlags, expectRuntimeFlags }) => {
782787
let url: string;
783788

784789
beforeAll(async () => {
@@ -812,7 +817,7 @@ describe.each(localTestConfigs)(
812817
}
813818

814819
return async () => await wrangler.stop();
815-
}, 10_000);
820+
}, 30_000);
816821

817822
test.for(Object.keys(WorkerdTests))(
818823
"%s",
@@ -950,6 +955,59 @@ describe.runIf(Boolean(CLOUDFLARE_ACCOUNT_ID))(
950955
}
951956
);
952957

958+
type ConfigGroup = {
959+
name: string;
960+
compatibilityDate: string;
961+
compatibilityFlags: string[];
962+
expectRuntimeFlags: Record<string, boolean>;
963+
};
964+
965+
/**
966+
* Groups test configs by their effective wrangler configuration
967+
* (compatibilityDate + compatibilityFlags). Configs that would produce
968+
* identical wrangler dev instances are merged into a single group,
969+
* combining their expectRuntimeFlags assertions.
970+
*/
971+
function groupByWranglerConfig(configs: TestConfig[]): ConfigGroup[] {
972+
const groups = new Map<string, ConfigGroup>();
973+
974+
for (const config of configs) {
975+
const flags = config.compatibilityFlags ?? [];
976+
const key = JSON.stringify({
977+
date: config.compatibilityDate,
978+
flags: [...flags].sort(),
979+
});
980+
981+
const existing = groups.get(key);
982+
if (existing) {
983+
existing.name += `, ${config.name}`;
984+
for (const [flag, value] of Object.entries(
985+
config.expectRuntimeFlags ?? {}
986+
)) {
987+
if (
988+
flag in existing.expectRuntimeFlags &&
989+
existing.expectRuntimeFlags[flag] !== value
990+
) {
991+
throw new Error(
992+
`Conflicting expectRuntimeFlags for "${flag}" in group "${existing.name}": ` +
993+
`existing=${existing.expectRuntimeFlags[flag]}, new=${value} (from "${config.name}")`
994+
);
995+
}
996+
existing.expectRuntimeFlags[flag] = value;
997+
}
998+
} else {
999+
groups.set(key, {
1000+
name: config.name,
1001+
compatibilityDate: config.compatibilityDate,
1002+
compatibilityFlags: flags,
1003+
expectRuntimeFlags: { ...(config.expectRuntimeFlags ?? {}) },
1004+
});
1005+
}
1006+
}
1007+
1008+
return [...groups.values()];
1009+
}
1010+
9531011
/**
9541012
* Collects enabled flags:
9551013
* - skips "experimental" flag

0 commit comments

Comments
 (0)