test(vitest): give config creators nameable return types

A vitest/vite type bump made inferred creator return types reach
vite-internal names (TS4058/TS4082), failing check-test-types repo-wide.
Annotate the scoped/extension config roots and the spread-rebuilding
creators with ViteUserConfig; also drop an unused workflow read, mutating
sorts, and an untyped record index left by 1f591bba56.
This commit is contained in:
Peter Steinberger
2026-08-10 09:35:51 -07:00
parent 25a9a2e020
commit 896592b747
8 changed files with 29 additions and 10 deletions
+4 -1
View File
@@ -1,9 +1,12 @@
import type { ViteUserConfig } from "vitest/config";
import { cliProcessTestFiles } from "./vitest.cli-process-paths.mjs";
// CLI process tests run serially in isolated forks so child startup deadlines
// measure the CLI rather than contention from the shared CLI test graph.
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
export function createCliProcessVitestConfig(env?: Record<string, string | undefined>) {
export function createCliProcessVitestConfig(
env?: Record<string, string | undefined>,
): ViteUserConfig {
const config = createScopedVitestConfig(cliProcessTestFiles, {
env,
fileParallelism: false,
+2 -1
View File
@@ -1,4 +1,5 @@
// Vitest extension config helpers keep extension shard defaults aligned.
import type { ViteUserConfig } from "vitest/config";
import { loadPatternListFromEnv } from "./vitest.pattern-file.ts";
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
@@ -13,7 +14,7 @@ export function createExtensionVitestConfig(
testRoots: readonly string[],
env: Record<string, string | undefined> = process.env,
options: ExtensionVitestConfigOptions = {},
) {
): ViteUserConfig {
return createScopedVitestConfig(
loadPatternListFromEnv("OPENCLAW_VITEST_INCLUDE_FILE", env) ??
testRoots.map((root) => `${root}/**/*.test.ts`),
@@ -1,12 +1,13 @@
// Vitest extension provider openai config wires the extension provider openai test shard.
import path from "node:path";
// Vitest extension provider openai config wires the extension provider openai test shard.
import type { ViteUserConfig } from "vitest/config";
import { createExtensionVitestConfig } from "./vitest.extension-config.ts";
import { providerOpenAiExtensionTestRoots } from "./vitest.extension-provider-paths.mjs";
import { repoRoot } from "./vitest.shared.config.ts";
export function createExtensionProviderOpenAiVitestConfig(
env: Record<string, string | undefined> = process.env,
) {
): ViteUserConfig {
const config = createExtensionVitestConfig(
"provider-openai",
providerOpenAiExtensionTestRoots,
+4 -1
View File
@@ -1,7 +1,10 @@
// Vitest process config wires the process test shard.
import type { ViteUserConfig } from "vitest/config";
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
export function createProcessVitestConfig(env?: Record<string, string | undefined>) {
export function createProcessVitestConfig(
env?: Record<string, string | undefined>,
): ViteUserConfig {
const config = createScopedVitestConfig(["src/process/**/*.test.ts"], {
dir: "src",
env,
+4 -1
View File
@@ -1,7 +1,10 @@
// Vitest runtime config config wires the runtime config test shard.
import type { ViteUserConfig } from "vitest/config";
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
export function createRuntimeConfigVitestConfig(env?: Record<string, string | undefined>) {
export function createRuntimeConfigVitestConfig(
env?: Record<string, string | undefined>,
): ViteUserConfig {
const config = createScopedVitestConfig(["src/config/**/*.test.ts"], {
dir: "src",
env,
+4 -2
View File
@@ -1,6 +1,6 @@
// Vitest scoped config helper builds test configs for scoped file patterns.
import path from "node:path";
import { defineConfig } from "vitest/config";
import { defineConfig, type ViteUserConfig } from "vitest/config";
import {
intersectIncludePatterns,
loadPatternListFromEnv,
@@ -219,7 +219,9 @@ export function createScopedVitestConfig(
setupFiles?: string[];
useNonIsolatedRunner?: boolean;
},
) {
// Explicit nameable return type: inference otherwise reaches vite-internal
// names (TS4058/TS4082) in every downstream scoped-config creator.
): ViteUserConfig {
const base = sharedVitestConfig as Record<string, unknown>;
const baseTest = sharedVitestConfig.test ?? {};
const baseSequence = (baseTest as { sequence?: { groupOrder?: number } }).sequence;
+5 -1
View File
@@ -2,12 +2,16 @@
// The shared ui shard runs non-isolated for speed, but tests that spy on module
// internals and assert the component uses that spy must not share a module cache
// with stateful predecessor files (see uiIsolatedTestFiles).
import type { ViteUserConfig } from "vitest/config";
import { controlUiLocaleModulesPlugin } from "../../ui/config/control-ui-locales.ts";
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
import { jsdomOptimizedDeps } from "./vitest.shared.config.ts";
import { uiIsolatedTestFiles } from "./vitest.ui-isolated-paths.mjs";
export function createUiIsolatedVitestConfig(env?: Record<string, string | undefined>) {
// Explicit nameable return type: inference reaches vite-internal names (TS4058/TS4082).
export function createUiIsolatedVitestConfig(
env?: Record<string, string | undefined>,
): ViteUserConfig {
const config = createScopedVitestConfig(uiIsolatedTestFiles, {
deps: jsdomOptimizedDeps,
environment: "jsdom",
+3 -1
View File
@@ -1,13 +1,15 @@
// Vitest ui config wires the ui test shard.
import type { ViteUserConfig } from "vitest/config";
import { controlUiLocaleModulesPlugin } from "../../ui/config/control-ui-locales.ts";
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
import { jsdomOptimizedDeps } from "./vitest.shared.config.ts";
import { uiIsolatedTestFiles } from "./vitest.ui-isolated-paths.mjs";
// Explicit nameable return type: inference reaches vite-internal names (TS4058/TS4082).
export function createUiVitestConfig(
env?: Record<string, string | undefined>,
options?: { includePatterns?: string[]; name?: string },
) {
): ViteUserConfig {
const includePatterns = options?.includePatterns ?? ["ui/src/**/*.test.ts"];
// Isolated files must never enter the shared module graph, including scoped runs.
const exclude = ["ui/src/**/*.e2e.test.ts", ...uiIsolatedTestFiles];