test: stabilize slow and flaky tests
This commit is contained in:
@@ -372,7 +372,7 @@ describe("doctor command", () => {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
}, 10_000);
|
}, 20_000);
|
||||||
|
|
||||||
it("warns when extra workspace directories exist", async () => {
|
it("warns when extra workspace directories exist", async () => {
|
||||||
readConfigFileSnapshot.mockResolvedValue({
|
readConfigFileSnapshot.mockResolvedValue({
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ describe("parseSystemdExecStart", () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("supports backslash-escaped characters", () => {
|
it("parses path arguments", () => {
|
||||||
const execStart = "/usr/bin/clawdbot gateway start --path \/tmp\/clawdbot";
|
const execStart = "/usr/bin/clawdbot gateway start --path /tmp/clawdbot";
|
||||||
expect(parseSystemdExecStart(execStart)).toEqual([
|
expect(parseSystemdExecStart(execStart)).toEqual([
|
||||||
"/usr/bin/clawdbot",
|
"/usr/bin/clawdbot",
|
||||||
"gateway",
|
"gateway",
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ describe("telegram inbound media", () => {
|
|||||||
async () => {
|
async () => {
|
||||||
const { createTelegramBot } = await import("./bot.js");
|
const { createTelegramBot } = await import("./bot.js");
|
||||||
const replyModule = await import("../auto-reply/reply.js");
|
const replyModule = await import("../auto-reply/reply.js");
|
||||||
const replySpy = replyModule.getReplyFromConfig as unknown as ReturnType<typeof vi.fn>;
|
const replySpy = replyModule.__replySpy as unknown as ReturnType<typeof vi.fn>;
|
||||||
|
|
||||||
onSpy.mockReset();
|
onSpy.mockReset();
|
||||||
replySpy.mockReset();
|
replySpy.mockReset();
|
||||||
@@ -143,7 +143,7 @@ describe("telegram inbound media", () => {
|
|||||||
async () => {
|
async () => {
|
||||||
const { createTelegramBot } = await import("./bot.js");
|
const { createTelegramBot } = await import("./bot.js");
|
||||||
const replyModule = await import("../auto-reply/reply.js");
|
const replyModule = await import("../auto-reply/reply.js");
|
||||||
const replySpy = replyModule.getReplyFromConfig as unknown as ReturnType<typeof vi.fn>;
|
const replySpy = replyModule.__replySpy as unknown as ReturnType<typeof vi.fn>;
|
||||||
|
|
||||||
onSpy.mockReset();
|
onSpy.mockReset();
|
||||||
replySpy.mockReset();
|
replySpy.mockReset();
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ import os from "node:os";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
|
||||||
import { DisconnectReason } from "@whiskeysockets/baileys";
|
import { DisconnectReason } from "@whiskeysockets/baileys";
|
||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
vi.useFakeTimers();
|
|
||||||
|
|
||||||
const rmMock = vi.spyOn(fs, "rm");
|
const rmMock = vi.spyOn(fs, "rm");
|
||||||
|
|
||||||
@@ -51,9 +49,13 @@ const { loginWeb } = await import("./login.js");
|
|||||||
|
|
||||||
describe("loginWeb coverage", () => {
|
describe("loginWeb coverage", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
vi.useFakeTimers();
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
rmMock.mockClear();
|
rmMock.mockClear();
|
||||||
});
|
});
|
||||||
|
afterEach(() => {
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
it("restarts once when WhatsApp requests code 515", async () => {
|
it("restarts once when WhatsApp requests code 515", async () => {
|
||||||
waitForWaConnection
|
waitForWaConnection
|
||||||
|
|||||||
Reference in New Issue
Block a user