test: tighten tooling helper assertions

This commit is contained in:
Peter Steinberger
2026-05-08 20:31:35 +01:00
parent 54f952e984
commit 88d32bca40
9 changed files with 1 additions and 12 deletions

View File

@@ -29,7 +29,6 @@ function writeJson(filePath: string, value: unknown): void {
function requireInstall(entry: OfficialChannelCatalogEntry | undefined): OfficialChannelInstall {
const install = entry?.openclaw?.install;
expect(install).toBeDefined();
if (!install) {
throw new Error("expected official channel install config");
}
@@ -37,7 +36,6 @@ function requireInstall(entry: OfficialChannelCatalogEntry | undefined): Officia
}
function requireNpmInstallSource(source: ReturnType<typeof describePluginInstallSource>) {
expect(source.npm).toBeDefined();
if (!source.npm) {
throw new Error("expected npm install source");
}

View File

@@ -16,7 +16,6 @@ function expectDistRelativePaths(paths: string[]) {
function expectPluginNpmRuntimeBuildPlan(
plan: ReturnType<typeof resolvePluginNpmRuntimeBuildPlan>,
): PluginNpmRuntimeBuildPlan {
expect(plan).toBeTruthy();
if (!plan) {
throw new Error("expected plugin npm runtime build plan");
}

View File

@@ -7,7 +7,6 @@ import {
function requireFirstWarning(warn: ReturnType<typeof vi.fn>): unknown {
const message = warn.mock.calls[0]?.[0];
expect(message).toBeDefined();
if (message === undefined) {
throw new Error("expected package manager warning");
}

View File

@@ -36,8 +36,7 @@ function runScript(args: string[], cwd = process.cwd()) {
function requireFirstMockArg<T>(mock: { mock: { calls: Array<[T, ...unknown[]]> } }): T {
const arg = mock.mock.calls[0]?.[0];
expect(arg).toBeDefined();
if (!arg) {
if (arg === undefined) {
throw new Error("expected first mock call argument");
}
return arg;

View File

@@ -7,7 +7,6 @@ import {
import { boundaryTestFiles } from "./vitest/vitest.unit-paths.mjs";
function requireTestConfig(config: ReturnType<typeof createBoundaryVitestConfig>) {
expect(config.test).toBeDefined();
if (!config.test) {
throw new Error("expected boundary vitest test config");
}

View File

@@ -33,7 +33,6 @@ import { createUnitVitestConfig } from "./vitest/vitest.unit.config.ts";
const patternFiles = createPatternFileHelper("openclaw-vitest-projects-config-");
function requireTestConfig<T extends { test?: unknown }>(config: T): NonNullable<T["test"]> {
expect(config.test).toBeDefined();
if (!config.test) {
throw new Error("expected vitest test config");
}
@@ -44,7 +43,6 @@ function requireWebOptimizer(testConfig: {
deps?: { optimizer?: { web?: { enabled?: boolean } } };
}) {
const webOptimizer = testConfig.deps?.optimizer?.web;
expect(webOptimizer).toBeDefined();
if (!webOptimizer) {
throw new Error("expected vitest web optimizer config");
}

View File

@@ -86,7 +86,6 @@ function matchingExcludePatterns(patterns: string[], file: string): string[] {
}
function requireTestConfig<T extends { test?: unknown }>(config: T): NonNullable<T["test"]> {
expect(config.test).toBeDefined();
if (!config.test) {
throw new Error("expected scoped vitest test config");
}

View File

@@ -3,7 +3,6 @@ import uiConfig from "../ui/vitest.config.ts";
import uiNodeConfig from "../ui/vitest.node.config.ts";
function requireTestConfig<T extends { test?: unknown }>(config: T): NonNullable<T["test"]> {
expect(config.test).toBeDefined();
if (!config.test) {
throw new Error("expected ui package vitest test config");
}

View File

@@ -14,7 +14,6 @@ import {
import { createUnitFastVitestConfig } from "./vitest/vitest.unit-fast.config.ts";
function requireTestConfig<T extends { test?: unknown }>(config: T): NonNullable<T["test"]> {
expect(config.test).toBeDefined();
if (!config.test) {
throw new Error("expected unit-fast vitest test config");
}