mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: tighten tooling helper assertions
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user