perf(test): reduce test startup overhead

This commit is contained in:
Peter Steinberger
2026-02-13 14:40:23 +00:00
parent 3bcde8df32
commit a7d6e44719
13 changed files with 283 additions and 286 deletions
+5 -10
View File
@@ -1,9 +1,8 @@
import { describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
describe("broadcast", () => {
it("accepts a broadcast peer map with strategy", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("accepts a broadcast peer map with strategy", () => {
const res = validateConfigObject({
agents: {
list: [{ id: "alfred" }, { id: "baerbel" }],
@@ -16,18 +15,14 @@ describe("broadcast", () => {
expect(res.ok).toBe(true);
});
it("rejects invalid broadcast strategy", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("rejects invalid broadcast strategy", () => {
const res = validateConfigObject({
broadcast: { strategy: "nope" },
});
expect(res.ok).toBe(false);
});
it("rejects non-array broadcast entries", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("rejects non-array broadcast entries", () => {
const res = validateConfigObject({
broadcast: { "120363403215116621@g.us": 123 },
});
@@ -1,9 +1,8 @@
import { describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
describe("gateway.remote.transport", () => {
it("accepts direct transport", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("accepts direct transport", () => {
const res = validateConfigObject({
gateway: {
remote: {
@@ -15,9 +14,7 @@ describe("gateway.remote.transport", () => {
expect(res.ok).toBe(true);
});
it("rejects unknown transport", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("rejects unknown transport", () => {
const res = validateConfigObject({
gateway: {
remote: {
@@ -1,9 +1,8 @@
import { describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
describe("gateway.tools config", () => {
it("accepts gateway.tools allow and deny lists", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("accepts gateway.tools allow and deny lists", () => {
const res = validateConfigObject({
gateway: {
tools: {
@@ -15,9 +14,7 @@ describe("gateway.tools config", () => {
expect(res.ok).toBe(true);
});
it("rejects invalid gateway.tools values", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("rejects invalid gateway.tools values", () => {
const res = validateConfigObject({
gateway: {
tools: {
+4 -7
View File
@@ -1,9 +1,8 @@
import { describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
describe("config msteams", () => {
it("accepts replyStyle at global/team/channel levels", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("accepts replyStyle at global/team/channel levels", () => {
const res = validateConfigObject({
channels: {
msteams: {
@@ -29,9 +28,7 @@ describe("config msteams", () => {
}
});
it("rejects invalid replyStyle", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("rejects invalid replyStyle", () => {
const res = validateConfigObject({
channels: { msteams: { replyStyle: "nope" } },
});
+4 -7
View File
@@ -1,9 +1,8 @@
import { describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
describe("sandbox docker config", () => {
it("accepts binds array in sandbox.docker config", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("accepts binds array in sandbox.docker config", () => {
const res = validateConfigObject({
agents: {
defaults: {
@@ -38,9 +37,7 @@ describe("sandbox docker config", () => {
}
});
it("rejects non-string values in binds array", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("rejects non-string values in binds array", () => {
const res = validateConfigObject({
agents: {
defaults: {
+4 -7
View File
@@ -1,9 +1,8 @@
import { describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
describe("talk.voiceAliases", () => {
it("accepts a string map of voice aliases", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("accepts a string map of voice aliases", () => {
const res = validateConfigObject({
talk: {
voiceAliases: {
@@ -15,9 +14,7 @@ describe("talk.voiceAliases", () => {
expect(res.ok).toBe(true);
});
it("rejects non-string voice alias values", async () => {
vi.resetModules();
const { validateConfigObject } = await import("./config.js");
it("rejects non-string voice alias values", () => {
const res = validateConfigObject({
talk: {
voiceAliases: {