fix(ci): stabilize windows tests
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { DisconnectReason } from "@whiskeysockets/baileys";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
@@ -7,12 +9,14 @@ vi.useFakeTimers();
|
||||
|
||||
const rmMock = vi.spyOn(fs, "rm");
|
||||
|
||||
const authDir = path.join(os.tmpdir(), "wa-creds");
|
||||
|
||||
vi.mock("../config/config.js", () => ({
|
||||
loadConfig: () =>
|
||||
({
|
||||
whatsapp: {
|
||||
accounts: {
|
||||
default: { enabled: true, authDir: "/tmp/wa-creds" },
|
||||
default: { enabled: true, authDir },
|
||||
},
|
||||
},
|
||||
}) as never,
|
||||
@@ -29,9 +33,9 @@ vi.mock("./session.js", () => {
|
||||
createWaSocket,
|
||||
waitForWaConnection,
|
||||
formatError,
|
||||
WA_WEB_AUTH_DIR: "/tmp/wa-creds",
|
||||
WA_WEB_AUTH_DIR: authDir,
|
||||
logoutWeb: vi.fn(async (params: { authDir?: string }) => {
|
||||
await fs.rm(params.authDir ?? "/tmp/wa-creds", {
|
||||
await fs.rm(params.authDir ?? authDir, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
@@ -75,7 +79,7 @@ describe("loginWeb coverage", () => {
|
||||
await expect(
|
||||
loginWeb(false, "web", waitForWaConnection as never),
|
||||
).rejects.toThrow(/cache cleared/i);
|
||||
expect(rmMock).toHaveBeenCalledWith("/tmp/wa-creds", {
|
||||
expect(rmMock).toHaveBeenCalledWith(authDir, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user